Skip to content

Commit

Permalink
Prevent warning on unreferenced parameter in SPARK code
Browse files Browse the repository at this point in the history
Ref. #314
  • Loading branch information
treiher committed Jul 23, 2020
1 parent 5b86c63 commit fb44769
Showing 1 changed file with 21 additions and 26 deletions.
47 changes: 21 additions & 26 deletions rflx/generator/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2173,11 +2173,11 @@ def __create_type(self, field_type: Type, message_package: ID) -> None:
if isinstance(field_type, ModularInteger):
unit += UnitPart(modular_types(field_type))
unit += UnitPart(self.__type_dependent_unreachable_function(field_type))
unit += self.__modular_functions(field_type)
unit += self.__integer_functions(field_type)
elif isinstance(field_type, RangeInteger):
unit += UnitPart(range_types(field_type))
unit += UnitPart(self.__type_dependent_unreachable_function(field_type))
unit += self.__range_functions(field_type)
unit += self.__integer_functions(field_type)
elif isinstance(field_type, Enumeration):
unit += UnitPart(enumeration_types(field_type))
unit += UnitPart(self.__type_dependent_unreachable_function(field_type))
Expand Down Expand Up @@ -2239,35 +2239,30 @@ def __create_array_unit(self, array_type: Array, package_name: ID) -> None:

self.__create_instantiation_unit(array_package.identifier, array_context, array_package)

def __range_functions(self, integer: RangeInteger) -> SubprogramUnitPart:
specification: List[Subprogram] = []
def __integer_functions(self, integer: Integer) -> UnitPart:
specification: List[Declaration] = []

for range_type in range_types(integer):
if isinstance(range_type, RangeSubtype):
continue
constraints = And(*integer.constraints("Val")).simplified()

specification.append(
self.__type_validation_function(integer, And(*integer.constraints("Val")).simplified())
)
specification.extend(self.__integer_conversion_functions(integer))
if constraints == TRUE:
specification.extend(
[
Pragma("Warnings", ["Off", '"unused variable ""Val"""']),
Pragma("Warnings", ["Off", '"formal parameter ""Val"" is not referenced"']),
]
)

return SubprogramUnitPart(specification)
specification.append(self.__type_validation_function(integer, constraints))

def __modular_functions(self, integer: ModularInteger) -> UnitPart:
specification: List[Declaration] = []
if constraints == TRUE:
specification.extend(
[
Pragma("Warnings", ["On", '"formal parameter ""Val"" is not referenced"']),
Pragma("Warnings", ["On", '"unused variable ""Val"""']),
]
)

specification.extend(
[
Pragma("Warnings", ["Off", '"unused variable ""Val"""']),
Pragma("Warnings", ["Off", '"formal parameter ""Val"" is not referenced"']),
self.__type_validation_function(
integer, And(*integer.constraints("Val")).simplified()
),
Pragma("Warnings", ["On", '"formal parameter ""Val"" is not referenced"']),
Pragma("Warnings", ["On", '"unused variable ""Val"""']),
*self.__integer_conversion_functions(integer),
]
)
specification.extend(self.__integer_conversion_functions(integer))

return UnitPart(specification)

Expand Down

0 comments on commit fb44769

Please sign in to comment.