From 687379ed6c8f57ed6167ceb2271c3b014ac72937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=BCndler?= Date: Tue, 9 Jan 2024 08:50:40 +0100 Subject: [PATCH] Use constant nth field access where possible --- opshin/types.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/opshin/types.py b/opshin/types.py index 618ed897..66db543a 100644 --- a/opshin/types.py +++ b/opshin/types.py @@ -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, ), ), ) @@ -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, @@ -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,