From e57a8f6853491d527df482d72146b342656b6ac0 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sun, 11 Sep 2005 15:43:14 +0000 Subject: [PATCH] *** empty log message *** --- ase/stx/class.c | 12 ++++++++---- ase/stx/interp.c | 13 ++++++++----- ase/test/stx/parser.c | 12 +++++++++--- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/ase/stx/class.c b/ase/stx/class.c index 3744d49c..04690a51 100644 --- a/ase/stx/class.c +++ b/ase/stx/class.c @@ -1,5 +1,5 @@ /* - * $Id: class.c,v 1.24 2005-09-11 15:15:35 bacon Exp $ + * $Id: class.c,v 1.25 2005-09-11 15:43:14 bacon Exp $ */ #include @@ -123,9 +123,13 @@ xp_word_t xp_stx_lookup_method ( /* TODO: can a metaclas have class variables? */ if (class_obj->header.class != stx->class_metaclass && - class_obj->class_variables != stx->nil) { - if (xp_stx_dict_lookup(stx, - class_obj->methods,name) != stx->nil) return class_index; + class_obj->methods != stx->nil) { + xp_word_t assoc; + assoc = xp_stx_dict_lookup(stx, class_obj->methods,name); + if (assoc != stx->nil) { + xp_assert (XP_STX_CLASS(stx,assoc) == stx->class_association); + return XP_STX_WORD_AT(stx, assoc, XP_STX_ASSOCIATION_VALUE); + } } if (class_obj->superclass != stx->nil) { diff --git a/ase/stx/interp.c b/ase/stx/interp.c index 5e4ec5cc..ad93d64e 100644 --- a/ase/stx/interp.c +++ b/ase/stx/interp.c @@ -1,5 +1,5 @@ /* - * $Id: interp.c,v 1.8 2005-09-11 15:15:35 bacon Exp $ + * $Id: interp.c,v 1.9 2005-09-11 15:43:14 bacon Exp $ */ #include @@ -45,14 +45,13 @@ struct vmcontext_t typedef struct vmcontext_t vmcontext_t; +static int __dispatch_primitive (xp_stx_t* stx, int no, vmcontext_t* vmc); xp_word_t xp_stx_new_context (xp_stx_t* stx, xp_word_t receiver, xp_word_t method) { xp_word_t context; xp_stx_context_t* ctxobj; -xp_printf (XP_TEXT("%d, %d\n"), receiver, method); - context = xp_stx_alloc_word_object( stx, XP_NULL, XP_STX_CONTEXT_SIZE, XP_NULL, 0); XP_STX_CLASS(stx,context) = stx->class_context; @@ -93,6 +92,10 @@ int xp_stx_interp (xp_stx_t* stx, xp_word_t context) while (vmc.pc < vmc.bytecode_size) { code = vmc.bytecodes[vmc.pc++]; +#ifdef DEBUG + xp_printf (XP_TEXT("code = 0x%x, %x\n"), code); +#endif + if (code >= 0x00 && code <= 0x3F) { /* stack - push */ int what = code >> 4; @@ -132,14 +135,14 @@ int xp_stx_interp (xp_stx_t* stx, xp_word_t context) else if (code >= 0xF0 && code <= 0xFF) { /* primitive */ next = vmc.bytecodes[vmc.pc++]; - __dispatch_primitive (next); + __dispatch_primitive (stx, ((code & 0x0F) << 8) | next, &vmc); } } return 0; } -static int __dispatch_primitive (xp_stx_t* stx, int no, xp_stx_context_t* ctxobj) +static int __dispatch_primitive (xp_stx_t* stx, int no, vmcontext_t* vmc) { switch (no) { case 0: diff --git a/ase/test/stx/parser.c b/ase/test/stx/parser.c index 7a3f9df3..9de83f27 100644 --- a/ase/test/stx/parser.c +++ b/ase/test/stx/parser.c @@ -143,6 +143,7 @@ int xp_main (int argc, xp_char_t* argv[]) */ stdio_t stdio; xp_word_t n = xp_stx_lookup_class (&stx, argv[1]); + xp_word_t m; parser.input_owner = (void*)&stdio; parser.input_func = stdio_func; @@ -164,9 +165,14 @@ int xp_main (int argc, xp_char_t* argv[]) xp_stx_parser_error_string (&parser)); } - xp_stx_interp (&stx, - xp_stx_new_context (&stx, n, - xp_stx_lookup_method(&stx, n, XP_TEXT("main")))); + xp_printf (XP_TEXT("== Running the main method ==\n")); + m = xp_stx_lookup_method (&stx, n, XP_TEXT("main")); + if (m == stx.nil) { + xp_printf (XP_TEXT("cannot lookup method main\n")); + } + else { + xp_stx_interp (&stx, xp_stx_new_context (&stx, n, m)); + } } exit_program: