将 EnumName/value/IsSigned 加入 FIELD_ROUTES,消除所有冗余 hasattr/getattr
This commit is contained in:
@@ -329,7 +329,7 @@ class ExprHandle(BaseHandle):
|
||||
if VarName not in getattr(Gen, '_define_constants', {}):
|
||||
try:
|
||||
sym_info = self.translator.SymbolTable.get(VarName)
|
||||
if sym_info and getattr(sym_info, 'IsDefine', None) and getattr(sym_info, 'DefineValue', None) is not None:
|
||||
if sym_info and sym_info.IsDefine and sym_info.DefineValue is not None:
|
||||
val = sym_info.DefineValue
|
||||
if isinstance(val, int):
|
||||
# Use VarType hint if available
|
||||
@@ -400,9 +400,9 @@ class ExprHandle(BaseHandle):
|
||||
return ir.Constant(ir.IntType(32), 1 if VarName == 'True' else 0)
|
||||
if VarName in self.Trans.SymbolTable:
|
||||
SymInfo = self.Trans.SymbolTable[VarName]
|
||||
if getattr(SymInfo, 'IsEnumMember', None) and isinstance(getattr(SymInfo, 'value', None), int):
|
||||
if SymInfo.IsEnumMember and isinstance(SymInfo.value, int):
|
||||
return ir.Constant(ir.IntType(32), SymInfo.value)
|
||||
if getattr(SymInfo, 'IsFunction', False) or getattr(SymInfo, 'IsFuncPtr', False):
|
||||
if SymInfo.IsFunction or SymInfo.IsFuncPtr:
|
||||
MangledName = Gen._mangle_func_name(VarName)
|
||||
if MangledName in Gen.module.globals:
|
||||
g = Gen.module.globals[MangledName]
|
||||
|
||||
Reference in New Issue
Block a user