l0_scope_context.py

l0_scope_context.py

Module: l0_scope_context

Source: compiler/stage1_py/l0_scope_context.py Language: Python

Symbols

Namespace l0_scope_context

Class l0_scope_context::ScopeContext

Tracks variables and cleanup requirements for a single lexical scope.

Member Data l0_scope_context.ScopeContext.owned_vars

1
List owned_vars

Member Data l0_scope_context.ScopeContext.declared_vars

1
List declared_vars

Member Data l0_scope_context.ScopeContext.parent

1
Optional parent

Member Data l0_scope_context.ScopeContext.with_cleanup_inline

1
Optional with_cleanup_inline

Member Data l0_scope_context.ScopeContext.with_cleanup_block

1
Optional with_cleanup_block

Member Data l0_scope_context.ScopeContext.with_cleanup_in_progress

1
bool with_cleanup_in_progress

Member Data l0_scope_context.ScopeContext.owned_vars

1
l0_scope_context.ScopeContext::owned_vars

Function l0_scope_context.ScopeContext.add_owned

1
None l0_scope_context.ScopeContext.add_owned(self, str var_name, Type var_type)

Mark a variable as owned (requiring cleanup) and declared.

Parameters:

  • var_name: The (mangled) name of the variable.
  • var_type: The L0 Type of the variable.

    Function l0_scope_context.ScopeContext.add_declared

1
None l0_scope_context.ScopeContext.add_declared(self, str var_name, Type var_type)

Mark a variable as declared for type lookup only.

Used for function parameters and pattern variables, which are managed by the caller or scrutinee and do not require cleanup within the current scope.

Parameters:

  • var_name: The (mangled) name of the variable.
  • var_type: The L0 Type of the variable.

    Function l0_scope_context.ScopeContext.remove_owned

1
None l0_scope_context.ScopeContext.remove_owned(self, str var_name)

Remove a variable from the owned set.

Parameters:

  • var_name: The (mangled) name of the variable to stop tracking.