将 EnumName/value/IsSigned 加入 FIELD_ROUTES,消除所有冗余 hasattr/getattr
This commit is contained in:
@@ -173,28 +173,28 @@ class BaseGenMixin:
|
||||
return ir.IntType(8)
|
||||
if hasattr(self, 'SymbolTable') and self.SymbolTable and clean_name in self.SymbolTable:
|
||||
Entry = self.SymbolTable[clean_name]
|
||||
if hasattr(Entry, 'IsTypedef') and Entry.IsTypedef:
|
||||
if Entry.IsTypedef:
|
||||
resolved_str = self._resolve_typedef(clean_name)
|
||||
if resolved_str != clean_name:
|
||||
return self._type_str_to_llvm(resolved_str)
|
||||
if hasattr(Entry, 'BaseType') and Entry.BaseType:
|
||||
if Entry.BaseType:
|
||||
from lib.includes import t as _t
|
||||
if not isinstance(Entry.BaseType, (_t._CTypedef,)) or getattr(Entry, 'PtrCount', 0) > 0:
|
||||
if not isinstance(Entry.BaseType, (_t._CTypedef,)) or Entry.PtrCount > 0:
|
||||
resolved = self._resolve_ctype_to_str(Entry)
|
||||
if resolved:
|
||||
return self._type_str_to_llvm(resolved)
|
||||
if hasattr(Entry, 'IsRenum') and Entry.IsRenum:
|
||||
if Entry.IsRenum:
|
||||
if clean_name in self.structs:
|
||||
return self.structs[clean_name]
|
||||
if hasattr(Entry, 'IsEnum') and Entry.IsEnum:
|
||||
if Entry.IsEnum:
|
||||
return ir.IntType(32)
|
||||
if hasattr(Entry, 'IsExceptionClass') and Entry.IsExceptionClass:
|
||||
if Entry.IsExceptionClass:
|
||||
return ir.IntType(32)
|
||||
if hasattr(Entry, 'IsFunction') and Entry.IsFunction:
|
||||
if Entry.IsFunction:
|
||||
return ir.PointerType(ir.IntType(8))
|
||||
if hasattr(Entry, 'IsVariable') and Entry.IsVariable:
|
||||
if Entry.IsVariable:
|
||||
return ir.PointerType(ir.IntType(8))
|
||||
if hasattr(Entry, 'BaseType'):
|
||||
if Entry.BaseType:
|
||||
from lib.includes import t as _t
|
||||
if isinstance(Entry.BaseType, type) and issubclass(Entry.BaseType, _t.CEnum):
|
||||
return ir.IntType(32)
|
||||
@@ -237,17 +237,17 @@ class BaseGenMixin:
|
||||
# 2. 再查 SymbolTable(用户定义的 typedef)
|
||||
if hasattr(self, 'SymbolTable') and self.SymbolTable and name in self.SymbolTable:
|
||||
Entry = self.SymbolTable[name]
|
||||
if hasattr(Entry, 'IsTypedef') and Entry.IsTypedef:
|
||||
if hasattr(Entry, 'BaseType') and Entry.BaseType:
|
||||
if Entry.IsTypedef:
|
||||
if Entry.BaseType:
|
||||
from lib.includes import t as _t
|
||||
if not isinstance(Entry.BaseType, (_t._CTypedef,)) and getattr(Entry, 'PtrCount', 0) == 0:
|
||||
if not isinstance(Entry.BaseType, (_t._CTypedef,)) and Entry.PtrCount == 0:
|
||||
llvm_str = CTypeRegistry.CTypeToLLVM(type(Entry.BaseType) if isinstance(Entry.BaseType, _t.CType) else Entry.BaseType)
|
||||
if llvm_str and llvm_str.startswith('i') and llvm_str[1:].isdigit():
|
||||
return int(llvm_str[1:])
|
||||
if hasattr(Entry, 'OriginalType') and Entry.OriginalType:
|
||||
if Entry.OriginalType:
|
||||
from lib.core.Handles.HandlesBase import CTypeInfo as _CTypeInfo
|
||||
if isinstance(Entry.OriginalType, _CTypeInfo) and Entry.OriginalType.BaseType:
|
||||
if not isinstance(Entry.OriginalType.BaseType, (_t._CTypedef,)) and getattr(Entry.OriginalType, 'PtrCount', 0) == 0:
|
||||
if not isinstance(Entry.OriginalType.BaseType, (_t._CTypedef,)) and Entry.OriginalType.PtrCount == 0:
|
||||
llvm_str = CTypeRegistry.CTypeToLLVM(type(Entry.OriginalType.BaseType) if isinstance(Entry.OriginalType.BaseType, _t.CType) else Entry.OriginalType.BaseType)
|
||||
if llvm_str and llvm_str.startswith('i') and llvm_str[1:].isdigit():
|
||||
return int(llvm_str[1:])
|
||||
|
||||
Reference in New Issue
Block a user