SPPCompiler.SemanticAnalysis.Scoping.ScopeManager module

class SPPCompiler.SemanticAnalysis.Scoping.ScopeManager.ScopeManager(global_scope, current_scope=None, nsbs=None, gsbs=None)

Bases: object

normal_sup_blocks: DefaultDict[TypeSymbol, list[Scope]]
generic_sup_blocks: dict[TypeSymbol, Scope]
reset(scope=None, iterator=None)
Return type:

None

create_and_move_into_new_scope(name, ast=None, error_formatter=None)
Return type:

Scope

move_out_of_current_scope()
Return type:

Scope

move_to_next_scope()
Return type:

Scope

get_namespaced_scope(namespace)
Return type:

Optional[Scope]

attach_super_scopes(progress, **kwargs)

The first thing to do is to identify every single “super scope”. These are scopes whose “ast” is either a SupPrototypeExtensionAst or a SupPrototypeFunctionsAst. Store them in a dictionary, with the key being their “name” attribute.

Iterate through every “top-level” scope, and identify each type scope. This is a scope whose “ast” is a ClassPrototypeAst. Only look inside module scopes for these (they will never be in more nested scopes). Once a type scope is found, compare its name against the dictionary of super scopes, using the relaxed symbolic comparison.

For every match found, attach the super scope to the class scope’s “_direct_up_scopes”. For sup-ext blocks, also add the class scope for the super-class, by using “get_symbol(super_class).scope”. This is required to use the attributes (state) of superclasses. Only add unique superclasses once.

Return type:

None

attach_super_scopes_helper(scope, **kwargs)
Return type:

None

attach_super_scopes_to_target_scope(scope, super_scopes, progress=None, **kwargs)
Return type:

None

property global_scope: Scope
property current_scope: Scope