38 ''' This module contains the SymbolInterface class and its subclasses. '''
46 ''' Abstract class of a Symbol Interface '''
50 :returns: a copy of this object.
51 :rtype: :py:class:`psyclone.psyir.symbol.SymbolInterface`
53 return self.__class__()
57 ''' The symbol is declared without attributes. Its data will live
58 during the local context.
66 ''' The symbol contains data that is kept alive through the execution
75 ''' The symbol contains data declared in a module scope without additional
80 return "DefaultModule"
84 ''' We have a symbol with a declaration but PSyclone does not support its
92 ''' A symbol declared in the local scope but acts as a global that
93 can be accessed by any scope referencing the same CommonBlock name.'''
100 ''' We have a symbol but we don't know where it is declared. '''
107 '''Describes the interface to a Symbol that is imported from an
108 external PSyIR container. The symbol can be renamed on import and,
109 if so, its original name in the Container is specified using the
110 optional 'orig_name' argument.
112 :param container_symbol: symbol representing the external container \
113 from which the symbol is imported.
114 :type container_symbol: \
115 :py:class:`psyclone.psyir.symbols.ContainerSymbol`
116 :param Optional[str] orig_name: the name of the symbol in the \
117 external container before it is renamed, or None (the default) if \
120 :raises TypeError: if the orig_name argument is an unexpected type.
123 def __init__(self, container_symbol, orig_name=None):
125 if not isinstance(orig_name, (str, type(
None))):
127 f
"ImportInterface orig_name parameter must be of type "
128 f
"str or None, but found '{type(orig_name).__name__}'.")
136 :returns: the symbol's original name if it is renamed on \
137 import, or None otherwise.
138 :rtype: Optional[str]
144 def container_symbol(self):
146 :return: symbol representing the container containing this Symbol.
147 :rtype: :py:class:`psyclone.psyir.symbols.ContainerSymbol`
151 @container_symbol.setter
152 def container_symbol(self, value):
154 :param value: the ContainerSymbol that imports the symbol with
156 :type value: :py:class:`psyclone.psyir.symbols.ContainerSymbol`
158 :raises TypeError: if the provided value is not a ContainerSymbol.
165 if not isinstance(value, ContainerSymbol):
167 f
"ImportInterface container_symbol parameter must be of type"
168 f
" ContainerSymbol, but found "
169 f
"'{type(value).__name__}'.")
176 orig_name_str = f
", orig_name='{self.orig_name}'"
177 return (f
"Import(container='{self.container_symbol.name}"
178 f
"'{orig_name_str})")
180 def __eq__(self, other):
181 if type(other)
is not type(self):
184 other.container_symbol.name.lower()):
187 other_oname = other.orig_name.lower()
if other.orig_name
else ""
188 return orig_name == other_oname
192 :returns: a copy of this object.
193 :rtype: :py:class:`psyclone.psyir.symbol.SymbolInterface`
200 Captures the interface to a Symbol that is accessed as a routine
203 :param access: specifies how the argument is used in the Schedule
204 :type access: :py:class:`psyclone.psyir.symbols.ArgumentInterface.Access`
209 Enumeration for the different types of access that an Argument
210 Symbol is permitted to have.
225 def __init__(self, access=None):
230 self.access = ArgumentInterface.Access.UNKNOWN
237 :returns: the access-type for this argument.
238 :rtype: :py:class:`psyclone.psyir.symbols.ArgumentInterface.Access`
243 def access(self, value):
245 :param value: the new access type.
246 :type value: :py:class:`psyclon.psyir.symbols.ArgumentInterface.Access`
248 :raises TypeError: if the supplied value is not an \
249 ArgumentInterface.Access
253 f
"SymbolInterface.access must be an 'ArgumentInterface.Access'"
254 f
" but got '{type(value).__name__}'.")
258 return f
"Argument({self.access})"
262 :returns: a copy of this object.
263 :rtype: :py:class:`psyclone.psyir.symbol.SymbolInterface`
269 '''The symbol exists in the file through compiler macros or preprocessor
272 Note that this is different from UnresolvedInterface because the backend
273 will not check if is importing statements that could bring them into
277 return "Preprocessor"
def container_symbol(self)
def container_symbol(self, value)