*** empty log message ***

This commit is contained in:
hyung-hwan 2005-05-21 16:11:06 +00:00
parent 70a5ead5cc
commit 1ce7078d50
3 changed files with 47 additions and 20 deletions

View File

@ -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 <xp/stx/context.h>
#include <xp/stx/object.h>
#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/misc.h>
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;

View File

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

View File

@ -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 <xp/stx/hash.h>
@ -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;