scope_context.l0

scope_context.l0

Module: scope_context

Source: compiler/stage2_l0/src/scope_context.l0 Language: Dea/L0

Imports / Includes

  • types
  • ast
  • std.vector
  • std.string

Symbols

Function sc_create

1
func sc_create(parent: ScopeContext*?) -> ScopeContext*

Create a backend scope context.

Parameters:

  • parent: Parent scope, or null for the function root.

Returns: New scope context.

Function sc_var_free

1
func sc_var_free(self: ScopeVar*)

Free a tracked variable record.

Parameters:

  • self: Record to free.

Function sc_inline_cleanup_free_opt

1
func sc_inline_cleanup_free_opt(items: VectorBase*?)

Free an optional inline-cleanup vector.

Parameters:

  • items: Optional cleanup vector to free.

Function sc_free

1
func sc_free(self: ScopeContext*)

Free one scope context and its owned containers.

Parameters:

  • self: Scope context to free.

Function sc_add_declared

1
func sc_add_declared(self: ScopeContext*, name: string, var_type: Type*)

Add a declared variable to a scope.

Parameters:

  • self: Scope to update.
  • name: Mangled C variable name.
  • var_type: Resolved L0 type.

Function sc_add_owned

1
func sc_add_owned(self: ScopeContext*, name: string, var_type: Type*)

Add an owned variable to a scope and record it as declared.

Parameters:

  • self: Scope to update.
  • name: Mangled C variable name.
  • var_type: Resolved L0 type.

Function sc_remove_owned

1
func sc_remove_owned(self: ScopeContext*, name: string)

Remove a variable from the owned set.

Parameters:

  • self: Scope to update.
  • name: Mangled C variable name to stop cleaning up.

Function sc_lookup_declared_type

1
func sc_lookup_declared_type(self: ScopeContext*?, name: string) -> Type*?

Return the closest declared variable type from a scope chain.

Parameters:

  • self: Starting scope, or null.
  • name: Mangled C variable name to find.

Returns: Borrowed type pointer, or null if absent.

Function sc_has_inline_cleanup

1
func sc_has_inline_cleanup(self: ScopeContext*) -> bool

Return whether a scope currently has inline cleanup items.

Parameters:

Returns: true if inline cleanup statements are recorded.

Function sc_push_inline_cleanup

1
func sc_push_inline_cleanup(self: ScopeContext*, stmt_id: StmtId)

Lazily create and append an inline cleanup statement id.

Parameters:

  • self: Scope to update.
  • stmt_id: Cleanup statement id to append.

Struct ScopeVar

Represents one declared variable tracked by the backend.

ScopeVar Field name

1
name: string

ScopeVar Field var_type

1
var_type: Type*

Struct ScopeContext

Represents backend cleanup state for a single lexical scope.

ScopeContext Field scope_id

1
scope_id: int

ScopeContext Field parent

1
parent: ScopeContext*?

ScopeContext Field owned_vars

1
owned_vars: VectorBase*

ScopeContext Field declared_vars

1
declared_vars: VectorBase*

ScopeContext Field with_cleanup_inline

1
with_cleanup_inline: VectorBase*?

ScopeContext Field with_cleanup_block

1
with_cleanup_block: StmtId

ScopeContext Field with_cleanup_in_progress

1
with_cleanup_in_progress: bool