Program¶
The main program: the entry point of an executable.
Declaration¶
Syntax¶
Program(symbol_table symtab, identifier name, identifier* dependencies,
stmt* body, location start_name, location end_name)
Arguments¶
Argument |
Description |
|---|---|
|
the symbol table of the program. It owns the local variables of the program and the |
|
the name of the program. |
|
the names of the modules and procedures the body of the program refers to. The backends use it to order code generation. |
|
the statements of the program, in order. |
|
the source span of the name in |
|
the source span of the name in |
Return values¶
None.
Description¶
A translation unit that is linked into an executable must contain exactly one Program. It is always owned by the global symbol table.
A program has no arguments and no return value, so it needs no
function_signature: unlike Function it can never be called
from ASR.
Statements typed directly into the REPL, or written outside of any program
unit, first appear in TranslationUnit.items. The global_stmts ASR pass
wraps them in a Program so that the rest of the compiler only has to deal
with program units.
Examples¶
An ASR text document that uses it:
(TranslationUnit
:symtab (SymbolTable
:id 0
:symbols {
"main" (Program
:symtab (SymbolTable
:id 1
:symbols {
"x" (Variable
:parent_symtab 1
: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 []
:body [
(Assignment
:target (Var
:v (SymbolRef 1 "x")
)
:value (IntegerBinOp
:left (IntegerConstant
:n 2
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:op :Add
:right (IntegerConstant
:n 3
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:type (Integer
:kind 4
)
:value (IntegerConstant
:n 5
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
]
)
}
)
:items []
)