*** empty log message ***

This commit is contained in:
hyung-hwan 2005-09-11 15:43:14 +00:00
parent ef790d9aa8
commit e57a8f6853
3 changed files with 25 additions and 12 deletions

View File

@ -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 <xp/stx/class.h>
@ -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) {

View File

@ -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 <xp/stx/interp.h>
@ -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:

View File

@ -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: