From 1ce7078d5027d04566a1538c759ebd1f733f61c7 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sat, 21 May 2005 16:11:06 +0000 Subject: [PATCH] *** empty log message *** --- ase/stx/context.c | 44 +++++++++++++++++++++++++++----------------- ase/stx/context.h | 19 ++++++++++++++++++- ase/stx/hash.c | 4 ++-- 3 files changed, 47 insertions(+), 20 deletions(-) diff --git a/ase/stx/context.c b/ase/stx/context.c index 295dbb4c..8466befd 100644 --- a/ase/stx/context.c +++ b/ase/stx/context.c @@ -1,52 +1,62 @@ /* - * $Id: context.c,v 1.4 2005-05-19 16:41:10 bacon Exp $ + * $Id: context.c,v 1.5 2005-05-21 16:11:06 bacon Exp $ */ #include #include - -#define XP_STX_CONTEXT_SIZE 4 -#define XP_STX_CONTEXT_IP 0 -#define XP_STX_CONTEXT_METHOD 1 -#define XP_STX_CONTEXT_ARGUMENTS 2 -#define XP_STX_CONTEXT_TEMPORARIES 3 +#include xp_stx_word_t xp_stx_new_context (xp_stx_t* stx, xp_stx_word_t method, xp_stx_word_t args, xp_stx_word_t temp) { xp_stx_word_t context; + xp_stx_context_t* obj; context = xp_stx_alloc_object(stx,XP_STX_CONTEXT_SIZE); + /* XP_STX_CLASS(stx,context) = stx->class_context; XP_STX_AT(stx,context,XP_STX_CONTEXT_IP) = XP_STX_TO_SMALLINT(0); XP_STX_AT(stx,context,XP_STX_CONTEXT_METHOD) = method; XP_STX_AT(stx,context,XP_STX_CONTEXT_ARGUMENTS) = args; XP_STX_AT(stx,context,XP_STX_CONTEXT_TEMPORARIES) = temp; + */ + + obj = (xp_stx_context_t*)XP_STX_OBJECT(stx,context); + obj->header.class = stx->class_context; + obj->ip = XP_STX_TO_SMALLINT(0); + obj->method = method; + obj->arguments = args; + obj->temporaries = temp; return context; } -static xp_stx_byte_t __fetch_byte (xp_stx_t* stx, xp_stx_word_t context) +static xp_stx_byte_t __fetch_byte ( + xp_stx_t* stx, xp_stx_context_t* context_obj) { - xp_stx_word_t method, ip; + xp_stx_word_t ip, method; - ip = XP_STX_AT(stx,context,XP_STX_CONTEXT_IP); - method = XP_STX_AT(stx,context,XP_STX_CONTEXT_METHOD); + xp_stx_assert (XP_STX_IS_SMALLINT(context_obj->ip)); + ip = XP_STX_FROM_SMALLINT(context_obj->ip); + method = context_obj->method; /* increment instruction pointer */ - XP_STX_AT(stx,context,XP_STX_CONTEXT_IP) = - XP_STX_TO_SMALLINT((XP_STX_FROM_SMALLINT(ip) + 1)); + context_obj->ip = XP_STX_TO_SMALLINT(ip + 1); - return XP_STX_BYTEAT(stx,method,XP_STX_FROM_SMALLINT(ip)); + xp_stx_assert (XP_STX_TYPE(stx,method) == XP_STX_BYTE_INDEXED); + return XP_STX_BYTEAT(stx,method,ip); } int xp_stx_run_context (xp_stx_t* stx, xp_stx_word_t context) { xp_stx_byte_t byte, operand; + xp_stx_context_t* context_obj; + + context_obj = (xp_stx_context_t*)XP_STX_OBJECT(stx,context); while (!stx->__wantabort) { /* check_process_switch (); // hopefully */ - byte = __fetch_byte (stx, context); + byte = __fetch_byte (stx, context_obj); #ifdef _DOS printf (XP_TEXT("code: %x\n"), byte); @@ -56,10 +66,10 @@ xp_printf (XP_TEXT("code: %x\n"), byte); switch (byte) { case PUSH_OBJECT: - operand = __fetch_byte (stx, context); + operand = __fetch_byte (stx, context_obj); break; case SEND_UNARY_MESSAGE: - operand = __fetch_byte (stx, context); + operand = __fetch_byte (stx, context_obj); break; case HALT: goto exit_run_context; diff --git a/ase/stx/context.h b/ase/stx/context.h index bdfe9e68..e8626cbe 100644 --- a/ase/stx/context.h +++ b/ase/stx/context.h @@ -1,5 +1,5 @@ /* - * $Id: context.h,v 1.1 2005-05-15 18:37:00 bacon Exp $ + * $Id: context.h,v 1.2 2005-05-21 16:11:06 bacon Exp $ */ #ifndef _XP_STX_CONTEXT_H_ @@ -11,6 +11,23 @@ #define SEND_UNARY_MESSAGE 0xB0 #define HALT 0xFF +#define XP_STX_CONTEXT_SIZE 4 +#define XP_STX_CONTEXT_IP 0 +#define XP_STX_CONTEXT_METHOD 1 +#define XP_STX_CONTEXT_ARGUMENTS 2 +#define XP_STX_CONTEXT_TEMPORARIES 3 + +struct xp_stx_context_t +{ + xp_stx_objhdr_t header; + xp_stx_word_t ip; + xp_stx_word_t method; + xp_stx_word_t arguments; + xp_stx_word_t temporaries; +}; + +typedef struct xp_stx_context_t xp_stx_context_t; + #ifdef __cplusplus extern "C" { #endif diff --git a/ase/stx/hash.c b/ase/stx/hash.c index 02141fa0..876b4dfe 100644 --- a/ase/stx/hash.c +++ b/ase/stx/hash.c @@ -1,5 +1,5 @@ /* - * $Id: hash.c,v 1.14 2005-05-19 16:41:10 bacon Exp $ + * $Id: hash.c,v 1.15 2005-05-21 16:11:06 bacon Exp $ */ #include @@ -13,7 +13,7 @@ xp_stx_word_t xp_stx_new_pairlink ( x = xp_stx_alloc_object (stx, XP_STX_PAIRLINK_SIZE); XP_STX_CLASS(stx,x) = stx->class_pairlink; - /* XP_STX_AT(stx,x,XP_STX_PAIRLINK_LINK) = stx->nil; */ + XP_STX_AT(stx,x,XP_STX_PAIRLINK_LINK) = stx->nil; XP_STX_AT(stx,x,XP_STX_PAIRLINK_KEY) = key; XP_STX_AT(stx,x,XP_STX_PAIRLINK_VALUE) = value;