Skip to content

Commit

Permalink
Merge pull request #304 from OpShin/feat/constant_fields
Browse files Browse the repository at this point in the history
Use constant nth field access where possible
  • Loading branch information
nielstron authored Jan 9, 2024
2 parents 54b37d2 + 687379e commit 20aa8e2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions opshin/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,9 @@ def attribute(self, attr: str) -> plt.AST:
return OLambda(
["self"],
transform_ext_params_map(attr_typ)(
plt.NthField(
plt.ConstantNthField(
OVar("self"),
plt.Integer(pos),
pos,
),
),
)
Expand Down Expand Up @@ -509,7 +509,7 @@ def stringify(self, recursive: bool = False) -> plt.AST:
plt.Apply(
field_type.stringify(recursive=True),
transform_ext_params_map(field_type)(
plt.NthField(OVar("self"), plt.Integer(pos))
plt.ConstantNthField(OVar("self"), pos)
),
),
map_fields,
Expand All @@ -520,7 +520,7 @@ def stringify(self, recursive: bool = False) -> plt.AST:
plt.Apply(
self.record.fields[0][1].stringify(recursive=True),
transform_ext_params_map(self.record.fields[0][1])(
plt.NthField(OVar("self"), plt.Integer(pos))
plt.ConstantNthField(OVar("self"), pos)
),
),
map_fields,
Expand Down

0 comments on commit 20aa8e2

Please sign in to comment.