File tree Expand file tree Collapse file tree 4 files changed +21
-3
lines changed Expand file tree Collapse file tree 4 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -552,6 +552,13 @@ def template_expr(self):
552
552
return self ._expr
553
553
554
554
def set_value (self , expr ):
555
+ # Setting a value will convert this instance from a templatized
556
+ # type to the original Data type (and call the original set_value()).
557
+ #
558
+ # Note: We assume that the templatized type is created by
559
+ # inheriting (TemplateDataMixin, <original data class>), and
560
+ # that this instance doesn't have additional multiple
561
+ # inheritance that could re-order the MRO.
555
562
self .__class__ = self .__class__ .__mro__ [
556
563
self .__class__ .__mro__ .index (TemplateDataMixin ) + 1
557
564
]
Original file line number Diff line number Diff line change @@ -180,6 +180,13 @@ def template_expr(self):
180
180
return self ._args_
181
181
182
182
def set_value (self , expr ):
183
+ # Setting a value will convert this instance from a templatized
184
+ # type to the original Data type (and call the original set_value()).
185
+ #
186
+ # Note: We assume that the templatized type is created by
187
+ # inheriting (TemplateDataMixin, <original data class>), and
188
+ # that this instance doesn't have additional multiple
189
+ # inheritance that could re-order the MRO.
183
190
self .__class__ = self .__class__ .__mro__ [
184
191
self .__class__ .__mro__ .index (TemplateDataMixin ) + 1
185
192
]
Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ def append(self, other):
181
181
# change). Omitting the assertion for efficiency.
182
182
# assert self.multiplier == 1
183
183
_type , other = other
184
- if _type <= _FIXED :
184
+ if _type <= _FIXED : # Note: catching _FIXED and _CONSTANT
185
185
self .constant += other
186
186
return
187
187
@@ -234,7 +234,7 @@ def append(self, other):
234
234
235
235
236
236
def to_expression (visitor , arg ):
237
- if arg [0 ] <= _VARIABLE :
237
+ if arg [0 ] <= _VARIABLE : # Note: catching _VARIABLE, _FIXED, and _CONSTANT
238
238
return arg [1 ]
239
239
else :
240
240
return arg [1 ].to_expression (visitor )
@@ -916,7 +916,7 @@ def finalizeResult(self, result):
916
916
ans = result [1 ]
917
917
if ans .__class__ is not self .Result :
918
918
ans = self .Result ()
919
- assert result [0 ] <= _FIXED
919
+ assert result [0 ] <= _FIXED # Note: allowing _FIXED or _CONSTANT
920
920
ans .constant = result [1 ]
921
921
return ans
922
922
Original file line number Diff line number Diff line change 67
67
68
68
69
69
class ExprType (enums .IntEnum ):
70
+ # Note that the ordering is meaningful, and we will compare
71
+ # instances using relational operators. In particular, we assume
72
+ # that the Enum values increase in polynomial degree, starting at
73
+ # CONSTANT and endine at GENERAL (nonlinear).
70
74
CONSTANT = 0
71
75
FIXED = 3
72
76
VARIABLE = 5
You can’t perform that action at this time.
0 commit comments