*** empty log message ***
This commit is contained in:
parent
ef790d9aa8
commit
e57a8f6853
@ -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>
|
#include <xp/stx/class.h>
|
||||||
@ -123,9 +123,13 @@ xp_word_t xp_stx_lookup_method (
|
|||||||
|
|
||||||
/* TODO: can a metaclas have class variables? */
|
/* TODO: can a metaclas have class variables? */
|
||||||
if (class_obj->header.class != stx->class_metaclass &&
|
if (class_obj->header.class != stx->class_metaclass &&
|
||||||
class_obj->class_variables != stx->nil) {
|
class_obj->methods != stx->nil) {
|
||||||
if (xp_stx_dict_lookup(stx,
|
xp_word_t assoc;
|
||||||
class_obj->methods,name) != stx->nil) return class_index;
|
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) {
|
if (class_obj->superclass != stx->nil) {
|
||||||
|
@ -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>
|
#include <xp/stx/interp.h>
|
||||||
@ -45,14 +45,13 @@ struct vmcontext_t
|
|||||||
|
|
||||||
typedef struct vmcontext_t 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 xp_stx_new_context (xp_stx_t* stx, xp_word_t receiver, xp_word_t method)
|
||||||
{
|
{
|
||||||
xp_word_t context;
|
xp_word_t context;
|
||||||
xp_stx_context_t* ctxobj;
|
xp_stx_context_t* ctxobj;
|
||||||
|
|
||||||
xp_printf (XP_TEXT("%d, %d\n"), receiver, method);
|
|
||||||
|
|
||||||
context = xp_stx_alloc_word_object(
|
context = xp_stx_alloc_word_object(
|
||||||
stx, XP_NULL, XP_STX_CONTEXT_SIZE, XP_NULL, 0);
|
stx, XP_NULL, XP_STX_CONTEXT_SIZE, XP_NULL, 0);
|
||||||
XP_STX_CLASS(stx,context) = stx->class_context;
|
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) {
|
while (vmc.pc < vmc.bytecode_size) {
|
||||||
code = vmc.bytecodes[vmc.pc++];
|
code = vmc.bytecodes[vmc.pc++];
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
xp_printf (XP_TEXT("code = 0x%x, %x\n"), code);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (code >= 0x00 && code <= 0x3F) {
|
if (code >= 0x00 && code <= 0x3F) {
|
||||||
/* stack - push */
|
/* stack - push */
|
||||||
int what = code >> 4;
|
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) {
|
else if (code >= 0xF0 && code <= 0xFF) {
|
||||||
/* primitive */
|
/* primitive */
|
||||||
next = vmc.bytecodes[vmc.pc++];
|
next = vmc.bytecodes[vmc.pc++];
|
||||||
__dispatch_primitive (next);
|
__dispatch_primitive (stx, ((code & 0x0F) << 8) | next, &vmc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
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) {
|
switch (no) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -143,6 +143,7 @@ int xp_main (int argc, xp_char_t* argv[])
|
|||||||
*/
|
*/
|
||||||
stdio_t stdio;
|
stdio_t stdio;
|
||||||
xp_word_t n = xp_stx_lookup_class (&stx, argv[1]);
|
xp_word_t n = xp_stx_lookup_class (&stx, argv[1]);
|
||||||
|
xp_word_t m;
|
||||||
|
|
||||||
parser.input_owner = (void*)&stdio;
|
parser.input_owner = (void*)&stdio;
|
||||||
parser.input_func = stdio_func;
|
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_parser_error_string (&parser));
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_stx_interp (&stx,
|
xp_printf (XP_TEXT("== Running the main method ==\n"));
|
||||||
xp_stx_new_context (&stx, n,
|
m = xp_stx_lookup_method (&stx, n, XP_TEXT("main"));
|
||||||
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:
|
exit_program:
|
||||||
|
Loading…
Reference in New Issue
Block a user