Temporarily disable using immediate ints

Also bugfix to let equal() work with immediates
This commit is contained in:
Justin Ethier 2016-03-19 22:20:08 -04:00
parent 750bd80619
commit 580a674525
2 changed files with 18 additions and 8 deletions

View file

@ -414,11 +414,15 @@ int equal(x, y) object x, y;
if (nullp(x)) return nullp(y); if (nullp(x)) return nullp(y);
if (nullp(y)) return nullp(x); if (nullp(y)) return nullp(x);
if (obj_is_char(x)) return obj_is_char(y) && x == y; if (obj_is_char(x)) return obj_is_char(y) && x == y;
if (obj_is_int(x)) return obj_is_int(y) && x == y; if (obj_is_int(x)) return (obj_is_int(y) && x == y) ||
(is_object_type(y) &&
type_of(y) == integer_tag &&
integer_value(y) == obj_obj2int(x));
switch(type_of(x)) { switch(type_of(x)) {
case integer_tag: case integer_tag:
return (obj_is_int(y) && obj_obj2int(y) == integer_value(x)) || return (obj_is_int(y) && obj_obj2int(y) == integer_value(x)) ||
(type_of(y) == integer_tag && (is_object_type(y) &&
type_of(y) == integer_tag &&
((integer_type *) x)->value == ((integer_type *) y)->value); ((integer_type *) x)->value == ((integer_type *) y)->value);
case double_tag: case double_tag:
return (is_object_type(y) && return (is_object_type(y) &&
@ -1529,10 +1533,10 @@ object Cyc_num_op_va_list(void *data, int argc, object (fn_op(void *, common_typ
fn_op(data, buf, va_arg(ns, object)); fn_op(data, buf, va_arg(ns, object));
} }
// TODO: if result is integer, could convert to an immediate here // // TODO: if result is integer, could convert to an immediate here
if (type_of(buf) == integer_tag) { // if (type_of(buf) == integer_tag) {
return obj_int2obj(buf->integer_t.value); // return obj_int2obj(buf->integer_t.value);
} // }
return buf; return buf;
} }

View file

@ -405,8 +405,14 @@
((vector? exp) ((vector? exp)
(c-compile-vector exp)) (c-compile-vector exp))
((integer? exp) ((integer? exp)
(c-code (string-append "obj_int2obj(" (let ((cvar-name (mangle (gensym 'c))))
(number->string exp) ")"))) (c-code/vars
(string-append "&" cvar-name) ; Code is just the variable name
(list ; Allocate integer on the C stack
(string-append
"make_int(" cvar-name ", " (number->string exp) ");")))))
; (c-code (string-append "obj_int2obj("
; (number->string exp) ")")))
((real? exp) ((real? exp)
(let ((cvar-name (mangle (gensym 'c)))) (let ((cvar-name (mangle (gensym 'c))))
(c-code/vars (c-code/vars