@@ -107,8 +107,12 @@ def ratio_read(obj):
107107_num_eq = as_var ("-num-eq" )(DoublePolymorphicFn (u"-num-eq" , IMath ))
108108_num_eq .set_default_fn (wrap_fn (lambda a , b : false ))
109109
110- as_var ("MAX-NUMBER" )(Integer (100000 )) # TODO: set this to a real max number
110+ IUncheckedMath = as_var ("IUncheckedMath" )(Protocol (u"IUncheckedMath" ))
111+ _unchecked_add = as_var ("-unchecked-add" )(DoublePolymorphicFn (u"-unchecked-add" , IUncheckedMath ))
112+ _unchecked_subtract = as_var ("-unchecked-subtract" )(DoublePolymorphicFn (u"-unchecked-subtract" , IUncheckedMath ))
113+ _unchecked_multiply = as_var ("-unchecked-multiply" )(DoublePolymorphicFn (u"-unchecked-multiply" , IUncheckedMath ))
111114
115+ as_var ("MAX-NUMBER" )(Integer (100000 )) # TODO: set this to a real max number
112116
113117num_op_template = """@extend({pfn}, {ty1}._type, {ty2}._type)
114118def {pfn}_{ty1}_{ty2}(a, b):
@@ -167,6 +171,16 @@ def define_num_ops():
167171
168172define_num_ops ()
169173
174+ def define_unchecked_num_ops ():
175+ # maybe define get_val() instead of using tuples?
176+ num_classes = [(Integer , "int_val" ), (Float , "float_val" )]
177+ for (c1 , conv1 ) in num_classes :
178+ for (c2 , conv2 ) in num_classes :
179+ for (op , sym ) in [("_unchecked_add" , "+" ), ("_unchecked_subtract" , "-" ), ("_unchecked_multiply" , "*" )]:
180+ extend_num_op (op , c1 , c2 , conv1 , sym , conv2 )
181+
182+ define_unchecked_num_ops ()
183+
170184bigint_ops_tmpl = """@extend({pfn}, {ty1}._type, {ty2}._type)
171185def _{pfn}_{ty1}_{ty2}(a, b):
172186 assert isinstance(a, {ty1}) and isinstance(b, {ty2})
0 commit comments