SignatureResolver class
Defined in module l0_signatures (l0_signatures.py).
Resolves top-level type signatures across all modules.
The resolver processes:
- Function signatures (parameters and return types).
- Struct field types.
- Enum variant payload types.
- Type alias targets.
- Module-level constant (let) types.
It also performs cycle detection for value-type definitions.
Constructors, destructors, conversion operators
- __init__(self, CompilationUnit cu, Dict module_envs[str, ModuleEnv])
- Initialize the signature resolver.
Public functions
- auto resolve(self) -> None
- Resolve all top-level signatures in the compilation unit.
Public attributes
Protected functions
- auto _resolve_module_signatures(self, ModuleEnv env) -> None
- Resolve all declarations within a single module.
- auto _emit(self, Diagnostic diag) -> None
- Add a diagnostic to the collection.
- auto _resolve_type_ref(self, ModuleEnv env, TypeRef tref, Optional]] alias_stack[Set[Tuple[str, str] = None) -> Optional[Type]
- Resolve a TypeRef in the context of a module environment.
- auto _resolve_type_alias_symbol(self, ModuleEnv env, Symbol sym, Optional]] alias_stack[Set[Tuple[str, str] = None) -> Optional[Type]
- Resolve a TYPE_ALIAS symbol to its target Type.
- auto _resolve_struct(self, ModuleEnv env, StructDecl decl) -> None
- Resolve field types for a struct declaration.
- auto _resolve_enum(self, ModuleEnv env, EnumDecl decl) -> None
- Resolve variant payload types for an enum declaration.
- auto _resolve_func(self, ModuleEnv env, FuncDecl decl) -> None
- Resolve parameter and return types for a function declaration.
- auto _resolve_type_alias(self, ModuleEnv env, TypeAliasDecl decl) -> None
- Resolve the target type for a type alias.
- auto _resolve_let(self, ModuleEnv env, LetDecl decl) -> None
- Resolve or infer the type for a module-level 'let' binding.
- auto _infer_literal_type(self, ModuleEnv env, Expr expr) -> Optional[Type]
- Infer type from simple literal expressions and struct/enum construction.
- auto _symbol_is_zero_arg_enum_variant(self, Symbol sym) -> bool
- Return whether a symbol names a zero-argument enum variant.
- auto _enum_type_for_variant_symbol(self, Symbol sym) -> Optional[EnumType]
- Return the owning enum type for an enum variant symbol.
- auto _extract_value_type_dependencies(self, Type typ) -> Set[Tuple[str, str]]
- Extract type dependencies for value fields only (pointer-free).
- auto _detect_value_type_cycles(self) -> None
- Detect and report cycles in value-type definitions.
Function documentation
l0_signatures:: SignatureResolver:: __init__(self,
CompilationUnit cu,
Dict module_envs[str, ModuleEnv])
Initialize the signature resolver.
| Parameters | |
|---|---|
| cu | The compilation unit. |
| module_envs | Environments produced by name resolution. |
None l0_signatures:: SignatureResolver:: resolve(self)
Resolve all top-level signatures in the compilation unit.
This iterates through all modules and their declarations, populating the resolution tables and reporting any errors found.
Optional[Type] l0_signatures:: SignatureResolver:: _resolve_type_ref(self,
ModuleEnv env,
TypeRef tref,
Optional]] alias_stack[Set[Tuple[str, str] = None) protected
Resolve a TypeRef in the context of a module environment.
| Parameters | |
|---|---|
| env | The current module environment. |
| tref | The TypeRef AST node to resolve. |
| alias_stack | Stack of aliases being resolved (for cycle detection). |
| Returns | The resolved Type if successful, otherwise None. |
Optional[Type] l0_signatures:: SignatureResolver:: _resolve_type_alias_symbol(self,
ModuleEnv env,
Symbol sym,
Optional]] alias_stack[Set[Tuple[str, str] = None) protected
Resolve a TYPE_ALIAS symbol to its target Type.
| Parameters | |
|---|---|
| env | Current module environment. |
| sym | The type alias symbol to resolve. |
| alias_stack | Set of alias identifiers currently being resolved. |
| Returns | The target Type if successful, otherwise None. |
Caches the result in sym.type. Detects recursive alias cycles.
None l0_signatures:: SignatureResolver:: _detect_value_type_cycles(self) protected
Detect and report cycles in value-type definitions.
Value-type cycles (where A contains B and B contains A directly) create infinite-size types and are prohibited. Pointers must be used to break such cycles.