ExternalSymbol¶
A symbol that lives in another scope, made visible here.
Declaration¶
Syntax¶
ExternalSymbol(symbol_table parent_symtab, identifier name,
symbol external, identifier module_name, identifier* scope_names,
identifier original_name, access access)
Arguments¶
Argument |
Description |
|---|---|
|
the symbol table this symbol is stored in. |
|
the name the symbol is known by here, after any renaming. |
|
the symbol this one stands for. |
|
the name of the module the original symbol is declared in. |
|
the names of the scopes to walk inside the module to reach the symbol, outermost first. Empty when the symbol is declared directly in the module. |
|
the name the symbol has in its own scope, which differs from |
|
|
Return values¶
None.
Description¶
Ordinary symbol lookup walks from a symbol table to its parents. That finds a module variable used inside a procedure of the same module, so no ExternalSymbol is needed there. It does not find a symbol that belongs to another module, because that module is not a parent of the current scope.
ExternalSymbol closes that gap: use m, only: f puts an ExternalSymbol
named f into the using scope, pointing at the real symbol in m. Every
reference in that scope then names the local ExternalSymbol, so every
symbol a program unit refers to is reachable from its own symbol table.
Examples¶
(ExternalSymbol
:parent_symtab 3
:name "reset"
:external (SymbolRef 1 "reset")
:module_name "m"
:scope_names []
:original_name "reset"
:access :Public
)
It comes from this complete ASR text document:
(TranslationUnit
:symtab (SymbolTable
:id 0
:symbols {
"m" (Module
:symtab (SymbolTable
:id 1
:symbols {
"reset" (Function
:symtab (SymbolTable
:id 2
:symbols {
"x" (Variable
:parent_symtab 2
:name "x"
:dependencies []
:intent :In
: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 "reset"
:function_signature (FunctionType
:arg_types [
(Integer
:kind 4
)
]
:return_var_type nil
:abi :Source
:deftype :Implementation
:bindc_name nil
:elemental false
:pure false
:module false
:inline false
:static false
:restrictions []
:is_restriction false
)
:dependencies []
:args [
(Var
:v (SymbolRef 2 "x")
)
]
:body []
:return_var nil
:access :Public
:deterministic false
:side_effect_free false
:module_file nil
)
}
)
:name "m"
:parent_module nil
:dependencies []
:loaded_from_mod false
:intrinsic false
:has_submodules false
)
"main" (Program
:symtab (SymbolTable
:id 3
:symbols {
"reset" (ExternalSymbol
:parent_symtab 3
:name "reset"
:external (SymbolRef 1 "reset")
:module_name "m"
:scope_names []
:original_name "reset"
:access :Public
)
"x" (Variable
:parent_symtab 3
: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 [
(SubroutineCall
:name (SymbolRef 3 "reset")
:original_name nil
:args [
(call_arg
:value (Var
:v (SymbolRef 3 "x")
)
)
]
:dt nil
:strict_bounds_checking false
)
]
)
}
)
:items []
)