Skip to content

Commit

Permalink
#2823 Unresolved TypeConstructors become Calls
Browse files Browse the repository at this point in the history
  • Loading branch information
sergisiso committed Dec 9, 2024
1 parent 1e6b095 commit f921d8b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,16 @@ def validate(self, node, options=None):
# pylint: disable=protected-access
for fp2_node in arg._fp2_nodes:
self._validate_fp2_node(fp2_node)
elif isinstance(arg, Call):
pass
else:
if isinstance(arg, Call):
info = (
f"The invoke call argument '{arg.routine.name}' has "
f"been used as a routine name. This is not allowed.")
else:
info = (
f"The arguments to this invoke call are expected to "
f"be kernel calls which are represented in generic "
f"PSyIR as CodeBlocks or ArrayReferences, but "
f"'{arg.debug_string()}' is of type "
f"'{type(arg).__name__}'.")
raise TransformationError(
f"Error in {self.name} transformation. {info}")
f"Error in {self.name} transformation. "
f"The arguments to this invoke call are expected to "
f"be kernel calls which are represented in generic "
f"PSyIR as CodeBlocks or ArrayReferences, but "
f"'{arg.debug_string()}' is of type "
f"'{type(arg).__name__}'.")

def apply(self, call, index, options=None):
''' Apply the transformation to the supplied node.
Expand Down
18 changes: 13 additions & 5 deletions src/psyclone/parse/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
Add_Operand, Parenthesis, Structure_Constructor, Component_Spec_List, \
Proc_Component_Ref, Kind_Selector, Type_Declaration_Stmt, \
Declaration_Type_Spec, Entity_Decl, Intrinsic_Type_Spec, \
Data_Component_Def_Stmt, Component_Decl
Data_Component_Def_Stmt, Component_Decl, Function_Reference, \
Actual_Arg_Spec_List
# pylint: enable=no-name-in-module

from psyclone.configuration import Config, LFRIC_API_NAMES
Expand Down Expand Up @@ -342,11 +343,11 @@ def create_invoke_call(self, statement):
invoke_label = self.check_invoke_label(argument)

elif isinstance(
argument, (Data_Ref, Part_Ref, Structure_Constructor)):
argument, (Data_Ref, Part_Ref, Structure_Constructor,
Function_Reference)):
# This should be a kernel call.
kernel_call = self.create_kernel_call(argument)
kernel_calls.append(kernel_call)

else:
# Unknown and/or unsupported argument type
raise ParseError(
Expand Down Expand Up @@ -644,7 +645,13 @@ def get_kernel(parse_tree, alg_filename, arg_type_defns):
'''
# pylint: disable=too-many-branches
if not isinstance(parse_tree, (Part_Ref, Structure_Constructor)):
# fparser can not distinguish between:
# - Array accessor (Part_Ref with Section_Subscript_List)
# - Type constructor (Structure_Constructor with Component_Spec_List)
# - Function Call (Function_Reference with Actual_Arg_Spec_List)
# so we accept the three combinations below
if not isinstance(parse_tree, (Part_Ref, Structure_Constructor,
Function_Reference)):
raise InternalError(
f"algorithm.py:get_kernel: Expected a parse tree (type Part_Ref "
f"or Structure_Constructor) but found instance of "
Expand All @@ -661,7 +668,8 @@ def get_kernel(parse_tree, alg_filename, arg_type_defns):
# Extract argument list. This can be removed when fparser#211 is fixed.
argument_list = []
if isinstance(parse_tree.items[1],
(Section_Subscript_List, Component_Spec_List)):
(Section_Subscript_List, Component_Spec_List,
Actual_Arg_Spec_List)):
argument_list = parse_tree.items[1].items
else:
# Expecting a single entry rather than a list
Expand Down
1 change: 1 addition & 0 deletions src/psyclone/psyir/symbols/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def specialise(self, subclass, **kwargs):
:raises TypeError: if subclass is not a sub-class of Symbol.
'''
import pdb; pdb.set_trace()
try:
is_subclass = issubclass(subclass, self.__class__)
except TypeError as info:
Expand Down

0 comments on commit f921d8b

Please sign in to comment.