*** empty log message ***
This commit is contained in:
parent
1a229b9d41
commit
70fa033b9f
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: bytecode.c,v 1.8 2005-07-19 12:08:04 bacon Exp $
|
* $Id: bytecode.c,v 1.9 2005-08-11 16:16:04 bacon Exp $
|
||||||
*/
|
*/
|
||||||
#include <xp/stx/bytecode.h>
|
#include <xp/stx/bytecode.h>
|
||||||
#include <xp/stx/class.h>
|
#include <xp/stx/class.h>
|
||||||
@ -85,7 +85,8 @@ static int __decode2 (xp_stx_t* stx,
|
|||||||
xp_word_t bytecode_size, pc = 0;
|
xp_word_t bytecode_size, pc = 0;
|
||||||
int code, next, next2;
|
int code, next, next2;
|
||||||
|
|
||||||
static const xp_char_t* stack_opcode_names[] = {
|
static const xp_char_t* stack_opcode_names[] =
|
||||||
|
{
|
||||||
XP_TEXT("push_receiver_variable"),
|
XP_TEXT("push_receiver_variable"),
|
||||||
XP_TEXT("push_temporary_location"),
|
XP_TEXT("push_temporary_location"),
|
||||||
XP_TEXT("push_literal_constant"),
|
XP_TEXT("push_literal_constant"),
|
||||||
@ -94,11 +95,31 @@ static int __decode2 (xp_stx_t* stx,
|
|||||||
XP_TEXT("store_temporary_location")
|
XP_TEXT("store_temporary_location")
|
||||||
};
|
};
|
||||||
|
|
||||||
static const xp_char_t* send_opcode_names[] = {
|
static const xp_char_t* send_opcode_names[] =
|
||||||
|
{
|
||||||
XP_TEXT("send_to_self"),
|
XP_TEXT("send_to_self"),
|
||||||
XP_TEXT("send_to_super")
|
XP_TEXT("send_to_super")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const xp_char_t* stack_special_opcode_names[] =
|
||||||
|
{
|
||||||
|
XP_TEXT("store_pop_stack_top"),
|
||||||
|
XP_TEXT("duplicate_pop_stack_top"),
|
||||||
|
XP_TEXT("push_active_context"),
|
||||||
|
XP_TEXT("push_nil"),
|
||||||
|
XP_TEXT("push_true"),
|
||||||
|
XP_TEXT("push_false")
|
||||||
|
};
|
||||||
|
|
||||||
|
static const xp_char_t* return_opcode_names[] =
|
||||||
|
{
|
||||||
|
XP_TEXT("return_receiver"),
|
||||||
|
XP_TEXT("return_true"),
|
||||||
|
XP_TEXT("return_false"),
|
||||||
|
XP_TEXT("return_nil"),
|
||||||
|
XP_TEXT("return_from_message"),
|
||||||
|
XP_TEXT("return_from_block")
|
||||||
|
};
|
||||||
|
|
||||||
bytecodes = XP_STX_BYTE_OBJECT(stx, method_obj->bytecodes);
|
bytecodes = XP_STX_BYTE_OBJECT(stx, method_obj->bytecodes);
|
||||||
bytecode_size = XP_STX_SIZE(stx, method_obj->bytecodes);
|
bytecode_size = XP_STX_SIZE(stx, method_obj->bytecodes);
|
||||||
@ -117,6 +138,12 @@ static int __decode2 (xp_stx_t* stx,
|
|||||||
xp_printf (XP_TEXT("%s %d\n"),
|
xp_printf (XP_TEXT("%s %d\n"),
|
||||||
stack_opcode_names[code & 0x0F], next);
|
stack_opcode_names[code & 0x0F], next);
|
||||||
}
|
}
|
||||||
|
else if (code >= 0x67 && code <= 0x6C) {
|
||||||
|
/* stack special */
|
||||||
|
xp_printf (XP_TEXT("%s\n"),
|
||||||
|
stack_special_opcode_names[code - 0x67]);
|
||||||
|
}
|
||||||
|
|
||||||
else if (code >= 0x70 && code <= 0x71 ) {
|
else if (code >= 0x70 && code <= 0x71 ) {
|
||||||
/* send */
|
/* send */
|
||||||
next = bytecodes->data[pc++];
|
next = bytecodes->data[pc++];
|
||||||
@ -132,7 +159,8 @@ static int __decode2 (xp_stx_t* stx,
|
|||||||
|
|
||||||
}
|
}
|
||||||
else if (code >= 0x78 && code <= 0x7D) {
|
else if (code >= 0x78 && code <= 0x7D) {
|
||||||
// return
|
xp_printf (XP_TEXT("%s\n"),
|
||||||
|
return_opcode_names[code - 0x78]);
|
||||||
}
|
}
|
||||||
else if (code >= 0x80 && code <= 0x8F) {
|
else if (code >= 0x80 && code <= 0x8F) {
|
||||||
// jump
|
// jump
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: bytecode.h,v 1.7 2005-07-10 09:21:46 bacon Exp $
|
* $Id: bytecode.h,v 1.8 2005-08-11 16:16:04 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_STX_BYTECODE_H_
|
#ifndef _XP_STX_BYTECODE_H_
|
||||||
@ -20,9 +20,13 @@
|
|||||||
#define PUSH_LITERAL_VARIABLE_EXTENDED 0x63
|
#define PUSH_LITERAL_VARIABLE_EXTENDED 0x63
|
||||||
#define STORE_RECEIVER_VARIABLE_EXTENDED 0x64
|
#define STORE_RECEIVER_VARIABLE_EXTENDED 0x64
|
||||||
#define STORE_TEMPORARY_LOCATION_EXTENDED 0x65
|
#define STORE_TEMPORARY_LOCATION_EXTENDED 0x65
|
||||||
#define STORE_POP_STACK_TOP 0x68
|
|
||||||
#define DUPLICATE_POP_STACK_TOP 0x69
|
#define STORE_POP_STACK_TOP 0x67
|
||||||
#define PUSH_ACTIVE_CONTEXT 0x6A
|
#define DUPLICATE_POP_STACK_TOP 0x68
|
||||||
|
#define PUSH_ACTIVE_CONTEXT 0x69
|
||||||
|
#define PUSH_NIL 0x6A
|
||||||
|
#define PUSH_TRUE 0x6B
|
||||||
|
#define PUSH_FALSE 0x6C
|
||||||
|
|
||||||
#define SEND_TO_SELF 0x70
|
#define SEND_TO_SELF 0x70
|
||||||
#define SEND_TO_SUPER 0x71
|
#define SEND_TO_SUPER 0x71
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
SRCS = \
|
SRCS = \
|
||||||
stx.c memory.c object.c symbol.c class.c \
|
stx.c memory.c object.c symbol.c class.c \
|
||||||
dict.c misc.c context.c name.c token.c parser.c bootstrp.c
|
dict.c misc.c context.c name.c token.c parser.c bootstrp.c bytecode.c
|
||||||
OBJS = $(SRCS:.c=.obj)
|
OBJS = $(SRCS:.c=.obj)
|
||||||
OUT = xpstx.lib
|
OUT = xpstx.lib
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: parser.c,v 1.66 2005-08-11 11:18:30 bacon Exp $
|
* $Id: parser.c,v 1.67 2005-08-11 16:16:04 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/parser.h>
|
#include <xp/stx/parser.h>
|
||||||
@ -769,6 +769,7 @@ static int __parse_statements (xp_stx_parser_t* parser)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EMIT_RETURN_FROM_MESSAGE (parser);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -973,7 +974,8 @@ static int __parse_primary (xp_stx_parser_t* parser, const xp_char_t* ident)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (__parse_primary_ident(parser, parser->token.name.buffer) == -1) return -1;
|
/*if (__parse_primary_ident(parser, parser->token.name.buffer) == -1) return -1;*/
|
||||||
|
if (__parse_primary_ident(parser, ident) == -1) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -990,13 +992,19 @@ static int __parse_primary_ident (xp_stx_parser_t* parser, const xp_char_t* iden
|
|||||||
}
|
}
|
||||||
else if (xp_strcmp(token->name.buffer, XP_TEXT("super")) == 0) {
|
else if (xp_strcmp(token->name.buffer, XP_TEXT("super")) == 0) {
|
||||||
}
|
}
|
||||||
else if (xp_strcmp(token->name.buffer, XP_TEXT("nil")) == 0) {
|
|
||||||
}
|
|
||||||
else if (xp_strcmp(token->name.buffer, XP_TEXT("true")) == 0) {
|
|
||||||
}
|
|
||||||
else if (xp_strcmp(token->name.buffer, XP_TEXT("false")) == 0) {
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
if (xp_strcmp(ident, XP_TEXT("nil")) == 0) {
|
||||||
|
EMIT_CODE (parser, PUSH_NIL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (xp_strcmp(ident, XP_TEXT("true")) == 0) {
|
||||||
|
EMIT_CODE (parser, PUSH_TRUE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (xp_strcmp(ident, XP_TEXT("false")) == 0) {
|
||||||
|
EMIT_CODE (parser, PUSH_FALSE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Refer to __parse_assignment for identifier lookup */
|
/* Refer to __parse_assignment for identifier lookup */
|
||||||
|
|
||||||
|
@ -1,4 +1,2 @@
|
|||||||
main
|
main
|
||||||
< primitive: 16 >
|
^nil
|
||||||
^nil.
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user