Skip to content

Commit

Permalink
Remove unnecessary identifier conversions
Browse files Browse the repository at this point in the history
Ref. #691, #1106
  • Loading branch information
treiher committed Jul 15, 2022
1 parent 8c688f6 commit 598cf51
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 117 deletions.
12 changes: 6 additions & 6 deletions rflx/generator/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ def create_valid_value_function(
Call(
f"Valid_{t.name}"
if is_builtin_type(t.identifier)
else ID(prefix * t.package * f"Valid_{t.name}"),
else prefix * t.package * f"Valid_{t.name}",
[Variable("Val")],
)
if isinstance(t, Scalar)
Expand Down Expand Up @@ -1740,9 +1740,9 @@ def condition(field: Field, message: Message) -> Expr:
c: expr.Expr = expr.Or(*[l.condition for l in message.outgoing(field)])
c = c.substituted(
mapping={
expr.Size(field.name): expr.Call(ID(const.TYPES_BASE_INT), [expr.Variable("Size")]),
expr.Size(field.name): expr.Call(const.TYPES_BASE_INT, [expr.Variable("Size")]),
expr.Last(field.name): expr.Call(
ID(const.TYPES_BASE_INT),
const.TYPES_BASE_INT,
[
expr.Call(
"Field_Last",
Expand Down Expand Up @@ -3140,7 +3140,7 @@ def _create_valid_structure_function(prefix: str, message: Message) -> UnitPart:

valid_values = [
Call(
ID(prefix * t.package * f"Valid_{t.name}"),
prefix * t.package * f"Valid_{t.name}",
[
Variable("Struct" * f.identifier),
],
Expand Down Expand Up @@ -3367,7 +3367,7 @@ def func(expression: expr.Expr) -> expr.Expr:

if isinstance(field_type, Scalar):
return expr.Call(
ID(const.TYPES_BASE_INT),
const.TYPES_BASE_INT,
[expr.Variable("Struct" * expression.identifier)],
)

Expand Down Expand Up @@ -3403,7 +3403,7 @@ def _create_to_context_procedure(prefix: str, message: Message) -> UnitPart:
)
.substituted(
lambda x: expr.Call(
ID(const.TYPES_BIT_LENGTH),
const.TYPES_BIT_LENGTH,
[expr.Variable("Struct" * x.identifier)],
)
if isinstance(x, expr.Variable)
Expand Down
22 changes: 7 additions & 15 deletions rflx/generator/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,22 +205,16 @@ def create_get_function(
[Variable("Ctx"), Variable("Fld")],
),
Call(
ID(
self.prefix
* message.identifier
* "Sufficient_Buffer_Length"
),
self.prefix * message.identifier * "Sufficient_Buffer_Length",
[Variable("Ctx"), Variable("Fld")],
),
*(
[
Not(
Call(
ID(
self.prefix
* message.identifier
* "Composite_Field"
),
self.prefix
* message.identifier
* "Composite_Field",
[Variable("Fld")],
)
)
Expand Down Expand Up @@ -998,11 +992,9 @@ def specification(field: Field) -> ProcedureSpecification:
[
Variable("Ctx"),
Variable(
ID(
self.prefix
* message.identifier
* f.affixed_name
)
self.prefix
* message.identifier
* f.affixed_name
),
],
)
Expand Down
Loading

0 comments on commit 598cf51

Please sign in to comment.