Reference Guide
2.5.0
|
Public Member Functions | |
def | __init__ (self, node=None, default_visibility=Symbol.Visibility.PUBLIC) |
def | default_visibility (self) |
def | default_visibility (self, vis) |
def | node (self) |
def | is_empty (self) |
def | parent_symbol_table (self, scope_limit=None) |
def | get_symbols (self, scope_limit=None) |
def | get_tags (self, scope_limit=None) |
def | shallow_copy (self) |
def | deep_copy (self) |
def | new_symbol (self, root_name=None, tag=None, shadowing=False, symbol_type=None, allow_renaming=True, **symbol_init_args) |
def | find_or_create (self, name, **new_symbol_args) |
def | find_or_create_tag (self, tag, root_name=None, **new_symbol_args) |
def | next_available_name (self, root_name=None, shadowing=False, other_table=None) |
def | add (self, new_symbol, tag=None) |
def | check_for_clashes (self, other_table, symbols_to_skip=()) |
def | merge (self, other_table, symbols_to_skip=()) |
def | swap_symbol_properties (self, symbol1, symbol2) |
def | specify_argument_list (self, argument_symbols) |
def | lookup (self, name, visibility=None, scope_limit=None) |
def | lookup_with_tag (self, tag, scope_limit=None) |
def | __contains__ (self, key) |
def | symbols_imported_from (self, csymbol) |
def | swap (self, old_symbol, new_symbol) |
def | remove (self, symbol) |
def | argument_list (self) |
def | symbols_dict (self) |
def | tags_dict (self) |
def | get_reverse_tags_dict (self) |
def | symbols (self) |
def | datasymbols (self) |
def | automatic_datasymbols (self) |
def | argument_datasymbols (self) |
def | imported_symbols (self) |
def | unresolved_datasymbols (self) |
def | precision_datasymbols (self) |
def | containersymbols (self) |
def | datatypesymbols (self) |
def | iteration_indices (self) |
def | data_arguments (self) |
def | copy_external_import (self, imported_var, tag=None) |
def | resolve_imports (self, container_symbols=None, symbol_target=None) |
def | rename_symbol (self, symbol, name, dry_run=False) |
def | wildcard_imports (self) |
def | view (self) |
def | __str__ (self) |
def | scope (self) |
def | detach (self) |
def | attach (self, node) |
def | __eq__ (self, other) |
Public Attributes | |
default_visibility | |
Encapsulates the symbol table and provides methods to add new symbols and look up existing symbols. Nested scopes are supported and, by default, the add and lookup methods take any ancestor symbol tables into consideration (ones attached to nodes that are ancestors of the node that this symbol table is attached to). If the default visibility is not specified then it defaults to Symbol.Visbility.PUBLIC. :param node: reference to the Schedule or Container to which this \ symbol table belongs. :type node: :py:class:`psyclone.psyir.nodes.Schedule`, \ :py:class:`psyclone.psyir.nodes.Container` or NoneType :param default_visibility: optional default visibility value for this \ symbol table, if not provided it defaults to PUBLIC visibility. :type default_visibillity: \ :py:class:`psyclone.psyir.symbols.Symbol.Visibility` :raises TypeError: if node argument is not a Schedule or a Container.
Definition at line 58 of file symbol_table.py.
def psyclone.psyir.symbols.symbol_table.SymbolTable.__contains__ | ( | self, | |
key | |||
) |
Check if the given key is part of the Symbol Table. :param str key: key to check for existance. :returns: whether the Symbol Table contains the given key. :rtype: bool
Definition at line 1027 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._normalize(), and psyclone.psyir.symbols.symbol_table.SymbolTable._symbols.
def psyclone.psyir.symbols.symbol_table.SymbolTable.__eq__ | ( | self, | |
other | |||
) |
Checks whether two SymbolTables are equal. # TODO 1698: Improve. Currently it uses a quick implementation # that only checks that the view() lines of each symbol_table # are exactly the same. # The current implementation does not check tags, order # of arguments or visibilities. :param object other: the object to check equality to. :returns: whether other is equal to self. :rtype: bool
Definition at line 1854 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable.view(), and psyclone.psyir.nodes.node.Node.view().
def psyclone.psyir.symbols.symbol_table.SymbolTable.add | ( | self, | |
new_symbol, | |||
tag = None |
|||
) |
Add a new symbol to the symbol table if the symbol name is not already in use. :param new_symbol: the symbol to add to the symbol table. :type new_symbol: :py:class:`psyclone.psyir.symbols.Symbol` :param str tag: a tag identifier for the new symbol, by default no \ tag is given. :raises InternalError: if the new_symbol argument is not a \ symbol. :raises KeyError: if the symbol name is already in use. :raises KeyError: if a tag is supplied and it is already in \ use.
Definition at line 561 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._normalize(), psyclone.psyir.symbols.symbol_table.SymbolTable._symbols, psyclone.psyir.symbols.symbol_table.SymbolTable._tags, and psyclone.psyir.symbols.symbol_table.SymbolTable.get_tags().
def psyclone.psyir.symbols.symbol_table.SymbolTable.argument_datasymbols | ( | self | ) |
:returns: list of symbols representing arguments. :rtype: List[:py:class:`psyclone.psyir.symbols.DataSymbol`]
Definition at line 1330 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable.datasymbols().
def psyclone.psyir.symbols.symbol_table.SymbolTable.argument_list | ( | self | ) |
Checks that the contents of the SymbolTable are self-consistent and then returns the list of kernel arguments. :returns: ordered list of arguments. :rtype: list of :py:class:`psyclone.psyir.symbols.DataSymbol` :raises InternalError: if the entries of the SymbolTable are not \ self-consistent.
Definition at line 1206 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._argument_list, psyclone.psyir.symbols.symbol_table.SymbolTable._validate_arg_list(), psyclone.psyir.symbols.symbol_table.SymbolTable._validate_non_args(), and psyclone.psyir.symbols.symbol_table.SymbolTable.datasymbols().
def psyclone.psyir.symbols.symbol_table.SymbolTable.attach | ( | self, | |
node | |||
) |
Attach this symbol table to the provided scope. :param node: the scoped node this symbol table will attach to. :type node: py:class:`psyclone.psyir.nodes.ScopingNode`
Definition at line 1825 of file symbol_table.py.
References psyclone.core.single_variable_access_info.AccessInfo._node, and psyclone.psyir.symbols.symbol_table.SymbolTable._node.
def psyclone.psyir.symbols.symbol_table.SymbolTable.automatic_datasymbols | ( | self | ) |
:returns: list of symbols representing automatic variables. :rtype: List[:py:class:`psyclone.psyir.symbols.DataSymbol`]
Definition at line 1322 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable.datasymbols().
def psyclone.psyir.symbols.symbol_table.SymbolTable.check_for_clashes | ( | self, | |
other_table, | |||
symbols_to_skip = () |
|||
) |
Checks the symbols in the supplied table against those in this table. If there is a name clash that cannot be resolved by renaming then a SymbolError is raised. Any symbols appearing in `symbols_to_skip` are excluded from the checks. :param other_table: the table for which to check for clashes. :type other_table: :py:class:`psyclone.psyir.symbols.SymbolTable` :param symbols_to_skip: an optional list of symbols to exclude from the check. :type symbols_to_skip: Iterable[ :py:class:`psyclone.psyir.symbols.Symbol`] :raises TypeError: if symbols_to_skip is supplied but is not an instance of Iterable. :raises SymbolError: if there would be an unresolvable name clash when importing symbols from `other_table` into this table.
Definition at line 597 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._handle_symbol_clash(), psyclone.f2pygen.IfThenGen.add(), psyclone.f2pygen.ProgUnitGen.add(), psyclone.f2pygen.DoGen.add(), psyclone.psyir.symbols.datatypes.StructureType.add(), psyclone.f2pygen.BaseGen.add(), psyclone.psyir.symbols.symbol_table.SymbolTable.add(), psyclone.psyir.symbols.datatypes.StructureType.lookup(), psyclone.psyir.symbols.symbol_table.SymbolTable.lookup(), psyclone.psyir.symbols.symbol_table.SymbolTable.next_available_name(), psyclone.psyir.symbols.symbol_table.SymbolTable.rename_symbol(), and psyclone.psyir.symbols.symbol_table.SymbolTable.wildcard_imports().
def psyclone.psyir.symbols.symbol_table.SymbolTable.containersymbols | ( | self | ) |
:returns: a list of the ContainerSymbols present in the Symbol Table. :rtype: List[:py:class:`psyclone.psyir.symbols.ContainerSymbol`]
Definition at line 1374 of file symbol_table.py.
References psyclone.expression.BinaryOperator.symbols, and psyclone.psyir.symbols.symbol_table.SymbolTable.symbols().
def psyclone.psyir.symbols.symbol_table.SymbolTable.copy_external_import | ( | self, | |
imported_var, | |||
tag = None |
|||
) |
Copy the given imported variable (and its referenced ContainerSymbol if needed) into the SymbolTable. :param imported_var: the variable to be copied in. :type imported_var: :py:class:`psyclone.psyir.symbols.DataSymbol` :param str tag: a tag identifier for the new copy, by default no tag \ is given. :raises TypeError: if the given variable is not an imported variable. :raises KeyError: if the given variable name already exists in the \ symbol table.
Definition at line 1414 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._has_same_name(), psyclone.psyir.symbols.symbol_table.SymbolTable._tags, psyclone.f2pygen.IfThenGen.add(), psyclone.f2pygen.ProgUnitGen.add(), psyclone.f2pygen.DoGen.add(), psyclone.psyir.symbols.datatypes.StructureType.add(), psyclone.f2pygen.BaseGen.add(), psyclone.psyir.symbols.symbol_table.SymbolTable.add(), psyclone.psyir.symbols.datatypes.StructureType.lookup(), psyclone.psyir.symbols.symbol_table.SymbolTable.lookup(), and psyclone.psyir.symbols.symbol_table.SymbolTable.lookup_with_tag().
def psyclone.psyir.symbols.symbol_table.SymbolTable.data_arguments | ( | self | ) |
:returns: list of symbols representing kernel data arguments. :rtype: List[:py:class:`psyclone.psyir.symbols.DataSymbol`] :raises NotImplementedError: this method is abstract.
Definition at line 1403 of file symbol_table.py.
def psyclone.psyir.symbols.symbol_table.SymbolTable.datasymbols | ( | self | ) |
:returns: list of symbols representing data variables. :rtype: List[:py:class:`psyclone.psyir.symbols.DataSymbol`]
Definition at line 1313 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._symbols.
def psyclone.psyir.symbols.symbol_table.SymbolTable.datatypesymbols | ( | self | ) |
:returns: the DataTypeSymbols present in the Symbol Table. :rtype: List[:py:class:`psyclone.psyir.symbols.DataTypeSymbol`]
Definition at line 1383 of file symbol_table.py.
References psyclone.expression.BinaryOperator.symbols, and psyclone.psyir.symbols.symbol_table.SymbolTable.symbols().
def psyclone.psyir.symbols.symbol_table.SymbolTable.deep_copy | ( | self | ) |
Create a copy of the symbol table with new instances of the top-level data structures and also new instances of the symbols contained in these data structures. Modifying a symbol attribute will not affect the equivalent named symbol in the original symbol table. The only attribute not copied is the _node reference to the scope, since that scope can only have one symbol table associated to it. :returns: a deep copy of this symbol table. :rtype: :py:class:`psyclone.psyir.symbols.SymbolTable`
Definition at line 255 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._normalize(), psyclone.psyir.symbols.symbol_table.SymbolTable._tags, psyclone.psyir.symbols.symbol_table.SymbolTable.argument_list(), psyclone.psyir.symbols.symbol_table.SymbolTable.default_visibility, psyclone.expression.BinaryOperator.symbols, and psyclone.psyir.symbols.symbol_table.SymbolTable.symbols().
def psyclone.psyir.symbols.symbol_table.SymbolTable.default_visibility | ( | self | ) |
:returns: the default visibility of symbols in this table. :rtype: :py:class:`psyclone.psyir.symbols.Symbol.Visibility`
Definition at line 101 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._default_visibility.
def psyclone.psyir.symbols.symbol_table.SymbolTable.default_visibility | ( | self, | |
vis | |||
) |
Sets the default visibility of symbols in this table. :param vis: the default visibility. :type vis: :py:class:`psyclone.psyir.symbols.Symbol.Visibility` :raises TypeError: if the supplied value is of the wrong type.
Definition at line 109 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._default_visibility.
def psyclone.psyir.symbols.symbol_table.SymbolTable.detach | ( | self | ) |
Detach this symbol table from the associated scope and return self. :returns: this symbol table. :rtype: py:class:`psyclone.psyir.symbols.SymbolTable`
Definition at line 1812 of file symbol_table.py.
References psyclone.core.single_variable_access_info.AccessInfo._node, and psyclone.psyir.symbols.symbol_table.SymbolTable._node.
def psyclone.psyir.symbols.symbol_table.SymbolTable.find_or_create | ( | self, | |
name, | |||
** | new_symbol_args | ||
) |
Lookup a symbol by its name, if it doesn't exist create a new symbol with the given properties. :param str name: name of the symbol to lookup or create. :param new_symbol_args: arguments to create a new symbol. :type new_symbol_args: unwrapped Dict[str, object] :raises SymbolError: if the symbol already exists but the type_symbol \ argument does not match the type of the symbol \ found.
Definition at line 412 of file symbol_table.py.
References psyclone.psyir.symbols.datatypes.StructureType.lookup(), psyclone.psyir.symbols.symbol_table.SymbolTable.lookup(), and psyclone.psyir.symbols.symbol_table.SymbolTable.new_symbol().
def psyclone.psyir.symbols.symbol_table.SymbolTable.find_or_create_tag | ( | self, | |
tag, | |||
root_name = None , |
|||
** | new_symbol_args | ||
) |
Lookup a tag, if it doesn't exist create a new symbol with the given tag. By default it creates a generic Symbol with the tag as the root of the symbol name. Optionally, a different root_name or any of the arguments available in the new_symbol() method can be given to refine the name and the type of the created Symbol. :param str tag: tag identifier. :param str root_name: optional name of the new symbol if it needs \ to be created. Otherwise it is ignored. :param bool shadowing: optional logical flag indicating whether the name can be overlapping with a symbol in any of the ancestors symbol tables. Defaults to False. :param symbol_type: class type of the new symbol. :type symbol_type: type object of class (or subclasses) of :py:class:`psyclone.psyir.symbols.Symbol` :param bool allow_renaming: whether to allow the newly created :param bool allow_renaming: whether to allow the newly created symbol to be renamed from root_name. Defaults to True. :param new_symbol_args: arguments to create a new symbol. :type new_symbol_args: unwrapped dict[str, Any] :returns: symbol associated with the given tag. :rtype: :py:class:`psyclone.psyir.symbols.Symbol` :raises SymbolError: if the symbol already exists but the type_symbol \ argument does not match the type of the symbol \ found.
Definition at line 441 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable.lookup_with_tag(), and psyclone.psyir.symbols.symbol_table.SymbolTable.new_symbol().
def psyclone.psyir.symbols.symbol_table.SymbolTable.get_reverse_tags_dict | ( | self | ) |
Constructs and returns a reverse of the map returned by tags_dict method. :returns: ordered dictionary of tags indexed by symbol. :rtype: OrderedDict[:py:class:`psyclone.psyir.symbols.Symbol`, str]
Definition at line 1287 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._tags.
def psyclone.psyir.symbols.symbol_table.SymbolTable.get_symbols | ( | self, | |
scope_limit = None |
|||
) |
Return symbols from this symbol table and all symbol tables associated with ancestors of the node that this symbol table is attached to. If there are name duplicates we only return the one from the closest ancestor including self. It accepts an optional scope_limit argument. :param scope_limit: optional Node which limits the symbol \ search space to the symbol tables of the nodes within the \ given scope. If it is None (the default), the whole \ scope (all symbol tables in ancestor nodes) is searched \ otherwise ancestors of the scope_limit node are not \ searched. :type scope_limit: Optional[:py:class:`psyclone.psyir.nodes.Node`] :returns: ordered dictionary of symbols indexed by symbol name. :rtype: OrderedDict[str] = :py:class:`psyclone.psyir.symbols.Symbol`
Definition at line 180 of file symbol_table.py.
def psyclone.psyir.symbols.symbol_table.SymbolTable.get_tags | ( | self, | |
scope_limit = None |
|||
) |
Return tags from this symbol table and all symbol tables associated with ancestors of the node that this symbol table is attached to. If there are tag duplicates we only return the one from the closest ancestor including self. It accepts an optional scope_limit argument. :param scope_limit: optional Node which limits the symbol \ search space to the symbol tables of the nodes within the \ given scope. If it is None (the default), the whole \ scope (all symbol tables in ancestor nodes) is searched \ otherwise ancestors of the scope_limit node are not \ searched. :type scope_limit: :py:class:`psyclone.psyir.nodes.Node` or \ `NoneType` :returns: ordered dictionary of symbols indexed by tag. :rtype: OrderedDict[str] = :py:class:`psyclone.psyir.symbols.Symbol`
Definition at line 208 of file symbol_table.py.
def psyclone.psyir.symbols.symbol_table.SymbolTable.imported_symbols | ( | self | ) |
:returns: list of symbols that have an imported interface (are \ associated with data that exists outside the current scope). :rtype: List[:py:class:`psyclone.psyir.symbols.Symbol`]
Definition at line 1338 of file symbol_table.py.
References psyclone.expression.BinaryOperator.symbols, and psyclone.psyir.symbols.symbol_table.SymbolTable.symbols().
def psyclone.psyir.symbols.symbol_table.SymbolTable.is_empty | ( | self | ) |
:returns: True if the symbol table is empty, and False otherwise. :rtype: bool
Definition at line 135 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._symbols.
def psyclone.psyir.symbols.symbol_table.SymbolTable.iteration_indices | ( | self | ) |
:returns: list of symbols representing kernel iteration indices. :rtype: List[:py:class:`psyclone.psyir.symbols.DataSymbol`] :raises NotImplementedError: this method is abstract.
Definition at line 1391 of file symbol_table.py.
def psyclone.psyir.symbols.symbol_table.SymbolTable.lookup | ( | self, | |
name, | |||
visibility = None , |
|||
scope_limit = None |
|||
) |
Look up a symbol in the symbol table. The lookup can be limited by visibility (e.g. just show public methods) or by scope_limit (e.g. just show symbols up to a certain scope). :param str name: name of the symbol. :param visibilty: the visibility or list of visibilities that the \ symbol must have. :type visibility: [list of] :py:class:`psyclone.symbols.Visibility` :param scope_limit: optional Node which limits the symbol \ search space to the symbol tables of the nodes within the \ given scope. If it is None (the default), the whole \ scope (all symbol tables in ancestor nodes) is searched \ otherwise ancestors of the scope_limit node are not \ searched. :type scope_limit: :py:class:`psyclone.psyir.nodes.Node` or \ `NoneType` :returns: the symbol with the given name and, if specified, visibility. :rtype: :py:class:`psyclone.psyir.symbols.Symbol` :raises TypeError: if the name argument is not a string. :raises SymbolError: if the name exists in the Symbol Table but does \ not have the specified visibility. :raises TypeError: if the visibility argument has the wrong type. :raises KeyError: if the given name is not in the Symbol Table.
Definition at line 935 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._normalize(), and psyclone.psyir.symbols.symbol_table.SymbolTable.get_symbols().
def psyclone.psyir.symbols.symbol_table.SymbolTable.lookup_with_tag | ( | self, | |
tag, | |||
scope_limit = None |
|||
) |
Look up a symbol by its tag. The lookup can be limited by scope_limit (e.g. just show symbols up to a certain scope). :param str tag: tag identifier. :param scope_limit: optional Node which limits the symbol \ search space to the symbol tables of the nodes within the \ given scope. If it is None (the default), the whole \ scope (all symbol tables in ancestor nodes) is searched \ otherwise ancestors of the scope_limit node are not \ searched. :returns: symbol with the given tag. :rtype: :py:class:`psyclone.psyir.symbols.Symbol` :raises TypeError: if the tag argument is not a string. :raises KeyError: if the given tag is not in the Symbol Table.
Definition at line 997 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable.get_tags().
def psyclone.psyir.symbols.symbol_table.SymbolTable.merge | ( | self, | |
other_table, | |||
symbols_to_skip = () |
|||
) |
Merges all of the symbols found in `other_table` into this table. Symbol objects in *either* table may be renamed in the event of clashes. Any Symbols appearing in `symbols_to_skip` are excluded. :param other_table: the symbol table from which to add symbols. :type other_table: :py:class:`psyclone.psyir.symbols.SymbolTable` :param symbols_to_skip: an optional list of Symbols to exclude from the merge. :type symbols_to_skip: Iterable[ :py:class:`psyclone.psyir.symbols.Symbol`] :raises TypeError: if `other_table` is not a SymbolTable. :raises TypeError: if `symbols_to_skip` is not an Iterable. :raises SymbolError: if name clashes prevent the merge.
Definition at line 834 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._add_container_symbols_from_table(), psyclone.psyir.symbols.symbol_table.SymbolTable._add_symbols_from_table(), and psyclone.psyir.symbols.symbol_table.SymbolTable.check_for_clashes().
def psyclone.psyir.symbols.symbol_table.SymbolTable.new_symbol | ( | self, | |
root_name = None , |
|||
tag = None , |
|||
shadowing = False , |
|||
symbol_type = None , |
|||
allow_renaming = True , |
|||
** | symbol_init_args | ||
) |
Create a new symbol. Optional root_name and shadowing arguments can be given to choose the name following the rules of next_available_name(). An optional tag can also be given. By default it creates a generic symbol but a symbol_type argument and any additional initialization keyword arguments of this symbol_type can be provided to refine the created Symbol. :param root_name: optional name to use when creating a new symbol name. This will be appended with an integer if the name clashes with an existing symbol name. :type root_name: Optional[str] :param str tag: optional tag identifier for the new symbol. :param bool shadowing: optional logical flag indicating whether the name can be overlapping with a symbol in any of the ancestors symbol tables. Defaults to False. :param symbol_type: class type of the new symbol. :type symbol_type: type object of class (or subclasses) of :py:class:`psyclone.psyir.symbols.Symbol` :param bool allow_renaming: whether to allow the newly created symbol to be renamed from root_name. Defaults to True. :param symbol_init_args: arguments to create a new symbol. :type symbol_init_args: unwrapped dict[str, Any] :raises TypeError: if the type_symbol argument is not the type of a Symbol object class or one of its subclasses. :raises SymbolError: if the the symbol needs to be created but would need to be renamed to be created and allow_renaming is False.
Definition at line 342 of file symbol_table.py.
References psyclone.f2pygen.IfThenGen.add(), psyclone.f2pygen.ProgUnitGen.add(), psyclone.f2pygen.DoGen.add(), psyclone.psyir.symbols.datatypes.StructureType.add(), psyclone.f2pygen.BaseGen.add(), psyclone.psyir.symbols.symbol_table.SymbolTable.add(), psyclone.psyir.symbols.symbol_table.SymbolTable.default_visibility, and psyclone.psyir.symbols.symbol_table.SymbolTable.next_available_name().
def psyclone.psyir.symbols.symbol_table.SymbolTable.next_available_name | ( | self, | |
root_name = None , |
|||
shadowing = False , |
|||
other_table = None |
|||
) |
Return a name that is not in the symbol table and therefore can be used to declare a new symbol. If the `root_name` argument is not supplied or if it is an empty string then the name is generated internally, otherwise the `root_name` is used. If required, an additional integer is appended to avoid clashes. If the shadowing argument is True (is False by default), the names in parent symbol tables will not be considered. If `other_table` is supplied, the new name is constructed so as not to clash with any entries in that table. :param str root_name: optional name to use when creating a new \ symbol name. This will be appended with an integer if the name \ clashes with an existing symbol name. :param bool shadowing: optional logical flag indicating whether the \ name can be overlapping with a symbol in any of the ancestors \ symbol tables. Defaults to False. :param other_table: an optional, second symbol table to take into \ account when constructing a new name. :type other_table: :py:class`psyclone.psyir.symbols.SymbolTable` :returns: the new unique symbol name. :rtype: str :raises TypeError: if any of the arguments are of the wrong type.
Definition at line 491 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._normalize(), psyclone.psyir.symbols.symbol_table.SymbolTable._symbols, and psyclone.psyir.symbols.symbol_table.SymbolTable.get_symbols().
def psyclone.psyir.symbols.symbol_table.SymbolTable.node | ( | self | ) |
:returns: the Schedule or Container to which this symbol table belongs. :rtype: :py:class:`psyclone.psyir.nodes.Schedule`, \ :py:class:`psyclone.psyir.nodes.Container` or NoneType
Definition at line 126 of file symbol_table.py.
References psyclone.core.single_variable_access_info.AccessInfo._node, and psyclone.psyir.symbols.symbol_table.SymbolTable._node.
def psyclone.psyir.symbols.symbol_table.SymbolTable.parent_symbol_table | ( | self, | |
scope_limit = None |
|||
) |
If this symbol table is enclosed in another scope, return the symbol table of the next outer scope. Otherwise return None. :param scope_limit: optional Node which limits the symbol \ search space to the symbol tables of the nodes within the \ given scope. If it is None (the default), the whole \ scope (all symbol tables in ancestor nodes) is searched \ otherwise ancestors of the scope_limit node are not \ searched. :type scope_limit: :py:class:`psyclone.psyir.nodes.Node` or \ `NoneType` :returns: the 'parent' SymbolTable of the current SymbolTable (i.e. the one that encloses this one in the PSyIR hierarchy). :rtype: :py:class:`psyclone.psyir.symbols.SymbolTable` or NoneType
Definition at line 143 of file symbol_table.py.
References psyclone.core.single_variable_access_info.AccessInfo.node(), and psyclone.psyir.symbols.symbol_table.SymbolTable.node().
def psyclone.psyir.symbols.symbol_table.SymbolTable.precision_datasymbols | ( | self | ) |
:returns: list of all symbols used to define the precision of \ other symbols within the table. :rtype: List[:py:class:`psyclone.psyir.symbols.DataSymbol`]
Definition at line 1356 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable.datasymbols().
def psyclone.psyir.symbols.symbol_table.SymbolTable.remove | ( | self, | |
symbol | |||
) |
Remove the supplied symbol from the Symbol Table. This has a high potential to leave broken links, so this method checks for some references to the removed symbol depending on the symbol type. Currently, generic Symbols, ContainerSymbols and RoutineSymbols are supported. Support for removing other types of Symbol will be added as required. TODO #898. This method should check for any references/uses of the target symbol. :param symbol: the symbol to remove. :type symbol: :py:class:`psyclone.psyir.symbols.Symbol` :raises TypeError: if the supplied parameter is not of type Symbol. :raises NotImplementedError: the removal of this symbol type is not supported yet. :raises KeyError: if the supplied symbol is not in the symbol table. :raises ValueError: if the supplied container symbol is referenced by one or more DataSymbols. :raises InternalError: if the supplied symbol is not the same as the entry with that name in this SymbolTable.
Definition at line 1131 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._normalize(), psyclone.psyir.symbols.symbol_table.SymbolTable._symbols, psyclone.psyir.symbols.symbol_table.SymbolTable._tags, psyclone.psyir.symbols.symbol_table.SymbolTable._validate_remove_routinesymbol(), and psyclone.psyir.symbols.symbol_table.SymbolTable.symbols_imported_from().
def psyclone.psyir.symbols.symbol_table.SymbolTable.rename_symbol | ( | self, | |
symbol, | |||
name, | |||
dry_run = False |
|||
) |
Rename the given symbol which should belong to this symbol table with the new name provided. :param symbol: the symbol to be renamed. :type symbol: :py:class:`psyclone.psyir.symbols.Symbol` :param str name: the new name. :param bool dry_run: if True then only the validation checks are performed. :raises TypeError: if the symbol is not a Symbol. :raises TypeError: if the name is not a str. :raises ValueError: if the given symbol does not belong to this symbol table. :raises KeyError: if the given variable name already exists in the symbol table. :raises SymbolError: if the specified Symbol is a ContainerSymbol, is imported/unresolved or is a formal routine argument. :raises SymbolError: if the specified Symbol is accessed within a CodeBlock in the scope of this table. :raises SymbolError: if the symbol has a common block interface.
Definition at line 1666 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._normalize(), psyclone.psyir.symbols.symbol_table.SymbolTable._symbols, psyclone.f2pygen.IfThenGen.add(), psyclone.f2pygen.ProgUnitGen.add(), psyclone.f2pygen.DoGen.add(), psyclone.psyir.symbols.datatypes.StructureType.add(), psyclone.f2pygen.BaseGen.add(), psyclone.psyir.symbols.symbol_table.SymbolTable.add(), psyclone.core.single_variable_access_info.AccessInfo.node(), psyclone.psyir.symbols.symbol_table.SymbolTable.node(), psyclone.expression.BinaryOperator.symbols, and psyclone.psyir.symbols.symbol_table.SymbolTable.symbols().
def psyclone.psyir.symbols.symbol_table.SymbolTable.resolve_imports | ( | self, | |
container_symbols = None , |
|||
symbol_target = None |
|||
) |
Try to resolve deferred and unknown information from imported symbols in this symbol table by searching for their definitions in referred external container. A single symbol to resolve can be specified for a more targeted import. :param container_symbols: list of container symbols to search in order to resolve imported symbols. Defaults to all container symbols in the symbol table. :type container_symbols: list[ :py:class:`psyclone.psyir.symbols.ContainerSymbol`] :param symbol_target: If a symbol is given, this method will just resolve information for the given symbol. Otherwise it will resolve all possible symbols information. Defaults to None. :type symbol_target: Optional[ :py:class:`psyclone.psyir.symbols.Symbol`] :raises SymbolError: if a symbol name clash is found between multiple \ imports or an import and a local symbol. :raises TypeError: if the provided container_symbols is not a list of \ ContainerSymbols. :raises TypeError: if the provided symbol_target is not a Symbol. :raises KeyError: if a symbol_target has been specified but this has \ not been found in any of the searched containers.
Definition at line 1482 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._has_same_name(), psyclone.f2pygen.IfThenGen.add(), psyclone.f2pygen.ProgUnitGen.add(), psyclone.f2pygen.DoGen.add(), psyclone.psyir.symbols.datatypes.StructureType.add(), psyclone.f2pygen.BaseGen.add(), psyclone.psyir.symbols.symbol_table.SymbolTable.add(), psyclone.psyir.symbols.symbol_table.SymbolTable.containersymbols(), psyclone.psyir.symbols.symbol_table.SymbolTable.default_visibility, psyclone.psyir.symbols.datatypes.StructureType.lookup(), psyclone.psyir.symbols.symbol_table.SymbolTable.lookup(), psyclone.core.single_variable_access_info.AccessInfo.node(), and psyclone.psyir.symbols.symbol_table.SymbolTable.node().
def psyclone.psyir.symbols.symbol_table.SymbolTable.scope | ( | self | ) |
:returns: the scope associated to this symbol table. :rtype: :py:class:`psyclone.psyir.nodes.ScopingNode`
Definition at line 1804 of file symbol_table.py.
References psyclone.core.single_variable_access_info.AccessInfo._node, and psyclone.psyir.symbols.symbol_table.SymbolTable._node.
def psyclone.psyir.symbols.symbol_table.SymbolTable.shallow_copy | ( | self | ) |
Create a copy of the symbol table with new instances of the top-level data structures but keeping the same existing symbol objects. Symbols added to the new symbol table will not be added in the original but the existing objects are still the same. :returns: a shallow copy of this symbol table. :rtype: :py:class:`psyclone.psyir.symbols.SymbolTable`
Definition at line 236 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._argument_list, psyclone.psyir.symbols.symbol_table.SymbolTable._symbols, psyclone.psyir.symbols.symbol_table.SymbolTable._tags, psyclone.psyir.symbols.symbol_table.SymbolTable.default_visibility, psyclone.core.single_variable_access_info.AccessInfo.node(), and psyclone.psyir.symbols.symbol_table.SymbolTable.node().
def psyclone.psyir.symbols.symbol_table.SymbolTable.specify_argument_list | ( | self, | |
argument_symbols | |||
) |
Sets-up the internal list storing the order of the arguments to this kernel. :param list argument_symbols: ordered list of the DataSymbols \ representing the kernel arguments. :raises ValueError: if the new argument_list is not consistent with \ the existing entries in the SymbolTable.
Definition at line 920 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._argument_list, and psyclone.psyir.symbols.symbol_table.SymbolTable._validate_arg_list().
def psyclone.psyir.symbols.symbol_table.SymbolTable.swap | ( | self, | |
old_symbol, | |||
new_symbol | |||
) |
Remove the `old_symbol` from the table and replace it with the `new_symbol`. :param old_symbol: the symbol to remove from the table. :type old_symbol: :py:class:`psyclone.psyir.symbols.Symbol` :param new_symbol: the symbol to add to the table. :type new_symbol: :py:class:`psyclone.psyir.symbols.Symbol` :raises TypeError: if either old/new_symbol are not Symbols. :raises SymbolError: if `old_symbol` and `new_symbol` don't have the same name (after normalising).
Definition at line 1067 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._has_same_name(), psyclone.psyir.symbols.symbol_table.SymbolTable._symbols, psyclone.f2pygen.IfThenGen.add(), psyclone.f2pygen.ProgUnitGen.add(), psyclone.f2pygen.DoGen.add(), psyclone.psyir.symbols.datatypes.StructureType.add(), psyclone.f2pygen.BaseGen.add(), psyclone.psyir.symbols.symbol_table.SymbolTable.add(), psyclone.core.single_variable_access_info.AccessInfo.node(), psyclone.psyir.symbols.symbol_table.SymbolTable.node(), psyclone.psyir.nodes.node.ChildrenList.remove(), and psyclone.psyir.symbols.symbol_table.SymbolTable.remove().
def psyclone.psyir.symbols.symbol_table.SymbolTable.swap_symbol_properties | ( | self, | |
symbol1, | |||
symbol2 | |||
) |
Swaps the properties of symbol1 and symbol2 apart from the symbol name. Argument list positions are also updated appropriately. :param symbol1: the first symbol. :type symbol1: :py:class:`psyclone.psyir.symbols.Symbol` :param symbol2: the second symbol. :type symbol2: :py:class:`psyclone.psyir.symbols.Symbol` :raises KeyError: if either of the supplied symbols are not in \ the symbol table. :raises TypeError: if the supplied arguments are not symbols, \ or the names of the symbols are the same in the SymbolTable \ instance.
Definition at line 877 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._argument_list, psyclone.psyir.symbols.symbol_table.SymbolTable._has_same_name(), and psyclone.psyir.symbols.symbol_table.SymbolTable._symbols.
def psyclone.psyir.symbols.symbol_table.SymbolTable.symbols | ( | self | ) |
:returns: list of symbols. :rtype: List[:py:class:`psyclone.psyir.symbols.Symbol`]
Definition at line 1305 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._symbols.
def psyclone.psyir.symbols.symbol_table.SymbolTable.symbols_dict | ( | self | ) |
:returns: ordered dictionary of symbols indexed by symbol name. :rtype: OrderedDict[str] = :py:class:`psyclone.psyir.symbols.Symbol`
Definition at line 1270 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._symbols.
def psyclone.psyir.symbols.symbol_table.SymbolTable.symbols_imported_from | ( | self, | |
csymbol | |||
) |
Examines the contents of this symbol table to see which DataSymbols (if any) are imported from the supplied ContainerSymbol (which must be present in the SymbolTable). :param csymbol: the ContainerSymbol to search for imports from. :type csymbol: :py:class:`psyclone.psyir.symbols.ContainerSymbol` :returns: list of DataSymbols that are imported from the supplied \ ContainerSymbol. If none are found then the list is empty. :rtype: list of :py:class:`psyclone.psyir.symbols.DataSymbol` :raises TypeError: if the supplied object is not a ContainerSymbol. :raises KeyError: if the supplied object is not in this SymbolTable.
Definition at line 1037 of file symbol_table.py.
References psyclone.psyir.nodes.psy_data_node.PSyDataNode.imported_symbols, psyclone.psyir.symbols.symbol_table.SymbolTable.imported_symbols(), psyclone.psyir.symbols.datatypes.StructureType.lookup(), and psyclone.psyir.symbols.symbol_table.SymbolTable.lookup().
def psyclone.psyir.symbols.symbol_table.SymbolTable.tags_dict | ( | self | ) |
:returns: ordered dictionary of symbols indexed by tag. :rtype: OrderedDict[str] = :py:class:`psyclone.psyir.symbols.Symbol`
Definition at line 1279 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._tags.
def psyclone.psyir.symbols.symbol_table.SymbolTable.unresolved_datasymbols | ( | self | ) |
:returns: list of symbols representing unresolved variables. :rtype: List[:py:class:`psyclone.psyir.symbols.DataSymbol`]
Definition at line 1348 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable.datasymbols().
def psyclone.psyir.symbols.symbol_table.SymbolTable.view | ( | self | ) |
:returns: a representation of this Symbol Table. :rtype: str
Definition at line 1784 of file symbol_table.py.
References psyclone.psyir.symbols.symbol_table.SymbolTable._symbols, psyclone.core.single_variable_access_info.AccessInfo.node(), and psyclone.psyir.symbols.symbol_table.SymbolTable.node().
def psyclone.psyir.symbols.symbol_table.SymbolTable.wildcard_imports | ( | self | ) |
Searches this symbol table and then up through any parent symbol tables for a ContainerSymbol that has a wildcard import. :returns: the name(s) of containers which have wildcard imports into the current scope. :rtype: set[str]
Definition at line 1765 of file symbol_table.py.