diff --git a/ase/stx/bytecode.c b/ase/stx/bytecode.c index a7103af5..d44049f5 100644 --- a/ase/stx/bytecode.c +++ b/ase/stx/bytecode.c @@ -1,5 +1,5 @@ /* - * $Id: bytecode.c,v 1.11 2005-09-11 15:15:35 bacon Exp $ + * $Id: bytecode.c,v 1.12 2005-09-11 17:01:56 bacon Exp $ */ #include #include @@ -158,8 +158,8 @@ static int __decode2 (xp_stx_t* stx, else if (code >= 0x70 && code <= 0x71 ) { /* send */ next = bytecodes->data[pc++]; - xp_printf (XP_TEXT("%s %d %d\n"), - send_opcode_names[code - 0x70], next >> 5, next >> 0x1F); + xp_printf (XP_TEXT("%s nargs(%d) selector(%d)\n"), + send_opcode_names[code - 0x70], next >> 5, next & 0x1F); } else if (code >= 0x72 && code <= 0x73 ) { /* send extended */ diff --git a/ase/stx/interp.c b/ase/stx/interp.c index ad93d64e..a9f00c68 100644 --- a/ase/stx/interp.c +++ b/ase/stx/interp.c @@ -1,5 +1,5 @@ /* - * $Id: interp.c,v 1.9 2005-09-11 15:43:14 bacon Exp $ + * $Id: interp.c,v 1.10 2005-09-11 17:01:56 bacon Exp $ */ #include @@ -71,7 +71,7 @@ int xp_stx_interp (xp_stx_t* stx, xp_word_t context) xp_stx_context_t* ctxobj; xp_stx_method_t* mthobj; vmcontext_t vmc; - int code, next; + int code, next, next2; ctxobj = (xp_stx_context_t*)XP_STX_OBJECT(stx,context); mthobj = (xp_stx_method_t*)XP_STX_OBJECT(stx,ctxobj->method); @@ -130,6 +130,40 @@ int xp_stx_interp (xp_stx_t* stx, xp_word_t context) } } + /* more here .... */ + + else if (code == 0x70) { + /* send to self */ + int nargs, selector; + next = vmc.bytecodes[vmc.pc++]; + + nargs = next >> 5; + + selector = vmc.literals[next & 0x1F]; + receiver = vmc.stack[--vmc.stack_top]; + + xp_stx_lookup_method (stx, class of receiver, + } + else if (code == 0x71) { + /* send to super */ + int nargs, selector; + next = vmc.bytecodes[vmc.pc++]; + + nargs = next >> 5; + selector = next & 0x1F; + + } + else if (code == 0x72) { + /* send to self extended */ + next = vmc.bytecodes[vmc.pc++]; + next2 = vmc.bytecodes[vmc.pc++]; + } + else if (code == 0x73) { + /* send to super extended */ + next = vmc.bytecodes[vmc.pc++]; + next2 = vmc.bytecodes[vmc.pc++]; + } + /* more code .... */ else if (code >= 0xF0 && code <= 0xFF) { diff --git a/ase/stx/parser.c b/ase/stx/parser.c index 7fccdf04..05889e71 100644 --- a/ase/stx/parser.c +++ b/ase/stx/parser.c @@ -1,5 +1,5 @@ /* - * $Id: parser.c,v 1.69 2005-09-11 15:15:35 bacon Exp $ + * $Id: parser.c,v 1.70 2005-09-11 17:01:56 bacon Exp $ */ #include @@ -441,6 +441,13 @@ static int __add_string_literal ( return __add_literal (parser, literal); } +static int __add_symbol_literal ( + xp_stx_parser_t* parser, const xp_char_t* str, xp_word_t size) +{ + xp_stx_t* stx = parser->stx; + return __add_literal (parser, xp_stx_new_symbolx(stx, str, size)); +} + int xp_stx_parser_parse_method ( xp_stx_parser_t* parser, xp_word_t method_class, void* input) { @@ -947,7 +954,10 @@ static int __parse_primary (xp_stx_parser_t* parser, const xp_char_t* ident) GET_TOKEN (parser); } else if (parser->token.type == XP_STX_TOKEN_SYMLIT) { - EMIT_CODE_TEST (parser, XP_TEXT("PushLiteral(SYM)"), parser->token.name.buffer); + pos = __add_symbol_literal (parser, + parser->token.name.buffer, parser->token.name.size); + if (pos == -1) return -1; + EMIT_PUSH_LITERAL_CONSTANT (parser, pos); GET_TOKEN (parser); } else if (parser->token.type == XP_STX_TOKEN_LBRACKET) { @@ -1198,10 +1208,17 @@ static int __parse_unary_message (xp_stx_parser_t* parser) { /* ::= unarySelector */ + xp_word_t pos; + while (parser->token.type == XP_STX_TOKEN_IDENT) { /* TODO: SEND_TO_SUPER */ /*EMIT_SEND_TO_SELF (parser, 0, index of parser->token.name.buffer);*/ - EMIT_SEND_TO_SELF (parser, 0, 0); + /*EMIT_SEND_TO_SELF (parser, 0, 0);*/ + + pos = __add_symbol_literal (parser, + parser->token.name.buffer, parser->token.name.size); + if (pos == -1) return -1; + EMIT_SEND_TO_SELF (parser, 0, pos); GET_TOKEN (parser); } diff --git a/ase/test/stx/test.st b/ase/test/stx/test.st index 0d23a094..bc125cde 100644 --- a/ase/test/stx/test.st +++ b/ase/test/stx/test.st @@ -2,6 +2,7 @@ main | a b | - a := 1. + a := 10. + #abc xxx. b := 3. ^nil