Reference Guide  2.5.0
psyclone.parse.kernel.BuiltInKernelTypeFactory Class Reference
Inheritance diagram for psyclone.parse.kernel.BuiltInKernelTypeFactory:
Collaboration diagram for psyclone.parse.kernel.BuiltInKernelTypeFactory:

Public Member Functions

def create (self, builtin_names, builtin_defs_file, name=None)
 
- Public Member Functions inherited from psyclone.parse.kernel.KernelTypeFactory
def __init__ (self, api="")
 
def create (self, parse_tree, name=None)
 

Detailed Description

Create API-specific information about the builtin metadata. The API
is set when the factory is created. Subclasses KernelTypeFactory
and makes use of its init method.

Definition at line 255 of file kernel.py.

Member Function Documentation

◆ create()

def psyclone.parse.kernel.BuiltInKernelTypeFactory.create (   self,
  builtin_names,
  builtin_defs_file,
  name = None 
)
Create API-specific information about the builtin metadata. This
method finds and parses the metadata then makes use of the
KernelTypeFactory parent class to return the api-specific
information about the builtin.

:param builtin_names: a list of valid builtin names
:type builtin_names: list of str
:param str builtin_defs_file: the file containing builtin \
metadata
:param name: the name of the builtin. Defaults to None if \
one is not provided.
:type name: str or NoneType

:raises ParseError: if the supplied name is not one of the \
builtin names
:raises ParseError: if the supplied name is recognised as a \
builtin but the associated file containing the required \
metadata can not be found.
:raises ParseError: if the metadata for the supplied builtin \
can not be parsed.

Definition at line 262 of file kernel.py.

262  def create(self, builtin_names, builtin_defs_file, name=None):
263  '''Create API-specific information about the builtin metadata. This
264  method finds and parses the metadata then makes use of the
265  KernelTypeFactory parent class to return the api-specific
266  information about the builtin.
267 
268  :param builtin_names: a list of valid builtin names
269  :type builtin_names: list of str
270  :param str builtin_defs_file: the file containing builtin \
271  metadata
272  :param name: the name of the builtin. Defaults to None if \
273  one is not provided.
274  :type name: str or NoneType
275 
276  :raises ParseError: if the supplied name is not one of the \
277  builtin names
278  :raises ParseError: if the supplied name is recognised as a \
279  builtin but the associated file containing the required \
280  metadata can not be found.
281  :raises ParseError: if the metadata for the supplied builtin \
282  can not be parsed.
283 
284  '''
285  if name not in builtin_names:
286  raise ParseError(
287  f"BuiltInKernelTypeFactory:create unrecognised built-in name. "
288  f"Got '{name}' but expected one of {builtin_names}")
289  # The meta-data for these lives in a Fortran module file
290  # passed in to this method.
291  fname = os.path.join(
292  os.path.dirname(os.path.abspath(__file__)),
293  builtin_defs_file)
294  if not os.path.isfile(fname):
295  raise ParseError(
296  f"BuiltInKernelTypeFactory:create Kernel '{name}' is a "
297  f"recognised Built-in but cannot find file '{fname}' "
298  f"containing the meta-data describing the Built-in operations "
299  f"for API '{self._type}'")
300  # Attempt to parse the meta-data
301  try:
302  parsefortran.FortranParser.cache.clear()
303  fparser.logging.disable(fparser.logging.CRITICAL)
304  parse_tree = fpapi.parse(fname)
305  except Exception as err:
306  raise ParseError(
307  f"BuiltInKernelTypeFactory:create: Failed to parse the meta-"
308  f"data for PSyclone built-ins in file '{fname}'.") from err
309 
310  # Now we have the parse tree, call our parent class to create \
311  # the object
312  return KernelTypeFactory.create(self, parse_tree, name)
313 # pylint: enable=too-few-public-methods
314 
315 
Here is the caller graph for this function:

The documentation for this class was generated from the following file: