Skip to content

Commit

Permalink
#2642 Avoid useless extends DataTypeSymbol visibility and procedure d…
Browse files Browse the repository at this point in the history
…atatype. Format.
  • Loading branch information
JulienRemy committed Dec 2, 2024
1 parent c8f74cb commit c35d98b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 32 deletions.
16 changes: 8 additions & 8 deletions src/psyclone/psyGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
UnresolvedType,
ImportInterface, INTEGER_TYPE,
RoutineSymbol, Symbol)
from psyclone.psyir.symbols.datatypes import (UnsupportedFortranType,
from psyclone.psyir.symbols.datatypes import (UnsupportedFortranType,
StructureType)

# The types of 'intent' that an argument to a Fortran subroutine
Expand Down Expand Up @@ -1768,7 +1768,7 @@ def _rename_psyir(self, suffix):
# go through its procedure components.
elif isinstance(sym.datatype, StructureType):
for procedure_name, procedure_component \
in sym.datatype.procedure_components.items():
in sym.datatype.procedure_components.items():
# Either the procedure component is of
# UnsupportedFortranType, in which case we replace in its
# whole declaration.
Expand All @@ -1780,8 +1780,8 @@ def _rename_psyir(self, suffix):
new_procedure_component = StructureType.ComponentType(
procedure_component.name,
UnsupportedFortranType(new_declaration,
procedure_component.\
datatype.partial_datatype),
procedure_component.
datatype.partial_datatype),
procedure_component.visibility,
procedure_component.initial_value)
sym.datatype.procedure_components[procedure_name] = \
Expand All @@ -1796,11 +1796,11 @@ def _rename_psyir(self, suffix):
new_kernel_symbol = RoutineSymbol(new_kern_name)
new_procedure_component = \
StructureType.ComponentType(procedure_component
.name,
.name,
procedure_component
.datatype,
procedure_component\
.visibility,
.datatype,
procedure_component
.visibility,
Reference(
new_kernel_symbol))
sym.datatype.procedure_components[procedure_name] = \
Expand Down
28 changes: 4 additions & 24 deletions src/psyclone/psyir/frontend/fparser2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2002,17 +2002,8 @@ def _process_derived_type_decln(self, parent, decl, visibility_map):
# If it is not in the symbol table, create a new
# DataTypeSymbol for it.
else:
# The visibility of the symbol representing this
# derived type.
if extends_name in visibility_map:
extends_symbol_vis = visibility_map[
extends_name]
else:
extends_symbol_vis = parent.symbol_table.\
default_visibility
extends_symbol = DataTypeSymbol(extends_name,
StructureType(),
extends_symbol_vis)
StructureType())
# Set it as the extended type of the new type.
dtype.extends = extends_symbol
else:
Expand Down Expand Up @@ -2062,20 +2053,9 @@ def _process_derived_type_decln(self, parent, decl, visibility_map):
# Deal with the optional initial value.
if procedure.items[4] is not None:
initial_value_name = procedure.items[4].string
# Look it up in the symbol table and get its
# datatype or create it if it does not exist.
if initial_value_name in parent.symbol_table:
initial_value_symbol = parent.symbol_table.\
lookup(initial_value_name)
if (isinstance(procedure_datatype,
UnsupportedFortranType)
and supported):
procedure_datatype = initial_value_symbol.\
datatype
else:
initial_value_symbol = RoutineSymbol(
initial_value_name,
UnresolvedType())
initial_value_symbol = RoutineSymbol(
initial_value_name,
UnresolvedType())
initial_value = Reference(initial_value_symbol)
else:
initial_value = None
Expand Down

0 comments on commit c35d98b

Please sign in to comment.