ast.l0

ast.l0

Module: ast

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

Imports / Includes

  • std.vector
  • std.string
  • std.assert

Symbols

Enum TopLevelDeclKind

1
TopLevelDeclKind

Defines the TopLevelDeclKind enumeration.

Variants:

  • TD_FUNC
  • TD_STRUCT
  • TD_ENUM
  • TD_TYPE_ALIAS
  • TD_LET

Enum PatternKind

1
PatternKind

Defines the PatternKind enumeration.

Variants:

  • PT_WILDCARD
  • PT_VARIANT

Enum ExprKind

1
ExprKind

Defines the ExprKind enumeration.

Variants:

  • EX_INT
  • EX_BYTE
  • EX_STRING
  • EX_BOOL
  • EX_NULL
  • EX_VAR_REF
  • EX_NEW
  • EX_UNARY
  • EX_BINARY
  • EX_CALL
  • EX_INDEX
  • EX_FIELD
  • EX_PAREN
  • EX_CAST
  • EX_TRY
  • EX_TYPE

Enum StmtKind

1
StmtKind

Defines the StmtKind enumeration.

Variants:

  • ST_BLOCK
  • ST_LET
  • ST_ASSIGN
  • ST_EXPR
  • ST_IF
  • ST_WHILE
  • ST_FOR
  • ST_RETURN
  • ST_DROP
  • ST_MATCH
  • ST_CASE
  • ST_BREAK
  • ST_CONTINUE
  • ST_WITH

Type Alias ExprId

1
type ExprId = int

Type Alias StmtId

1
type StmtId = int

Type Alias PatternId

1
type PatternId = int

Function invalid_expr_id

1
func invalid_expr_id() -> ExprId

Returns an invalid ID for a expr to indicate absence.

Returns: The sentinel value indicating an invalid expression ID (-1).

Function invalid_stmt_id

1
func invalid_stmt_id() -> StmtId

Returns an invalid ID for a stmt to indicate absence.

Returns: The sentinel value indicating an invalid statement ID (-1).

Function invalid_pattern_id

1
func invalid_pattern_id() -> PatternId

Returns an invalid ID for a pattern to indicate absence.

Returns: The sentinel value indicating an invalid pattern ID (-1).

Function ptr_vec_create

1
func ptr_vec_create(initial_capacity: int) -> VectorBase*

Create a vector of pointer slots.

Parameters:

  • initial_capacity: Initial vector capacity.

Returns: New pointer vector.

Function ptr_vec_push

1
func ptr_vec_push(self: VectorBase*, ptr: void*)

Append a pointer value to a pointer vector.

Parameters:

  • self: Pointer vector to extend.
  • ptr: Pointer value to append.

Function ptr_vec_get

1
func ptr_vec_get(self: VectorBase*, index: int) -> void*

Return a pointer value from a pointer vector.

Parameters:

  • self: Pointer vector to inspect.
  • index: Zero-based element index.

Returns: Pointer value at index.

Function id_vec_create

1
func id_vec_create(initial_capacity: int) -> VectorBase*

Create a vector of integer ids.

Parameters:

  • initial_capacity: Initial vector capacity.

Returns: New id vector.

Function id_vec_push

1
func id_vec_push(self: VectorBase*, id: int)

Append an id to an id vector.

Parameters:

  • self: Id vector to extend.
  • id: Id value to append.

Function id_vec_get

1
func id_vec_get(self: VectorBase*, index: int) -> int

Return an id from an id vector.

Parameters:

  • self: Id vector to inspect.
  • index: Zero-based element index.

Returns: Id value at index.

Function span_here

1
func span_here(line: int, column: int) -> Span

Build a zero-width span at a source location.

Parameters:

  • line: One-based source line.
  • column: One-based source column.

Returns: Span whose start and end are the same location.

Function pattern_node_create

1
func pattern_node_create(kind: PatternKind, span: Span) -> PatternNode*

Create a pattern node.

Parameters:

  • kind: Pattern kind.
  • span: Source span for the node.

Returns: New pattern node.

Function pattern_arena_create

1
func pattern_arena_create(initial_capacity: int) -> PatternArena*

Create a pattern arena.

Parameters:

  • initial_capacity: Initial arena capacity.

Returns: New pattern arena.

Function pattern_arena_add

1
func pattern_arena_add(self: PatternArena*, node: PatternNode*) -> PatternId

Add a pattern node to the arena.

Parameters:

  • self: Pattern arena to extend.
  • node: Pattern node to store.

Returns: Pattern id assigned to the stored node.

Function pattern_arena_get

1
func pattern_arena_get(self: PatternArena*, id: PatternId) -> PatternNode*

Return a pattern node from the arena.

Parameters:

  • self: Pattern arena to inspect.
  • id: Pattern id to look up.

Returns: Pattern node for id.

Function sv_free_opt

1
func sv_free_opt(v: StringVector*?)

Free an optional string vector.

Parameters:

  • v: Optional vector to free.

Function pattern_node_free

1
func pattern_node_free(node: PatternNode*)

Free a pattern node and any owned vectors.

Parameters:

  • node: Pattern node to free.

Function pattern_arena_free

1
func pattern_arena_free(self: PatternArena*)

Free a pattern arena and every stored node.

Parameters:

  • self: Pattern arena to free.

Function expr_node_create

1
func expr_node_create(kind: ExprKind, span: Span) -> ExprNode*

Create an expression node.

Parameters:

  • kind: Expression kind.
  • span: Source span for the node.

Returns: New expression node.

Function expr_arena_create

1
func expr_arena_create(initial_capacity: int) -> ExprArena*

Create an expression arena.

Parameters:

  • initial_capacity: Initial arena capacity.

Returns: New expression arena.

Function expr_arena_add

1
func expr_arena_add(self: ExprArena*, node: ExprNode*) -> ExprId

Add an expression node to the arena.

Parameters:

  • self: Expression arena to extend.
  • node: Expression node to store.

Returns: Expression id assigned to the stored node.

Function expr_arena_get

1
func expr_arena_get(self: ExprArena*, id: ExprId) -> ExprNode*

Return an expression node from the arena.

Parameters:

  • self: Expression arena to inspect.
  • id: Expression id to look up.

Returns: Expression node for id.

Function stmt_node_create

1
func stmt_node_create(kind: StmtKind, span: Span) -> StmtNode*

Create a statement node.

Parameters:

  • kind: Statement kind.
  • span: Source span for the node.

Returns: New statement node.

Function stmt_arena_create

1
func stmt_arena_create(initial_capacity: int) -> StmtArena*

Create a statement arena.

Parameters:

  • initial_capacity: Initial arena capacity.

Returns: New statement arena.

Function stmt_arena_add

1
func stmt_arena_add(self: StmtArena*, node: StmtNode*) -> StmtId

Add a statement node to the arena.

Parameters:

  • self: Statement arena to extend.
  • node: Statement node to store.

Returns: Statement id assigned to the stored node.

Function stmt_arena_get

1
func stmt_arena_get(self: StmtArena*, id: StmtId) -> StmtNode*

Return a statement node from the arena.

Parameters:

  • self: Statement arena to inspect.
  • id: Statement id to look up.

Returns: Statement node for id.

Function type_ref_free

1
func type_ref_free(self: TypeRef*?)

Free an optional type reference.

Parameters:

  • self: Optional type reference to free.

Function param_free

1
func param_free(self: Param*)

Free a function parameter node.

Parameters:

  • self: Parameter to free.

Function field_decl_free

1
func field_decl_free(self: FieldDecl*)

Free a field declaration node.

Parameters:

  • self: Field declaration to free.

Function enum_variant_free

1
func enum_variant_free(self: EnumVariant*)

Free an enum variant declaration.

Parameters:

  • self: Enum variant to free.

Function func_decl_free

1
func func_decl_free(self: FuncDecl*)

Free a function declaration.

Parameters:

  • self: Function declaration to free.

Function struct_decl_free

1
func struct_decl_free(self: StructDecl*)

Free a struct declaration.

Parameters:

  • self: Struct declaration to free.

Function enum_decl_free

1
func enum_decl_free(self: EnumDecl*)

Free an enum declaration.

Parameters:

  • self: Enum declaration to free.

Function type_alias_decl_free

1
func type_alias_decl_free(self: TypeAliasDecl*)

Free a type-alias declaration.

Parameters:

  • self: Type-alias declaration to free.

Function let_decl_free

1
func let_decl_free(self: LetDecl*)

Free a top-level let declaration.

Parameters:

  • self: Let declaration to free.

Function top_level_decl_free

1
func top_level_decl_free(self: TopLevelDecl*)

Free a top-level declaration wrapper and its payload.

Parameters:

  • self: Top-level declaration to free.

Function module_free

1
func module_free(self: Module*)

Free a parsed module and its owned declarations.

Parameters:

Function id_vec_free

1
func id_vec_free(v: VectorBase*?)

Free an optional id vector.

Parameters:

  • v: Optional vector to free.

Function import_vec_free

1
func import_vec_free(v: VectorBase*?)

Free an optional import vector.

Parameters:

  • v: Optional import vector to free.

Function top_level_decl_vec_free

1
func top_level_decl_vec_free(v: VectorBase*?)

Free an optional top-level declaration vector.

Parameters:

  • v: Optional declaration vector to free.

Function param_vec_free

1
func param_vec_free(v: VectorBase*?)

Free an optional parameter vector.

Parameters:

  • v: Optional parameter vector to free.

Function field_decl_vec_free

1
func field_decl_vec_free(v: VectorBase*?)

Free an optional field-declaration vector.

Parameters:

  • v: Optional field-declaration vector to free.

Function enum_variant_vec_free

1
func enum_variant_vec_free(v: VectorBase*?)

Free an optional enum-variant vector.

Parameters:

  • v: Optional enum-variant vector to free.

Function match_arm_vec_free

1
func match_arm_vec_free(v: VectorBase*?)

Free an optional match-arm vector.

Parameters:

  • v: Optional match-arm vector to free.

Function case_arm_vec_free

1
func case_arm_vec_free(v: VectorBase*?)

Free an optional case-arm vector.

Parameters:

  • v: Optional case-arm vector to free.

Function with_item_vec_free

1
func with_item_vec_free(v: VectorBase*?)

Free an optional with -item vector.

Parameters:

  • v: Optional with-item vector to free.

Function expr_node_free

1
func expr_node_free(self: ExprNode*)

Free an expression node and its owned payload.

Parameters:

  • self: Expression node to free.

Function stmt_node_free

1
func stmt_node_free(self: StmtNode*)

Free a statement node and its owned payload.

Parameters:

  • self: Statement node to free.

Function expr_arena_free

1
func expr_arena_free(self: ExprArena*)

Free an expression arena and every stored node.

Parameters:

  • self: Expression arena to free.

Function stmt_arena_free

1
func stmt_arena_free(self: StmtArena*)

Free a statement arena and every stored node.

Parameters:

  • self: Statement arena to free.

Struct Span

Represents the Span structure.

Span Field start_line

1
start_line: int

Span Field start_column

1
start_column: int

Span Field end_line

1
end_line: int

Span Field end_column

1
end_column: int

Struct TypeRef

Represents the TypeRef structure.

TypeRef Field name

1
name: string

TypeRef Field pointer_depth

1
pointer_depth: int

TypeRef Field is_nullable

1
is_nullable: bool

TypeRef Field module_path

1
module_path: StringVector*?

TypeRef Field name_qualifier

1
name_qualifier: StringVector*?

TypeRef Field span

1
span: Span

Struct Import

Represents the Import structure.

Import Field name

1
name: string

Import Field span

1
span: Span

Struct Param

Represents the Param structure.

Param Field name

1
name: string

Param Field type_ref

1
type_ref: TypeRef*

Struct FieldDecl

Represents the FieldDecl structure.

FieldDecl Field name

1
name: string

FieldDecl Field type_ref

1
type_ref: TypeRef*

Struct EnumVariant

Represents the EnumVariant structure.

EnumVariant Field name

1
name: string

EnumVariant Field fields

1
fields: VectorBase*

Struct FuncDecl

Represents the FuncDecl structure.

FuncDecl Field name

1
name: string

FuncDecl Field params

1
params: VectorBase*

FuncDecl Field return_type

1
return_type: TypeRef*

FuncDecl Field body

1
body: StmtId

FuncDecl Field is_extern

1
is_extern: bool

FuncDecl Field span

1
span: Span

Struct StructDecl

Represents the StructDecl structure.

StructDecl Field name

1
name: string

StructDecl Field fields

1
fields: VectorBase*

StructDecl Field span

1
span: Span

Struct EnumDecl

Represents the EnumDecl structure.

EnumDecl Field name

1
name: string

EnumDecl Field variants

1
variants: VectorBase*

EnumDecl Field span

1
span: Span

Struct TypeAliasDecl

Represents the TypeAliasDecl structure.

TypeAliasDecl Field name

1
name: string

TypeAliasDecl Field target

1
target: TypeRef*

TypeAliasDecl Field span

1
span: Span

Struct LetDecl

Represents the LetDecl structure.

LetDecl Field name

1
name: string

LetDecl Field type_ref

1
type_ref: TypeRef*?

LetDecl Field value

1
value: ExprId

LetDecl Field span

1
span: Span

Struct TopLevelDecl

Represents the TopLevelDecl structure.

TopLevelDecl Field kind

1
kind: TopLevelDeclKind

TopLevelDecl Field data

1
data: void*

Struct Module

Represents the Module structure.

Module Field name

1
name: string

Module Field imports

1
imports: VectorBase*

Module Field decls

1
decls: VectorBase*

Module Field span

1
span: Span

Module Field filename

1
filename: string

Struct PatternNode

Represents the PatternNode structure.

PatternNode Field kind

1
kind: PatternKind

PatternNode Field span

1
span: Span

PatternNode Field name

1
name: string

PatternNode Field vars

1
vars: StringVector*?

PatternNode Field module_path

1
module_path: StringVector*?

PatternNode Field name_qualifier

1
name_qualifier: StringVector*?

Struct PatternArena

Represents the PatternArena structure.

PatternArena Field nodes

1
nodes: VectorBase*

Struct ExprNode

Represents the ExprNode structure.

ExprNode Field kind

1
kind: ExprKind

ExprNode Field span

1
span: Span

ExprNode Field int_value

1
int_value: int

ExprNode Field bool_value

1
bool_value: bool

ExprNode Field text_value

1
text_value: string

ExprNode Field expr_a

1
expr_a: ExprId

ExprNode Field expr_b

1
expr_b: ExprId

ExprNode Field expr_c

1
expr_c: ExprId

ExprNode Field ids

1
ids: VectorBase*?

ExprNode Field type_ref

1
type_ref: TypeRef*?

ExprNode Field module_path

1
module_path: StringVector*?

ExprNode Field name_qualifier

1
name_qualifier: StringVector*?

Struct ExprArena

Represents the ExprArena structure.

ExprArena Field nodes

1
nodes: VectorBase*

Struct MatchArm

Represents the MatchArm structure.

MatchArm Field pattern

1
pattern: PatternId

MatchArm Field body

1
body: StmtId

MatchArm Field span

1
span: Span

Struct CaseArm

Represents the CaseArm structure.

CaseArm Field literal

1
literal: ExprId

CaseArm Field body

1
body: StmtId

CaseArm Field span

1
span: Span

Struct CaseElse

Represents the CaseElse structure.

CaseElse Field body

1
body: StmtId

CaseElse Field span

1
span: Span

Struct WithItem

Represents the WithItem structure.

WithItem Field init

1
init: StmtId

WithItem Field cleanup_stmt

1
cleanup_stmt: StmtId

WithItem Field has_cleanup

1
has_cleanup: bool

WithItem Field span

1
span: Span

Struct StmtNode

Represents the StmtNode structure.

StmtNode Field kind

1
kind: StmtKind

StmtNode Field span

1
span: Span

StmtNode Field name

1
name: string

StmtNode Field type_ref

1
type_ref: TypeRef*?

StmtNode Field expr_a

1
expr_a: ExprId

StmtNode Field expr_b

1
expr_b: ExprId

StmtNode Field stmt_a

1
stmt_a: StmtId

StmtNode Field stmt_b

1
stmt_b: StmtId

StmtNode Field stmt_c

1
stmt_c: StmtId

StmtNode Field ids

1
ids: VectorBase*?

StmtNode Field match_arms

1
match_arms: VectorBase*?

StmtNode Field case_arms

1
case_arms: VectorBase*?

StmtNode Field case_else

1
case_else: CaseElse*?

StmtNode Field with_items

1
with_items: VectorBase*?

Struct StmtArena

Represents the StmtArena structure.

StmtArena Field nodes

1
nodes: VectorBase*