factor/native/arithmetic.c

94 lines
1.4 KiB
C
Raw Normal View History

2004-07-28 19:02:24 -04:00
#include "factor.h"
2004-12-18 20:24:46 -05:00
void primitive_arithmetic_type(void)
{
2004-12-18 20:24:46 -05:00
CELL obj1 = dpeek();
CELL obj2 = get(ds - CELLS);
CELL type1 = TAG(obj1);
CELL type2 = TAG(obj2);
2004-09-19 00:57:33 -04:00
CELL type;
2004-12-18 20:24:46 -05:00
switch(type2)
{
case FIXNUM_TYPE:
2004-12-18 20:24:46 -05:00
switch(type1)
{
case BIGNUM_TYPE:
put(ds - CELLS,tag_bignum(to_bignum(obj2)));
2004-12-18 20:24:46 -05:00
break;
case FLOAT_TYPE:
put(ds - CELLS,tag_float(to_float((obj2))));
2004-12-18 20:24:46 -05:00
break;
}
type = type1;
2004-09-19 00:57:33 -04:00
break;
case BIGNUM_TYPE:
2004-12-18 20:24:46 -05:00
switch(type1)
{
case FIXNUM_TYPE:
drepl(tag_bignum(to_bignum(obj1)));
2004-12-18 20:24:46 -05:00
type = type2;
break;
case FLOAT_TYPE:
put(ds - CELLS,tag_float(to_float((obj2))));
2004-09-19 00:57:33 -04:00
type = type1;
break;
default:
2004-12-18 20:24:46 -05:00
type = type1;
2004-09-19 00:57:33 -04:00
break;
}
2004-09-19 17:39:28 -04:00
break;
case RATIO_TYPE:
2004-12-18 20:24:46 -05:00
switch(type1)
{
case FIXNUM_TYPE:
case BIGNUM_TYPE:
2004-12-18 20:24:46 -05:00
type = type2;
break;
case FLOAT_TYPE:
put(ds - CELLS,tag_float(to_float((obj2))));
2004-09-19 00:57:33 -04:00
type = type1;
break;
default:
2004-12-18 20:24:46 -05:00
type = type1;
2004-09-19 00:57:33 -04:00
break;
}
2004-09-19 17:39:28 -04:00
break;
case FLOAT_TYPE:
2004-12-18 20:24:46 -05:00
switch(type1)
{
case FIXNUM_TYPE:
case BIGNUM_TYPE:
case RATIO_TYPE:
drepl(tag_float(to_float(obj1)));
2004-12-18 20:24:46 -05:00
type = type2;
2004-09-19 00:57:33 -04:00
break;
default:
2004-12-18 20:24:46 -05:00
type = type1;
2004-09-19 00:57:33 -04:00
break;
}
2004-09-19 17:39:28 -04:00
break;
case COMPLEX_TYPE:
2004-12-18 20:24:46 -05:00
switch(type1)
{
case FIXNUM_TYPE:
case BIGNUM_TYPE:
case RATIO_TYPE:
case FLOAT_TYPE:
2004-12-18 20:24:46 -05:00
type = type2;
2004-09-19 00:57:33 -04:00
break;
default:
2004-12-18 20:24:46 -05:00
type = type1;
2004-09-19 00:57:33 -04:00
break;
}
2004-09-19 17:39:28 -04:00
break;
default:
2004-12-18 20:24:46 -05:00
type = type2;
2004-09-19 00:57:33 -04:00
break;
}
2004-12-18 20:24:46 -05:00
dpush(tag_fixnum(type));
2004-09-19 00:33:40 -04:00
}