diff --git a/ase/lsp/memory.c b/ase/lsp/memory.c index b8572ace..ebd32d51 100644 --- a/ase/lsp/memory.c +++ b/ase/lsp/memory.c @@ -1,5 +1,5 @@ /* - * $Id: memory.c,v 1.8 2005-02-07 15:10:41 bacon Exp $ + * $Id: memory.c,v 1.9 2005-02-14 14:37:50 bacon Exp $ */ #include @@ -383,7 +383,7 @@ xp_lisp_obj_t* xp_lisp_make_true (xp_lisp_mem_t* mem) return mem->t; } -xp_lisp_obj_t* xp_lisp_make_int (xp_lisp_mem_t* mem, xp_lisp_int value) +xp_lisp_obj_t* xp_lisp_make_int (xp_lisp_mem_t* mem, xp_lisp_int_t value) { xp_lisp_obj_t* obj; @@ -395,7 +395,7 @@ xp_lisp_obj_t* xp_lisp_make_int (xp_lisp_mem_t* mem, xp_lisp_int value) return obj; } -xp_lisp_obj_t* xp_lisp_make_float (xp_lisp_mem_t* mem, xp_lisp_float value) +xp_lisp_obj_t* xp_lisp_make_float (xp_lisp_mem_t* mem, xp_lisp_real_t value) { xp_lisp_obj_t* obj; diff --git a/ase/lsp/memory.h b/ase/lsp/memory.h index 9e6f6fc7..54227b46 100644 --- a/ase/lsp/memory.h +++ b/ase/lsp/memory.h @@ -1,5 +1,5 @@ /* - * $Id: memory.h,v 1.3 2005-02-07 15:10:41 bacon Exp $ + * $Id: memory.h,v 1.4 2005-02-14 14:37:50 bacon Exp $ */ #ifndef _XP_LISP_MEM_H_ @@ -68,8 +68,8 @@ void xp_lisp_unlock_all (xp_lisp_obj_t* obj); // object creation of standard types xp_lisp_obj_t* xp_lisp_make_nil (xp_lisp_mem_t* mem); xp_lisp_obj_t* xp_lisp_make_true (xp_lisp_mem_t* mem); -xp_lisp_obj_t* xp_lisp_make_int (xp_lisp_mem_t* mem, xp_lisp_int value); -xp_lisp_obj_t* xp_lisp_make_float (xp_lisp_mem_t* mem, xp_lisp_float value); +xp_lisp_obj_t* xp_lisp_make_int (xp_lisp_mem_t* mem, xp_lisp_int_t value); +xp_lisp_obj_t* xp_lisp_make_float (xp_lisp_mem_t* mem, xp_lisp_real_t value); xp_lisp_obj_t* xp_lisp_make_symbol (xp_lisp_mem_t* mem, const xp_char_t* str, xp_size_t len); xp_lisp_obj_t* xp_lisp_make_string (xp_lisp_mem_t* mem, const xp_char_t* str, xp_size_t len); xp_lisp_obj_t* xp_lisp_make_cons (xp_lisp_mem_t* mem, xp_lisp_obj_t* car, xp_lisp_obj_t* cdr); diff --git a/ase/lsp/object.h b/ase/lsp/object.h index 5185091f..03e975df 100644 --- a/ase/lsp/object.h +++ b/ase/lsp/object.h @@ -1,5 +1,5 @@ /* - * $Id: object.h,v 1.3 2005-02-07 15:10:41 bacon Exp $ + * $Id: object.h,v 1.4 2005-02-14 14:37:50 bacon Exp $ */ #ifndef _XP_LISP_OBJECT_H_ @@ -49,13 +49,13 @@ struct xp_lisp_obj_true_t struct xp_lisp_obj_int_t { XP_LISP_OBJ_HEADER; - xp_lisp_int value; + xp_lisp_int_t value; }; struct xp_lisp_obj_float_t { XP_LISP_OBJ_HEADER; - xp_lisp_float value; + xp_lisp_real_t value; }; struct xp_lisp_obj_symbol_t diff --git a/ase/lsp/primitive.c b/ase/lsp/primitive.c index 4459d208..01d81051 100644 --- a/ase/lsp/primitive.c +++ b/ase/lsp/primitive.c @@ -1,5 +1,5 @@ /* - * $Id: primitive.c,v 1.4 2005-02-05 05:30:25 bacon Exp $ + * $Id: primitive.c,v 1.5 2005-02-14 14:37:50 bacon Exp $ */ #include @@ -523,7 +523,7 @@ xp_lisp_obj_t* xp_lisp_prim_letx (xp_lisp_t* lsp, xp_lisp_obj_t* args) xp_lisp_obj_t* xp_lisp_prim_plus (xp_lisp_t* lsp, xp_lisp_obj_t* args) { xp_lisp_obj_t* body, * tmp; - xp_lisp_int value = 0; + xp_lisp_int_t value = 0; XP_LISP_PRIM_CHECK_ARG_COUNT (lsp, args, 1, XP_LISP_PRIM_MAX_ARG_COUNT); xp_assert (XP_LISP_TYPE(args) == XP_LISP_OBJ_CONS); diff --git a/ase/lsp/print.c b/ase/lsp/print.c index d1e0fc03..649c02e4 100644 --- a/ase/lsp/print.c +++ b/ase/lsp/print.c @@ -1,5 +1,5 @@ /* - * $Id: print.c,v 1.3 2005-02-04 16:23:34 bacon Exp $ + * $Id: print.c,v 1.4 2005-02-14 14:37:50 bacon Exp $ */ #include @@ -67,7 +67,15 @@ void xp_lisp_print (xp_lisp_t* lsp, xp_lisp_obj_t* obj) xp_fprintf (lsp->outstream,XP_TEXT("t")); break; case XP_LISP_OBJ_INT: - xp_fprintf (lsp->outstream,XP_TEXT("%d"), XP_LISP_IVALUE(obj)); + if (xp_sizeof(xp_lisp_int_t) == xp_sizeof(int)) { + xp_fprintf (lsp->outstream,XP_TEXT("%d"), XP_LISP_IVALUE(obj)); + } + else if (xp_sizeof(xp_lisp_int_t) == xp_sizeof(long)) { + xp_fprintf (lsp->outstream,XP_TEXT("%ld"), XP_LISP_IVALUE(obj)); + } + else if (xp_sizeof(xp_lisp_int_t) == xp_sizeof(long long)) { + xp_fprintf (lsp->outstream,XP_TEXT("%lld"), XP_LISP_IVALUE(obj)); + } break; case XP_LISP_OBJ_FLOAT: xp_fprintf (lsp->outstream,XP_TEXT("%f"), XP_LISP_FVALUE(obj)); diff --git a/ase/lsp/read.c b/ase/lsp/read.c index 02a39bb7..e9b5b1ba 100644 --- a/ase/lsp/read.c +++ b/ase/lsp/read.c @@ -1,5 +1,5 @@ /* - * $Id: read.c,v 1.6 2005-02-05 05:43:55 bacon Exp $ + * $Id: read.c,v 1.7 2005-02-14 14:37:50 bacon Exp $ */ #include @@ -326,17 +326,20 @@ static int read_token (xp_lisp_t* lsp) static int read_number (xp_lisp_t* lsp, int negative) { + xp_lisp_int_t ivalue = 0; + do { - TOKEN_IVALUE(lsp) = - TOKEN_IVALUE(lsp) * 10 + lsp->curc - XP_CHAR('0'); + ivalue = ivalue * 10 + (lsp->curc - XP_CHAR('0')); TOKEN_ADD_CHAR (lsp, lsp->curc); NEXT_CHAR (lsp); } while (IS_DIGIT(lsp->curc)); - if (negative) TOKEN_IVALUE(lsp) *= -1; + if (negative) ivalue *= -1; + + TOKEN_IVALUE(lsp) = ivalue; TOKEN_TYPE(lsp) = TOKEN_INT; - // TODO: read floating point numbers +/* TODO: read floating point numbers */ return 0; } @@ -354,7 +357,7 @@ static int read_ident (xp_lisp_t* lsp) static int read_string (xp_lisp_t* lsp) { int escaped = 0; - xp_lisp_cint code = 0; + xp_cint_t code = 0; do { if (lsp->curc == XP_EOF) { diff --git a/ase/lsp/token.h b/ase/lsp/token.h index 7755fb96..3a384668 100644 --- a/ase/lsp/token.h +++ b/ase/lsp/token.h @@ -1,5 +1,5 @@ /* - * $Id: token.h,v 1.4 2005-02-07 15:10:41 bacon Exp $ + * $Id: token.h,v 1.5 2005-02-14 14:37:50 bacon Exp $ */ #ifndef _XP_LISP_TOKEN_H_ @@ -11,8 +11,8 @@ struct xp_lisp_token_t { int type; - xp_lisp_int ivalue; - xp_lisp_float fvalue; + xp_lisp_int_t ivalue; + xp_lisp_real_t fvalue; xp_size_t capacity; xp_size_t size; diff --git a/ase/lsp/types.h b/ase/lsp/types.h index 4a4b1091..63681052 100644 --- a/ase/lsp/types.h +++ b/ase/lsp/types.h @@ -1,5 +1,5 @@ /* - * $Id: types.h,v 1.4 2005-02-07 15:10:41 bacon Exp $ + * $Id: types.h,v 1.5 2005-02-14 14:37:50 bacon Exp $ */ #ifndef _XP_LISP_TYPES_H_ @@ -8,8 +8,7 @@ #include #include -typedef xp_cint_t xp_lisp_cint; -typedef xp_long_t xp_lisp_int; -typedef xp_real_t xp_lisp_float; +typedef xp_long_t xp_lisp_int_t; +typedef xp_real_t xp_lisp_real_t; #endif