GoTo¶
Jumps to a labelled statement in the same procedure.
Declaration¶
Syntax¶
GoTo(int target_id, identifier name)
Arguments¶
Argument |
Description |
|---|---|
|
the |
|
the label as it was written, for diagnostics. |
Return values¶
None.
Description¶
The jump is linked by the integer target_id rather than by a pointer to the
target node. A pointer would have to be fixed up every time ASR is serialised
into a module file and read back; an integer survives that untouched.
target_id is unique within a procedure only, and a go to may not leave the
procedure it appears in.
Examples¶
(GoTo
:target_id 100
:name "100"
)
It comes from this complete ASR text document:
(TranslationUnit
:symtab (SymbolTable
:id 0
:symbols {
"main" (Program
:symtab (SymbolTable
:id 1
:symbols {
"i" (Variable
:parent_symtab 1
:name "i"
: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 []
)
"label" (Variable
:parent_symtab 1
:name "label"
: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 [
(Assign
:label 100
:variable "label"
)
(GoTo
:target_id 100
:name "100"
)
(Assignment
:target (Var
:v (SymbolRef 1 "i")
)
:value (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
(GoToTarget
:id 100
:name "100"
)
(IfArithmetic
:test (Var
:v (SymbolRef 1 "i")
)
:lt_label 100
:eq_label 100
:gt_label 100
)
]
)
}
)
:items []
)