diff --git a/cgen.scm b/cgen.scm index 16837e1e..fdde1054 100644 --- a/cgen.scm +++ b/cgen.scm @@ -545,7 +545,7 @@ ((eq? p 'open-input-file) "port_type") ((eq? p 'length) "integer_type") ((eq? p 'char->integer) "integer_type") - ((eq? p 'string->number) "integer_type") + ((eq? p 'string->number) "common_type") ((eq? p 'list->string) "string_type") ; ((eq? p 'string->list) "object") ((eq? p 'string-append) "string_type") diff --git a/cyclone.h b/cyclone.h index 1a764db2..597b3ef0 100644 --- a/cyclone.h +++ b/cyclone.h @@ -268,5 +268,14 @@ void dispatch(int argc, function_type func, object clo, object cont, object args void dispatch_va(int argc, function_type_va func, object clo, object cont, object args); void do_dispatch(int argc, function_type func, object clo, object *buffer); +/* All constant-size objects */ +typedef union { + cons_type cons_t; + symbol_type symbol_t; + primitive_type primitive_t; + integer_type integer_t; + double_type double_t; + string_type string_t; +} common_type; #endif /* CYCLONE_H */ diff --git a/runtime.h b/runtime.h index dbee4f82..f5c1f0b3 100644 --- a/runtime.h +++ b/runtime.h @@ -660,14 +660,16 @@ static void __string2list(const char *str, cons_type *buf, int buflen){ } } -static integer_type Cyc_string2number(object str){ +static common_type Cyc_string2number(object str){ + common_type result; make_int(n, 0); if (type_of(str) == string_tag && ((string_type *) str)->str){ // TODO: not good enough long-term since it doesn't parse floats n.value = atoi(((string_type *) str)->str); } - return n; + result.integer_t = n; + return result; } static void dispatch_string_91append(int argc, object clo, object cont, object str1, ...) { @@ -975,7 +977,7 @@ static void _char_91_125integer(object cont, object args) { static void _integer_91_125char(object cont, object args) { return_funcall1(cont, Cyc_integer2char(car(args)));} static void _string_91_125number(object cont, object args) { - integer_type i = Cyc_string2number(car(args)); + common_type i = Cyc_string2number(car(args)); return_funcall1(cont, &i);} //static void _error(object cont, object args) { // integer_type argc = Cyc_length(args); @@ -1122,16 +1124,6 @@ defprimitive(write, write, &_write); /* write */ defprimitive(display, display, &_display); /* display */ /* -------------------------------------------- */ -/* All constant-size objects */ -typedef union { - cons_type cons_t; - symbol_type symbol_t; - primitive_type primitive_t; - integer_type integer_t; - double_type double_t; - string_type string_t; -} common_type; - /* * * @param cont - Continuation for the function to call into