TranslationUnit¶
The root of every ASR graph.
Declaration¶
Syntax¶
TranslationUnit(symbol_table symtab, node* items)
Arguments¶
Argument |
Description |
|---|---|
|
the global symbol table, with |
|
statements and expressions that are not inside any program unit yet. Only the interactive frontends produce them; the |
Return values¶
None.
Description¶
A TranslationUnit is what a frontend produces and what every ASR pass and
backend consumes. It is the only constructor of the unit type, so it is also
the only thing an ASR text document may have at its root.
The global symbol table is the root of the symbol graph. Symbols nested deeper (a variable of a program, a function of a module) live in the symbol table of their owner, and every symbol table other than the global one is reachable from it by walking the owning symbols.
Examples¶
An ASR text document is always a TranslationUnit:
(TranslationUnit
:symtab (SymbolTable
:id 0
:symbols {
"m" (Module
:symtab (SymbolTable
:id 1
:symbols {
"c" (Variable
:parent_symtab 1
:name "c"
:dependencies []
:intent :Local
:symbolic_value (IntegerConstant
:n 3
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:value (IntegerConstant
:n 3
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:storage :Parameter
:type (Integer
:kind 4
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
)
}
)
:name "m"
:parent_module nil
:dependencies []
:loaded_from_mod false
:intrinsic false
:has_submodules false
)
"main" (Program
:symtab (SymbolTable
:id 2
:symbols {
"c" (ExternalSymbol
:parent_symtab 2
:name "c"
:external (SymbolRef 1 "c")
:module_name "m"
:scope_names []
:original_name "c"
:access :Public
)
"x" (Variable
:parent_symtab 2
:name "x"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Integer
:kind 4
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
)
}
)
:name "main"
:dependencies [
"m"
]
:body [
(Assignment
:target (Var
:v (SymbolRef 2 "x")
)
:value (Var
:v (SymbolRef 2 "c")
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
]
)
}
)
:items []
)