1.1 --- a/templates/native/float.c Mon Feb 04 18:53:56 2019 +0100
1.2 +++ b/templates/native/float.c Mon May 20 13:12:25 2019 +0200
1.3 @@ -63,6 +63,28 @@
1.4 return __NULL;
1.5 }
1.6
1.7 +static __attr make_result(__attr self, __attr other, double value)
1.8 +{
1.9 + __attr result;
1.10 +
1.11 + if (self.value->temporary)
1.12 + {
1.13 + __set_trailing_data(self, __builtins___float_float, value);
1.14 + return self;
1.15 + }
1.16 + else if (other.value->temporary)
1.17 + {
1.18 + __set_trailing_data(other, __builtins___float_float, value);
1.19 + return other;
1.20 + }
1.21 + else
1.22 + {
1.23 + result = __new_float(value);
1.24 + result.value->temporary = 1;
1.25 + return result;
1.26 + }
1.27 +}
1.28 +
1.29 /* Floating point operations. Exceptions are raised in the signal handler. */
1.30
1.31 __attr __fn_native_float_float_add(__attr __self, __attr self, __attr other)
1.32 @@ -70,7 +92,7 @@
1.33 /* self and other interpreted as float */
1.34 double i = __TOFLOAT(self);
1.35 double j = __TOFLOAT(other);
1.36 - return __new_float(i + j);
1.37 + return make_result(self, other, i + j);
1.38 }
1.39
1.40 __attr __fn_native_float_float_sub(__attr __self, __attr self, __attr other)
1.41 @@ -78,7 +100,7 @@
1.42 /* self and other interpreted as float */
1.43 double i = __TOFLOAT(self);
1.44 double j = __TOFLOAT(other);
1.45 - return __new_float(i - j);
1.46 + return make_result(self, other, i - j);
1.47 }
1.48
1.49 __attr __fn_native_float_float_mul(__attr __self, __attr self, __attr other)
1.50 @@ -86,7 +108,7 @@
1.51 /* self and other interpreted as float */
1.52 double i = __TOFLOAT(self);
1.53 double j = __TOFLOAT(other);
1.54 - return __new_float(i * j);
1.55 + return make_result(self, other, i * j);
1.56 }
1.57
1.58 __attr __fn_native_float_float_div(__attr __self, __attr self, __attr other)
1.59 @@ -94,7 +116,7 @@
1.60 /* self and other interpreted as float */
1.61 double i = __TOFLOAT(self);
1.62 double j = __TOFLOAT(other);
1.63 - return __new_float(i / j);
1.64 + return make_result(self, other, i / j);
1.65 }
1.66
1.67 __attr __fn_native_float_float_mod(__attr __self, __attr self, __attr other)
1.68 @@ -102,7 +124,7 @@
1.69 /* self and other interpreted as float */
1.70 double i = __TOFLOAT(self);
1.71 double j = __TOFLOAT(other);
1.72 - return __new_float(fmod(i, j));
1.73 + return make_result(self, other, fmod(i, j));
1.74 }
1.75
1.76 __attr __fn_native_float_float_neg(__attr __self, __attr self)
1.77 @@ -128,7 +150,7 @@
1.78 __raise_overflow_error();
1.79
1.80 /* Return the result. */
1.81 - return __new_float(result);
1.82 + return make_result(self, other, result);
1.83 }
1.84
1.85 __attr __fn_native_float_float_le(__attr __self, __attr self, __attr other)