Var¶
A reference to a variable.
Declaration¶
Syntax¶
Var(symbol v)
Arguments¶
Argument |
Description |
|---|---|
|
the Variable symbol, or another symbol standing for one, such as an ExternalSymbol. |
Return values¶
The value of the expression.
Description¶
Var holds nothing but the symbol. The type, the intent, the storage and everything else are read from the Variable it points at, so there is exactly one place where a variable’s properties live and no way for a reference to disagree with the declaration.
In ASR text the symbol is written (SymbolRef id "name"), naming the symbol
table and the key.
Examples¶
(Var
:v (SymbolRef 1 "x")
)
It comes from this complete ASR text document:
(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 []
)