*** empty log message ***
This commit is contained in:
parent
cb4d9c6d70
commit
dc0fcaeeab
@ -1,18 +1,18 @@
|
||||
/*
|
||||
* $Id: array.c,v 1.1 2005-08-15 16:03:57 bacon Exp $
|
||||
* $Id: array.c,v 1.2 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/stx/array.h>
|
||||
#include <xp/stx/object.h>
|
||||
#include <xp/bas/assert.h>
|
||||
#include <ase/stx/array.h>
|
||||
#include <ase/stx/object.h>
|
||||
#include <ase/bas/assert.h>
|
||||
|
||||
xp_word_t xp_stx_new_array (xp_stx_t* stx, xp_word_t size)
|
||||
ase_word_t ase_stx_new_array (ase_stx_t* stx, ase_word_t size)
|
||||
{
|
||||
xp_word_t x;
|
||||
ase_word_t x;
|
||||
|
||||
xp_assert (stx->class_array != stx->nil);
|
||||
x = xp_stx_alloc_word_object (stx, XP_NULL, 0, XP_NULL, size);
|
||||
XP_STX_CLASS(stx,x) = stx->class_array;
|
||||
ase_assert (stx->class_array != stx->nil);
|
||||
x = ase_stx_alloc_word_object (stx, ASE_NULL, 0, ASE_NULL, size);
|
||||
ASE_STX_CLASS(stx,x) = stx->class_array;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
* $Id: array.h,v 1.3 2005-08-18 15:28:18 bacon Exp $
|
||||
* $Id: array.h,v 1.4 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_STX_ARRAY_H_
|
||||
#define _XP_STX_ARRAY_H_
|
||||
#ifndef _ASE_STX_ARRAY_H_
|
||||
#define _ASE_STX_ARRAY_H_
|
||||
|
||||
#include <xp/stx/stx.h>
|
||||
#include <ase/stx/stx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
xp_word_t xp_stx_new_array (xp_stx_t* stx, xp_word_t size);
|
||||
ase_word_t ase_stx_new_array (ase_stx_t* stx, ase_word_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,18 +1,18 @@
|
||||
/*
|
||||
* $Id: bootstrp.h,v 1.8 2005-08-18 15:28:18 bacon Exp $
|
||||
* $Id: bootstrp.h,v 1.9 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_STX_BOOTSTRP_H_
|
||||
#define _XP_STX_BOOTSTRP_H_
|
||||
#ifndef _ASE_STX_BOOTSTRP_H_
|
||||
#define _ASE_STX_BOOTSTRP_H_
|
||||
|
||||
#include <xp/stx/stx.h>
|
||||
#include <ase/stx/stx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
xp_word_t xp_stx_new_array (xp_stx_t* stx, xp_word_t size);
|
||||
int xp_stx_bootstrap (xp_stx_t* stx);
|
||||
ase_word_t ase_stx_new_array (ase_stx_t* stx, ase_word_t size);
|
||||
int ase_stx_bootstrap (ase_stx_t* stx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,178 +1,178 @@
|
||||
/*
|
||||
* $Id: bytecode.c,v 1.16 2005-10-02 15:45:09 bacon Exp $
|
||||
* $Id: bytecode.c,v 1.17 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
#include <xp/stx/bytecode.h>
|
||||
#include <xp/stx/class.h>
|
||||
#include <xp/stx/method.h>
|
||||
#include <xp/stx/dict.h>
|
||||
#include <ase/stx/bytecode.h>
|
||||
#include <ase/stx/class.h>
|
||||
#include <ase/stx/method.h>
|
||||
#include <ase/stx/dict.h>
|
||||
|
||||
static void __decode1 (xp_stx_t* stx, xp_word_t idx, void* data);
|
||||
static int __decode2 (xp_stx_t* stx,
|
||||
xp_stx_class_t* class_obj, xp_stx_method_t* method_obj);
|
||||
static void __decode1 (ase_stx_t* stx, ase_word_t idx, void* data);
|
||||
static int __decode2 (ase_stx_t* stx,
|
||||
ase_stx_class_t* class_obj, ase_stx_method_t* method_obj);
|
||||
|
||||
int xp_stx_decode (xp_stx_t* stx, xp_word_t class)
|
||||
int ase_stx_decode (ase_stx_t* stx, ase_word_t class)
|
||||
{
|
||||
xp_stx_class_t* class_obj;
|
||||
ase_stx_class_t* class_obj;
|
||||
|
||||
class_obj = (xp_stx_class_t*)XP_STX_OBJECT(stx, class);
|
||||
class_obj = (ase_stx_class_t*)ASE_STX_OBJECT(stx, class);
|
||||
if (class_obj->methods == stx->nil) return 0;
|
||||
|
||||
/* TODO */
|
||||
xp_stx_dict_traverse (stx, class_obj->methods, __decode1, class_obj);
|
||||
ase_stx_dict_traverse (stx, class_obj->methods, __decode1, class_obj);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <xp/bas/stdio.h>
|
||||
static void __dump_object (xp_stx_t* stx, xp_word_t obj)
|
||||
#include <ase/bas/stdio.h>
|
||||
static void __dump_object (ase_stx_t* stx, ase_word_t obj)
|
||||
{
|
||||
if (XP_STX_IS_SMALLINT(obj)) {
|
||||
xp_printf (XP_TEXT("%d"), XP_STX_FROM_SMALLINT(obj));
|
||||
if (ASE_STX_IS_SMALLINT(obj)) {
|
||||
ase_printf (ASE_T("%d"), ASE_STX_FROM_SMALLINT(obj));
|
||||
}
|
||||
else if (XP_STX_CLASS(stx,obj) == stx->class_character) {
|
||||
xp_printf (XP_TEXT("$%c"), XP_STX_WORD_AT(stx,obj,0));
|
||||
else if (ASE_STX_CLASS(stx,obj) == stx->class_character) {
|
||||
ase_printf (ASE_T("$%c"), ASE_STX_WORD_AT(stx,obj,0));
|
||||
}
|
||||
else if (XP_STX_CLASS(stx,obj) == stx->class_string) {
|
||||
xp_printf (XP_TEXT("'%s'"), XP_STX_DATA(stx,obj));
|
||||
else if (ASE_STX_CLASS(stx,obj) == stx->class_string) {
|
||||
ase_printf (ASE_T("'%s'"), ASE_STX_DATA(stx,obj));
|
||||
}
|
||||
else if (XP_STX_CLASS(stx,obj) == stx->class_symbol) {
|
||||
xp_printf (XP_TEXT("#%s"), XP_STX_DATA(stx,obj));
|
||||
else if (ASE_STX_CLASS(stx,obj) == stx->class_symbol) {
|
||||
ase_printf (ASE_T("#%s"), ASE_STX_DATA(stx,obj));
|
||||
}
|
||||
else if (XP_STX_IS_CHAR_OBJECT(stx, obj)) {
|
||||
xp_printf (XP_TEXT("unknow char object [%s]"), XP_STX_DATA(stx,obj));
|
||||
else if (ASE_STX_IS_CHAR_OBJECT(stx, obj)) {
|
||||
ase_printf (ASE_T("unknow char object [%s]"), ASE_STX_DATA(stx,obj));
|
||||
}
|
||||
else if (XP_STX_IS_BYTE_OBJECT(stx, obj)) {
|
||||
xp_printf (XP_TEXT("unknown byte object"), XP_STX_DATA(stx,obj));
|
||||
else if (ASE_STX_IS_BYTE_OBJECT(stx, obj)) {
|
||||
ase_printf (ASE_T("unknown byte object"), ASE_STX_DATA(stx,obj));
|
||||
}
|
||||
else if (XP_STX_IS_WORD_OBJECT(stx, obj)) {
|
||||
xp_printf (XP_TEXT("unknown word object"), XP_STX_DATA(stx,obj));
|
||||
else if (ASE_STX_IS_WORD_OBJECT(stx, obj)) {
|
||||
ase_printf (ASE_T("unknown word object"), ASE_STX_DATA(stx,obj));
|
||||
}
|
||||
else {
|
||||
xp_printf (XP_TEXT("invalid object type"));
|
||||
ase_printf (ASE_T("invalid object type"));
|
||||
}
|
||||
}
|
||||
|
||||
static void __decode1 (xp_stx_t* stx, xp_word_t idx, void* data)
|
||||
static void __decode1 (ase_stx_t* stx, ase_word_t idx, void* data)
|
||||
{
|
||||
xp_stx_method_t* method_obj;
|
||||
xp_stx_class_t* class_obj;
|
||||
xp_word_t key = XP_STX_WORD_AT(stx,idx,XP_STX_ASSOCIATION_KEY);
|
||||
xp_word_t value = XP_STX_WORD_AT(stx,idx,XP_STX_ASSOCIATION_VALUE);
|
||||
xp_word_t* literals;
|
||||
xp_word_t literal_count, i;
|
||||
ase_stx_method_t* method_obj;
|
||||
ase_stx_class_t* class_obj;
|
||||
ase_word_t key = ASE_STX_WORD_AT(stx,idx,ASE_STX_ASSOCIATION_KEY);
|
||||
ase_word_t value = ASE_STX_WORD_AT(stx,idx,ASE_STX_ASSOCIATION_VALUE);
|
||||
ase_word_t* literals;
|
||||
ase_word_t literal_count, i;
|
||||
|
||||
xp_word_t method_class;
|
||||
xp_stx_class_t* method_class_obj;
|
||||
ase_word_t method_class;
|
||||
ase_stx_class_t* method_class_obj;
|
||||
|
||||
class_obj = (xp_stx_class_t*)data;
|
||||
class_obj = (ase_stx_class_t*)data;
|
||||
|
||||
xp_printf (XP_TEXT("* Method: %s\n"), XP_STX_DATA(stx, key));
|
||||
method_obj = (xp_stx_method_t*)XP_STX_OBJECT(stx, value);
|
||||
ase_printf (ASE_T("* Method: %s\n"), ASE_STX_DATA(stx, key));
|
||||
method_obj = (ase_stx_method_t*)ASE_STX_OBJECT(stx, value);
|
||||
|
||||
literals = method_obj->literals;
|
||||
/*
|
||||
literal_count = XP_STX_SIZE(stx, value) -
|
||||
(XP_STX_FROM_SMALLINT(class_obj->spec) >> XP_STX_SPEC_INDEXABLE_BITS);
|
||||
literal_count = ASE_STX_SIZE(stx, value) -
|
||||
(ASE_STX_FROM_SMALLINT(class_obj->spec) >> ASE_STX_SPEC_INDEXABLE_BITS);
|
||||
*/
|
||||
method_class = XP_STX_CLASS(stx,value);
|
||||
method_class_obj = XP_STX_OBJECT(stx, method_class);
|
||||
literal_count = XP_STX_SIZE(stx,value) -
|
||||
(XP_STX_FROM_SMALLINT(method_class_obj->spec) >> XP_STX_SPEC_INDEXABLE_BITS);
|
||||
method_class = ASE_STX_CLASS(stx,value);
|
||||
method_class_obj = ASE_STX_OBJECT(stx, method_class);
|
||||
literal_count = ASE_STX_SIZE(stx,value) -
|
||||
(ASE_STX_FROM_SMALLINT(method_class_obj->spec) >> ASE_STX_SPEC_INDEXABLE_BITS);
|
||||
|
||||
xp_printf (XP_TEXT("* Literal Count: %d, Temporary Count: %d, Argument Count: %d\n"),
|
||||
ase_printf (ASE_T("* Literal Count: %d, Temporary Count: %d, Argument Count: %d\n"),
|
||||
literal_count,
|
||||
XP_STX_FROM_SMALLINT(method_obj->tmpcount),
|
||||
XP_STX_FROM_SMALLINT(method_obj->argcount));
|
||||
ASE_STX_FROM_SMALLINT(method_obj->tmpcount),
|
||||
ASE_STX_FROM_SMALLINT(method_obj->argcount));
|
||||
for (i = 0; i < literal_count; i++) {
|
||||
xp_printf (XP_TEXT("%d. ["), i);
|
||||
ase_printf (ASE_T("%d. ["), i);
|
||||
__dump_object (stx, literals[i]);
|
||||
xp_printf (XP_TEXT("]\n"));
|
||||
ase_printf (ASE_T("]\n"));
|
||||
}
|
||||
__decode2 (stx, data, method_obj);
|
||||
}
|
||||
|
||||
static int __decode2 (xp_stx_t* stx,
|
||||
xp_stx_class_t* class_obj, xp_stx_method_t* method_obj)
|
||||
static int __decode2 (ase_stx_t* stx,
|
||||
ase_stx_class_t* class_obj, ase_stx_method_t* method_obj)
|
||||
{
|
||||
xp_stx_byte_object_t* bytecodes;
|
||||
xp_word_t bytecode_size, pc = 0;
|
||||
ase_stx_byte_object_t* bytecodes;
|
||||
ase_word_t bytecode_size, pc = 0;
|
||||
int code, next, next2;
|
||||
|
||||
static const xp_char_t* stack_opcode_names[] =
|
||||
static const ase_char_t* stack_opcode_names[] =
|
||||
{
|
||||
XP_TEXT("push_receiver_variable"),
|
||||
XP_TEXT("push_temporary_location"),
|
||||
XP_TEXT("push_literal_constant"),
|
||||
XP_TEXT("push_literal_variable"),
|
||||
XP_TEXT("store_receiver_variable"),
|
||||
XP_TEXT("store_temporary_location")
|
||||
ASE_T("push_receiver_variable"),
|
||||
ASE_T("push_temporary_location"),
|
||||
ASE_T("push_literal_constant"),
|
||||
ASE_T("push_literal_variable"),
|
||||
ASE_T("store_receiver_variable"),
|
||||
ASE_T("store_temporary_location")
|
||||
};
|
||||
|
||||
static const xp_char_t* send_opcode_names[] =
|
||||
static const ase_char_t* send_opcode_names[] =
|
||||
{
|
||||
XP_TEXT("send_to_self"),
|
||||
XP_TEXT("send_to_super")
|
||||
ASE_T("send_to_self"),
|
||||
ASE_T("send_to_super")
|
||||
};
|
||||
|
||||
static const xp_char_t* stack_special_opcode_names[] =
|
||||
static const ase_char_t* stack_special_opcode_names[] =
|
||||
{
|
||||
XP_TEXT("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"),
|
||||
XP_TEXT("push_receiver")
|
||||
ASE_T("pop_stack_top"),
|
||||
ASE_T("duplicate_pop_stack_top"),
|
||||
ASE_T("push_active_context"),
|
||||
ASE_T("push_nil"),
|
||||
ASE_T("push_true"),
|
||||
ASE_T("push_false"),
|
||||
ASE_T("push_receiver")
|
||||
};
|
||||
|
||||
static const xp_char_t* return_opcode_names[] =
|
||||
static const ase_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")
|
||||
ASE_T("return_receiver"),
|
||||
ASE_T("return_true"),
|
||||
ASE_T("return_false"),
|
||||
ASE_T("return_nil"),
|
||||
ASE_T("return_from_message"),
|
||||
ASE_T("return_from_block")
|
||||
};
|
||||
|
||||
bytecodes = XP_STX_BYTE_OBJECT(stx, method_obj->bytecodes);
|
||||
bytecode_size = XP_STX_SIZE(stx, method_obj->bytecodes);
|
||||
bytecodes = ASE_STX_BYTE_OBJECT(stx, method_obj->bytecodes);
|
||||
bytecode_size = ASE_STX_SIZE(stx, method_obj->bytecodes);
|
||||
|
||||
while (pc < bytecode_size) {
|
||||
code = bytecodes->data[pc++];
|
||||
|
||||
if (code >= 0x00 && code <= 0x5F) {
|
||||
/* stack */
|
||||
xp_printf (XP_TEXT("%s %d\n"),
|
||||
ase_printf (ASE_T("%s %d\n"),
|
||||
stack_opcode_names[code >> 4], code & 0x0F);
|
||||
}
|
||||
else if (code >= 0x60 && code <= 0x65) {
|
||||
/* stack extended */
|
||||
next = bytecodes->data[pc++];
|
||||
xp_printf (XP_TEXT("%s %d\n"),
|
||||
ase_printf (ASE_T("%s %d\n"),
|
||||
stack_opcode_names[code & 0x0F], next);
|
||||
}
|
||||
else if (code >= 0x67 && code <= 0x6D) {
|
||||
/* stack special */
|
||||
xp_printf (XP_TEXT("%s\n"),
|
||||
ase_printf (ASE_T("%s\n"),
|
||||
stack_special_opcode_names[code - 0x67]);
|
||||
}
|
||||
|
||||
else if (code >= 0x70 && code <= 0x71 ) {
|
||||
/* send message */
|
||||
next = bytecodes->data[pc++];
|
||||
xp_printf (XP_TEXT("%s nargs(%d) selector(%d)\n"),
|
||||
ase_printf (ASE_T("%s nargs(%d) selector(%d)\n"),
|
||||
send_opcode_names[code - 0x70], next >> 5, next & 0x1F);
|
||||
}
|
||||
else if (code >= 0x72 && code <= 0x73 ) {
|
||||
/* send message extended */
|
||||
next = bytecodes->data[pc++];
|
||||
next2 = bytecodes->data[pc++];
|
||||
xp_printf (XP_TEXT("%s %d %d\n"),
|
||||
ase_printf (ASE_T("%s %d %d\n"),
|
||||
send_opcode_names[code - 0x72], next, next2);
|
||||
|
||||
}
|
||||
else if (code >= 0x78 && code <= 0x7D) {
|
||||
xp_printf (XP_TEXT("%s\n"),
|
||||
ase_printf (ASE_T("%s\n"),
|
||||
return_opcode_names[code - 0x78]);
|
||||
}
|
||||
else if (code >= 0x80 && code <= 0x8F) {
|
||||
@ -181,11 +181,11 @@ static int __decode2 (xp_stx_t* stx,
|
||||
else if (code >= 0xF0 && code <= 0xFF) {
|
||||
// primitive
|
||||
next = bytecodes->data[pc++];
|
||||
xp_printf (XP_TEXT("do_primitive %d\n"), ((code & 0x0F) << 8) | next);
|
||||
ase_printf (ASE_T("do_primitive %d\n"), ((code & 0x0F) << 8) | next);
|
||||
|
||||
}
|
||||
else {
|
||||
xp_printf (XP_TEXT("unknown byte code 0x%x\n"), code);
|
||||
ase_printf (ASE_T("unknown byte code 0x%x\n"), code);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
* $Id: bytecode.h,v 1.12 2005-10-02 15:45:09 bacon Exp $
|
||||
* $Id: bytecode.h,v 1.13 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_STX_BYTECODE_H_
|
||||
#define _XP_STX_BYTECODE_H_
|
||||
#ifndef _ASE_STX_BYTECODE_H_
|
||||
#define _ASE_STX_BYTECODE_H_
|
||||
|
||||
#include <xp/stx/stx.h>
|
||||
#include <ase/stx/stx.h>
|
||||
|
||||
#define PUSH_RECEIVER_VARIABLE 0x00
|
||||
#define PUSH_TEMPORARY_LOCATION 0x10
|
||||
@ -47,7 +47,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int xp_stx_decode (xp_stx_t* stx, xp_word_t class_idx);
|
||||
int ase_stx_decode (ase_stx_t* stx, ase_word_t class_idx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
132
ase/stx/class.c
132
ase/stx/class.c
@ -1,66 +1,66 @@
|
||||
/*
|
||||
* $Id: class.c,v 1.27 2005-10-02 15:45:09 bacon Exp $
|
||||
* $Id: class.c,v 1.28 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/stx/class.h>
|
||||
#include <xp/stx/symbol.h>
|
||||
#include <xp/stx/object.h>
|
||||
#include <xp/stx/dict.h>
|
||||
#include <xp/stx/misc.h>
|
||||
#include <ase/stx/class.h>
|
||||
#include <ase/stx/symbol.h>
|
||||
#include <ase/stx/object.h>
|
||||
#include <ase/stx/dict.h>
|
||||
#include <ase/stx/misc.h>
|
||||
|
||||
xp_word_t xp_stx_new_class (xp_stx_t* stx, const xp_char_t* name)
|
||||
ase_word_t ase_stx_new_class (ase_stx_t* stx, const ase_char_t* name)
|
||||
{
|
||||
xp_word_t meta, class;
|
||||
xp_word_t class_name;
|
||||
ase_word_t meta, class;
|
||||
ase_word_t class_name;
|
||||
|
||||
meta = xp_stx_alloc_word_object (
|
||||
stx, XP_NULL, XP_STX_METACLASS_SIZE, XP_NULL, 0);
|
||||
XP_STX_CLASS(stx,meta) = stx->class_metaclass;
|
||||
meta = ase_stx_alloc_word_object (
|
||||
stx, ASE_NULL, ASE_STX_METACLASS_SIZE, ASE_NULL, 0);
|
||||
ASE_STX_CLASS(stx,meta) = stx->class_metaclass;
|
||||
/* the spec of the metaclass must be the spec of its
|
||||
* instance. so the XP_STX_CLASS_SIZE is set */
|
||||
XP_STX_WORD_AT(stx,meta,XP_STX_METACLASS_SPEC) =
|
||||
XP_STX_TO_SMALLINT((XP_STX_CLASS_SIZE << XP_STX_SPEC_INDEXABLE_BITS) | XP_STX_SPEC_NOT_INDEXABLE);
|
||||
* instance. so the ASE_STX_CLASS_SIZE is set */
|
||||
ASE_STX_WORD_AT(stx,meta,ASE_STX_METACLASS_SPEC) =
|
||||
ASE_STX_TO_SMALLINT((ASE_STX_CLASS_SIZE << ASE_STX_SPEC_INDEXABLE_BITS) | ASE_STX_SPEC_NOT_INDEXABLE);
|
||||
|
||||
/* the spec of the class is set later in __create_builtin_classes */
|
||||
class = xp_stx_alloc_word_object (
|
||||
stx, XP_NULL, XP_STX_CLASS_SIZE, XP_NULL, 0);
|
||||
XP_STX_CLASS(stx,class) = meta;
|
||||
class_name = xp_stx_new_symbol (stx, name);
|
||||
XP_STX_WORD_AT(stx,class,XP_STX_CLASS_NAME) = class_name;
|
||||
class = ase_stx_alloc_word_object (
|
||||
stx, ASE_NULL, ASE_STX_CLASS_SIZE, ASE_NULL, 0);
|
||||
ASE_STX_CLASS(stx,class) = meta;
|
||||
class_name = ase_stx_new_symbol (stx, name);
|
||||
ASE_STX_WORD_AT(stx,class,ASE_STX_CLASS_NAME) = class_name;
|
||||
|
||||
xp_stx_dict_put (stx, stx->smalltalk, class_name, class);
|
||||
ase_stx_dict_put (stx, stx->smalltalk, class_name, class);
|
||||
return class;
|
||||
}
|
||||
|
||||
xp_word_t xp_stx_lookup_class (xp_stx_t* stx, const xp_char_t* name)
|
||||
ase_word_t ase_stx_lookup_class (ase_stx_t* stx, const ase_char_t* name)
|
||||
{
|
||||
xp_word_t assoc, meta, value;
|
||||
ase_word_t assoc, meta, value;
|
||||
|
||||
assoc = xp_stx_dict_lookup (stx, stx->smalltalk, name);
|
||||
assoc = ase_stx_dict_lookup (stx, stx->smalltalk, name);
|
||||
if (assoc == stx->nil) {
|
||||
return stx->nil;
|
||||
}
|
||||
|
||||
value = XP_STX_WORD_AT(stx,assoc,XP_STX_ASSOCIATION_VALUE);
|
||||
meta = XP_STX_CLASS(stx,value);
|
||||
if (XP_STX_CLASS(stx,meta) != stx->class_metaclass) return stx->nil;
|
||||
value = ASE_STX_WORD_AT(stx,assoc,ASE_STX_ASSOCIATION_VALUE);
|
||||
meta = ASE_STX_CLASS(stx,value);
|
||||
if (ASE_STX_CLASS(stx,meta) != stx->class_metaclass) return stx->nil;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
int xp_stx_get_instance_variable_index (
|
||||
xp_stx_t* stx, xp_word_t class_index,
|
||||
const xp_char_t* name, xp_word_t* index)
|
||||
int ase_stx_get_instance_variable_index (
|
||||
ase_stx_t* stx, ase_word_t class_index,
|
||||
const ase_char_t* name, ase_word_t* index)
|
||||
{
|
||||
xp_word_t index_super = 0;
|
||||
xp_stx_class_t* class_obj;
|
||||
xp_stx_char_object_t* string;
|
||||
ase_word_t index_super = 0;
|
||||
ase_stx_class_t* class_obj;
|
||||
ase_stx_char_object_t* string;
|
||||
|
||||
class_obj = (xp_stx_class_t*)XP_STX_OBJECT(stx, class_index);
|
||||
xp_assert (class_obj != XP_NULL);
|
||||
class_obj = (ase_stx_class_t*)ASE_STX_OBJECT(stx, class_index);
|
||||
ase_assert (class_obj != ASE_NULL);
|
||||
|
||||
if (class_obj->superclass != stx->nil) {
|
||||
if (xp_stx_get_instance_variable_index (
|
||||
if (ase_stx_get_instance_variable_index (
|
||||
stx, class_obj->superclass, name, &index_super) == 0) {
|
||||
*index = index_super;
|
||||
return 0;
|
||||
@ -75,8 +75,8 @@ int xp_stx_get_instance_variable_index (
|
||||
else {
|
||||
if (class_obj->variables == stx->nil) *index = 0;
|
||||
else {
|
||||
string = XP_STX_CHAR_OBJECT(stx, class_obj->variables);
|
||||
if (xp_stx_strword(string->data, name, index) != XP_NULL) {
|
||||
string = ASE_STX_CHAR_OBJECT(stx, class_obj->variables);
|
||||
if (ase_stx_strword(string->data, name, index) != ASE_NULL) {
|
||||
*index += index_super;
|
||||
return 0;
|
||||
}
|
||||
@ -88,17 +88,17 @@ int xp_stx_get_instance_variable_index (
|
||||
return -1;
|
||||
}
|
||||
|
||||
xp_word_t xp_stx_lookup_class_variable (
|
||||
xp_stx_t* stx, xp_word_t class_index, const xp_char_t* name)
|
||||
ase_word_t ase_stx_lookup_class_variable (
|
||||
ase_stx_t* stx, ase_word_t class_index, const ase_char_t* name)
|
||||
{
|
||||
xp_stx_class_t* class_obj;
|
||||
ase_stx_class_t* class_obj;
|
||||
|
||||
class_obj = (xp_stx_class_t*)XP_STX_OBJECT(stx, class_index);
|
||||
xp_assert (class_obj != XP_NULL);
|
||||
class_obj = (ase_stx_class_t*)ASE_STX_OBJECT(stx, class_index);
|
||||
ase_assert (class_obj != ASE_NULL);
|
||||
|
||||
if (class_obj->superclass != stx->nil) {
|
||||
xp_word_t tmp;
|
||||
tmp = xp_stx_lookup_class_variable (
|
||||
ase_word_t tmp;
|
||||
tmp = ase_stx_lookup_class_variable (
|
||||
stx, class_obj->superclass, name);
|
||||
if (tmp != stx->nil) return tmp;
|
||||
}
|
||||
@ -106,57 +106,57 @@ xp_word_t xp_stx_lookup_class_variable (
|
||||
/* TODO: can a metaclas have class variables? */
|
||||
if (class_obj->header.class != stx->class_metaclass &&
|
||||
class_obj->class_variables != stx->nil) {
|
||||
if (xp_stx_dict_lookup(stx,
|
||||
if (ase_stx_dict_lookup(stx,
|
||||
class_obj->class_variables,name) != stx->nil) return class_index;
|
||||
}
|
||||
|
||||
return stx->nil;
|
||||
}
|
||||
|
||||
xp_word_t xp_stx_lookup_method (xp_stx_t* stx,
|
||||
xp_word_t class_index, const xp_char_t* name, xp_bool_t from_super)
|
||||
ase_word_t ase_stx_lookup_method (ase_stx_t* stx,
|
||||
ase_word_t class_index, const ase_char_t* name, ase_bool_t from_super)
|
||||
{
|
||||
xp_stx_class_t* class_obj;
|
||||
ase_stx_class_t* class_obj;
|
||||
|
||||
class_obj = (xp_stx_class_t*)XP_STX_OBJECT(stx, class_index);
|
||||
xp_assert (class_obj != XP_NULL);
|
||||
class_obj = (ase_stx_class_t*)ASE_STX_OBJECT(stx, class_index);
|
||||
ase_assert (class_obj != ASE_NULL);
|
||||
|
||||
#if 0
|
||||
if (class_obj->header.class != stx->class_metaclass &&
|
||||
class_obj->methods != stx->nil) {
|
||||
xp_word_t assoc;
|
||||
assoc = xp_stx_dict_lookup(stx, class_obj->methods, name);
|
||||
ase_word_t assoc;
|
||||
assoc = ase_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);
|
||||
ase_assert (ASE_STX_CLASS(stx,assoc) == stx->class_association);
|
||||
return ASE_STX_WORD_AT(stx, assoc, ASE_STX_ASSOCIATION_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
if (class_obj->superclass != stx->nil) {
|
||||
xp_word_t tmp;
|
||||
tmp = xp_stx_lookup_method (
|
||||
ase_word_t tmp;
|
||||
tmp = ase_stx_lookup_method (
|
||||
stx, class_obj->superclass, name);
|
||||
if (tmp != stx->nil) return tmp;
|
||||
}
|
||||
#endif
|
||||
|
||||
while (class_index != stx->nil) {
|
||||
class_obj = (xp_stx_class_t*)XP_STX_OBJECT(stx, class_index);
|
||||
class_obj = (ase_stx_class_t*)ASE_STX_OBJECT(stx, class_index);
|
||||
|
||||
xp_assert (class_obj != XP_NULL);
|
||||
xp_assert (
|
||||
ase_assert (class_obj != ASE_NULL);
|
||||
ase_assert (
|
||||
class_obj->header.class == stx->class_metaclass ||
|
||||
XP_STX_CLASS(stx,class_obj->header.class) == stx->class_metaclass);
|
||||
ASE_STX_CLASS(stx,class_obj->header.class) == stx->class_metaclass);
|
||||
|
||||
if (from_super) {
|
||||
from_super = xp_false;
|
||||
from_super = ase_false;
|
||||
}
|
||||
else if (class_obj->methods != stx->nil) {
|
||||
xp_word_t assoc;
|
||||
assoc = xp_stx_dict_lookup(stx, class_obj->methods, name);
|
||||
ase_word_t assoc;
|
||||
assoc = ase_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);
|
||||
ase_assert (ASE_STX_CLASS(stx,assoc) == stx->class_association);
|
||||
return ASE_STX_WORD_AT(stx, assoc, ASE_STX_ASSOCIATION_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
106
ase/stx/class.h
106
ase/stx/class.h
@ -1,78 +1,78 @@
|
||||
/*
|
||||
* $Id: class.h,v 1.15 2005-10-02 15:45:09 bacon Exp $
|
||||
* $Id: class.h,v 1.16 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_STX_CLASS_H_
|
||||
#define _XP_STX_CLASS_H_
|
||||
#ifndef _ASE_STX_CLASS_H_
|
||||
#define _ASE_STX_CLASS_H_
|
||||
|
||||
#include <xp/stx/stx.h>
|
||||
#include <ase/stx/stx.h>
|
||||
|
||||
/* definitions for common objects */
|
||||
#define XP_STX_CLASS_SIZE 8
|
||||
#define XP_STX_CLASS_SPEC 0
|
||||
#define XP_STX_CLASS_METHODS 1
|
||||
#define XP_STX_CLASS_SUPERCLASS 2
|
||||
#define XP_STX_CLASS_SUBCLASSES 3
|
||||
#define XP_STX_CLASS_NAME 4
|
||||
#define XP_STX_CLASS_VARIABLES 5
|
||||
#define XP_STX_CLASS_CLASS_VARIABLES 6
|
||||
#define XP_STX_CLASS_POOL_DICTIONARIES 7
|
||||
#define ASE_STX_CLASS_SIZE 8
|
||||
#define ASE_STX_CLASS_SPEC 0
|
||||
#define ASE_STX_CLASS_METHODS 1
|
||||
#define ASE_STX_CLASS_SUPERCLASS 2
|
||||
#define ASE_STX_CLASS_SUBCLASSES 3
|
||||
#define ASE_STX_CLASS_NAME 4
|
||||
#define ASE_STX_CLASS_VARIABLES 5
|
||||
#define ASE_STX_CLASS_CLASS_VARIABLES 6
|
||||
#define ASE_STX_CLASS_POOL_DICTIONARIES 7
|
||||
|
||||
#define XP_STX_METACLASS_SIZE 5
|
||||
#define XP_STX_METACLASS_SPEC 0
|
||||
#define XP_STX_METACLASS_METHODS 1
|
||||
#define XP_STX_METACLASS_SUPERCLASS 2
|
||||
#define XP_STX_METACLASS_SUBCLASSES 3
|
||||
#define XP_STX_METACLASS_INSTANCE_CLASS 4
|
||||
#define ASE_STX_METACLASS_SIZE 5
|
||||
#define ASE_STX_METACLASS_SPEC 0
|
||||
#define ASE_STX_METACLASS_METHODS 1
|
||||
#define ASE_STX_METACLASS_SUPERCLASS 2
|
||||
#define ASE_STX_METACLASS_SUBCLASSES 3
|
||||
#define ASE_STX_METACLASS_INSTANCE_CLASS 4
|
||||
|
||||
#define XP_STX_SPEC_INDEXABLE_BITS 2
|
||||
#define XP_STX_SPEC_INDEXABLE_MASK 3
|
||||
#define XP_STX_SPEC_NOT_INDEXABLE 0
|
||||
#define XP_STX_SPEC_WORD_INDEXABLE 1
|
||||
#define XP_STX_SPEC_BYTE_INDEXABLE 2
|
||||
#define XP_STX_SPEC_CHAR_INDEXABLE 3
|
||||
#define ASE_STX_SPEC_INDEXABLE_BITS 2
|
||||
#define ASE_STX_SPEC_INDEXABLE_MASK 3
|
||||
#define ASE_STX_SPEC_NOT_INDEXABLE 0
|
||||
#define ASE_STX_SPEC_WORD_INDEXABLE 1
|
||||
#define ASE_STX_SPEC_BYTE_INDEXABLE 2
|
||||
#define ASE_STX_SPEC_CHAR_INDEXABLE 3
|
||||
|
||||
struct xp_stx_class_t
|
||||
struct ase_stx_class_t
|
||||
{
|
||||
xp_stx_objhdr_t header;
|
||||
xp_word_t spec; /* indexable: 2, nfields: the rest */
|
||||
xp_word_t methods;
|
||||
xp_word_t superclass;
|
||||
xp_word_t subclasses;
|
||||
xp_word_t name;
|
||||
xp_word_t variables;
|
||||
xp_word_t class_variables;
|
||||
xp_word_t pool_dictonaries;
|
||||
ase_stx_objhdr_t header;
|
||||
ase_word_t spec; /* indexable: 2, nfields: the rest */
|
||||
ase_word_t methods;
|
||||
ase_word_t superclass;
|
||||
ase_word_t subclasses;
|
||||
ase_word_t name;
|
||||
ase_word_t variables;
|
||||
ase_word_t class_variables;
|
||||
ase_word_t pool_dictonaries;
|
||||
};
|
||||
|
||||
struct xp_stx_metaclass_t
|
||||
struct ase_stx_metaclass_t
|
||||
{
|
||||
xp_stx_objhdr_t header;
|
||||
xp_word_t spec;
|
||||
xp_word_t methods;
|
||||
xp_word_t superclass;
|
||||
xp_word_t subclasses;
|
||||
xp_word_t instance_class;
|
||||
ase_stx_objhdr_t header;
|
||||
ase_word_t spec;
|
||||
ase_word_t methods;
|
||||
ase_word_t superclass;
|
||||
ase_word_t subclasses;
|
||||
ase_word_t instance_class;
|
||||
};
|
||||
|
||||
typedef struct xp_stx_class_t xp_stx_class_t;
|
||||
typedef struct xp_stx_metaclass_t xp_stx_metaclass_t;
|
||||
typedef struct ase_stx_class_t ase_stx_class_t;
|
||||
typedef struct ase_stx_metaclass_t ase_stx_metaclass_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
xp_word_t xp_stx_new_class (xp_stx_t* stx, const xp_char_t* name);
|
||||
xp_word_t xp_stx_lookup_class (xp_stx_t* stx, const xp_char_t* name);
|
||||
ase_word_t ase_stx_new_class (ase_stx_t* stx, const ase_char_t* name);
|
||||
ase_word_t ase_stx_lookup_class (ase_stx_t* stx, const ase_char_t* name);
|
||||
|
||||
int xp_stx_get_instance_variable_index (
|
||||
xp_stx_t* stx, xp_word_t class_index,
|
||||
const xp_char_t* name, xp_word_t* index);
|
||||
int ase_stx_get_instance_variable_index (
|
||||
ase_stx_t* stx, ase_word_t class_index,
|
||||
const ase_char_t* name, ase_word_t* index);
|
||||
|
||||
xp_word_t xp_stx_lookup_class_variable (
|
||||
xp_stx_t* stx, xp_word_t class_index, const xp_char_t* name);
|
||||
xp_word_t xp_stx_lookup_method (xp_stx_t* stx,
|
||||
xp_word_t class_index, const xp_char_t* name, xp_bool_t from_super);
|
||||
ase_word_t ase_stx_lookup_class_variable (
|
||||
ase_stx_t* stx, ase_word_t class_index, const ase_char_t* name);
|
||||
ase_word_t ase_stx_lookup_method (ase_stx_t* stx,
|
||||
ase_word_t class_index, const ase_char_t* name, ase_bool_t from_super);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,23 +1,23 @@
|
||||
/*
|
||||
* $Id: context.c,v 1.11 2005-07-19 12:08:04 bacon Exp $
|
||||
* $Id: context.c,v 1.12 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/stx/context.h>
|
||||
#include <xp/stx/object.h>
|
||||
#include <xp/stx/class.h>
|
||||
#include <xp/stx/misc.h>
|
||||
#include <ase/stx/context.h>
|
||||
#include <ase/stx/object.h>
|
||||
#include <ase/stx/class.h>
|
||||
#include <ase/stx/misc.h>
|
||||
|
||||
xp_word_t xp_stx_new_context (xp_stx_t* stx,
|
||||
xp_word_t method, xp_word_t args, xp_word_t temp)
|
||||
ase_word_t ase_stx_new_context (ase_stx_t* stx,
|
||||
ase_word_t method, ase_word_t args, ase_word_t temp)
|
||||
{
|
||||
xp_word_t context;
|
||||
xp_stx_context_t* obj;
|
||||
ase_word_t context;
|
||||
ase_stx_context_t* obj;
|
||||
|
||||
context = xp_stx_alloc_word_object(
|
||||
stx, XP_NULL, XP_STX_CONTEXT_SIZE, XP_NULL, 0);
|
||||
obj = (xp_stx_context_t*)XP_STX_OBJECT(stx,context);
|
||||
obj->header.class = xp_stx_lookup_class(stx,XP_TEXT("Context"));
|
||||
obj->ip = XP_STX_TO_SMALLINT(0);
|
||||
context = ase_stx_alloc_word_object(
|
||||
stx, ASE_NULL, ASE_STX_CONTEXT_SIZE, ASE_NULL, 0);
|
||||
obj = (ase_stx_context_t*)ASE_STX_OBJECT(stx,context);
|
||||
obj->header.class = ase_stx_lookup_class(stx,ASE_T("Context"));
|
||||
obj->ip = ASE_STX_TO_SMALLINT(0);
|
||||
obj->method = method;
|
||||
obj->arguments = args;
|
||||
obj->temporaries = temp;
|
||||
@ -25,37 +25,37 @@ xp_word_t xp_stx_new_context (xp_stx_t* stx,
|
||||
return context;
|
||||
}
|
||||
|
||||
static xp_byte_t __fetch_byte (
|
||||
xp_stx_t* stx, xp_stx_context_t* context_obj)
|
||||
static ase_byte_t __fetch_byte (
|
||||
ase_stx_t* stx, ase_stx_context_t* context_obj)
|
||||
{
|
||||
xp_word_t ip, method;
|
||||
ase_word_t ip, method;
|
||||
|
||||
xp_assert (XP_STX_IS_SMALLINT(context_obj->ip));
|
||||
ip = XP_STX_FROM_SMALLINT(context_obj->ip);
|
||||
ase_assert (ASE_STX_IS_SMALLINT(context_obj->ip));
|
||||
ip = ASE_STX_FROM_SMALLINT(context_obj->ip);
|
||||
method = context_obj->method;
|
||||
|
||||
/* increment instruction pointer */
|
||||
context_obj->ip = XP_STX_TO_SMALLINT(ip + 1);
|
||||
context_obj->ip = ASE_STX_TO_SMALLINT(ip + 1);
|
||||
|
||||
xp_assert (XP_STX_TYPE(stx,method) == XP_STX_BYTE_INDEXED);
|
||||
return XP_STX_BYTE_AT(stx,method,ip);
|
||||
ase_assert (ASE_STX_TYPE(stx,method) == ASE_STX_BYTE_INDEXED);
|
||||
return ASE_STX_BYTE_AT(stx,method,ip);
|
||||
}
|
||||
|
||||
int xp_stx_run_context (xp_stx_t* stx, xp_word_t context)
|
||||
int ase_stx_run_context (ase_stx_t* stx, ase_word_t context)
|
||||
{
|
||||
xp_byte_t byte, operand;
|
||||
xp_stx_context_t* context_obj;
|
||||
ase_byte_t byte, operand;
|
||||
ase_stx_context_t* context_obj;
|
||||
|
||||
context_obj = (xp_stx_context_t*)XP_STX_OBJECT(stx,context);
|
||||
context_obj = (ase_stx_context_t*)ASE_STX_OBJECT(stx,context);
|
||||
|
||||
while (!stx->__wantabort) {
|
||||
/* check_process_switch (); // hopefully */
|
||||
byte = __fetch_byte (stx, context_obj);
|
||||
|
||||
#ifdef _DOS
|
||||
printf (XP_TEXT("code: %x\n"), byte);
|
||||
printf (ASE_T("code: %x\n"), byte);
|
||||
#else
|
||||
xp_printf (XP_TEXT("code: %x\n"), byte);
|
||||
ase_printf (ASE_T("code: %x\n"), byte);
|
||||
#endif
|
||||
|
||||
switch (byte) {
|
||||
|
@ -1,40 +1,40 @@
|
||||
/*
|
||||
* $Id: context.h,v 1.5 2005-08-18 15:28:18 bacon Exp $
|
||||
* $Id: context.h,v 1.6 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_STX_CONTEXT_H_
|
||||
#define _XP_STX_CONTEXT_H_
|
||||
#ifndef _ASE_STX_CONTEXT_H_
|
||||
#define _ASE_STX_CONTEXT_H_
|
||||
|
||||
#include <xp/stx/stx.h>
|
||||
#include <ase/stx/stx.h>
|
||||
|
||||
#define PUSH_OBJECT 0xA0
|
||||
#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
|
||||
#define ASE_STX_CONTEXT_SIZE 4
|
||||
#define ASE_STX_CONTEXT_IP 0
|
||||
#define ASE_STX_CONTEXT_METHOD 1
|
||||
#define ASE_STX_CONTEXT_ARGUMENTS 2
|
||||
#define ASE_STX_CONTEXT_TEMPORARIES 3
|
||||
|
||||
struct xp_stx_context_t
|
||||
struct ase_stx_context_t
|
||||
{
|
||||
xp_stx_objhdr_t header;
|
||||
xp_word_t ip;
|
||||
xp_word_t method;
|
||||
xp_word_t arguments;
|
||||
xp_word_t temporaries;
|
||||
ase_stx_objhdr_t header;
|
||||
ase_word_t ip;
|
||||
ase_word_t method;
|
||||
ase_word_t arguments;
|
||||
ase_word_t temporaries;
|
||||
};
|
||||
|
||||
typedef struct xp_stx_context_t xp_stx_context_t;
|
||||
typedef struct ase_stx_context_t ase_stx_context_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
xp_word_t xp_stx_new_context (xp_stx_t* stx,
|
||||
xp_word_t method, xp_word_t args, xp_word_t temp);
|
||||
int xp_stx_run_context (xp_stx_t* stx, xp_word_t context);
|
||||
ase_word_t ase_stx_new_context (ase_stx_t* stx,
|
||||
ase_word_t method, ase_word_t args, ase_word_t temp);
|
||||
int ase_stx_run_context (ase_stx_t* stx, ase_word_t context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
162
ase/stx/dict.c
162
ase/stx/dict.c
@ -1,67 +1,67 @@
|
||||
/*
|
||||
* $Id: dict.c,v 1.10 2005-08-11 10:18:35 bacon Exp $
|
||||
* $Id: dict.c,v 1.11 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/stx/dict.h>
|
||||
#include <xp/stx/object.h>
|
||||
#include <xp/stx/misc.h>
|
||||
#include <ase/stx/dict.h>
|
||||
#include <ase/stx/object.h>
|
||||
#include <ase/stx/misc.h>
|
||||
|
||||
/* NOTE:
|
||||
* The code here implements SystemDictionary whose key is always a symbol.
|
||||
* Dictionary, on the contrary, can accept any object as a key.
|
||||
*/
|
||||
|
||||
xp_word_t __new_association (
|
||||
xp_stx_t* stx, xp_word_t key, xp_word_t value)
|
||||
ase_word_t __new_association (
|
||||
ase_stx_t* stx, ase_word_t key, ase_word_t value)
|
||||
{
|
||||
xp_word_t x;
|
||||
ase_word_t x;
|
||||
#ifdef __GNUC__
|
||||
xp_word_t data[2] = { key, value };
|
||||
ase_word_t data[2] = { key, value };
|
||||
#else
|
||||
xp_word_t data[2];
|
||||
ase_word_t data[2];
|
||||
data[0] = key;
|
||||
data[1] = value;
|
||||
#endif
|
||||
x = xp_stx_alloc_word_object (
|
||||
stx, data, XP_STX_ASSOCIATION_SIZE, XP_NULL, 0);
|
||||
XP_STX_CLASS(stx,x) = stx->class_association;
|
||||
x = ase_stx_alloc_word_object (
|
||||
stx, data, ASE_STX_ASSOCIATION_SIZE, ASE_NULL, 0);
|
||||
ASE_STX_CLASS(stx,x) = stx->class_association;
|
||||
return x;
|
||||
}
|
||||
|
||||
static xp_word_t __dict_find_slot (
|
||||
xp_stx_t* stx, xp_word_t dict, xp_word_t key)
|
||||
static ase_word_t __dict_find_slot (
|
||||
ase_stx_t* stx, ase_word_t dict, ase_word_t key)
|
||||
{
|
||||
xp_word_t size, hash, index, assoc, symbol;
|
||||
xp_stx_word_object_t* dict_obj;
|
||||
ase_word_t size, hash, index, assoc, symbol;
|
||||
ase_stx_word_object_t* dict_obj;
|
||||
|
||||
xp_assert (!XP_STX_IS_SMALLINT(dict) &&
|
||||
XP_STX_IS_WORD_OBJECT(stx, dict));
|
||||
xp_assert (dict == stx->smalltalk ||
|
||||
xp_stx_classof(stx,dict) == stx->class_system_dictionary);
|
||||
xp_assert (xp_stx_classof(stx,key) == stx->class_symbol);
|
||||
ase_assert (!ASE_STX_IS_SMALLINT(dict) &&
|
||||
ASE_STX_IS_WORD_OBJECT(stx, dict));
|
||||
ase_assert (dict == stx->smalltalk ||
|
||||
ase_stx_classof(stx,dict) == stx->class_system_dictionary);
|
||||
ase_assert (ase_stx_classof(stx,key) == stx->class_symbol);
|
||||
|
||||
size = XP_STX_SIZE(stx,dict);
|
||||
hash = xp_stx_hash_object(stx, key);
|
||||
size = ASE_STX_SIZE(stx,dict);
|
||||
hash = ase_stx_hash_object(stx, key);
|
||||
|
||||
/* consider tally, the only instance variable of a system dictionary */
|
||||
index = hash % (size - 1) + 1;
|
||||
|
||||
dict_obj = XP_STX_WORD_OBJECT(stx,dict);
|
||||
dict_obj = ASE_STX_WORD_OBJECT(stx,dict);
|
||||
|
||||
while (1) {
|
||||
assoc = dict_obj->data[index];
|
||||
if (assoc == stx->nil) break;
|
||||
|
||||
symbol = XP_STX_WORD_AT(stx,assoc,XP_STX_ASSOCIATION_KEY);
|
||||
xp_assert (xp_stx_classof(stx,symbol) == stx->class_symbol);
|
||||
symbol = ASE_STX_WORD_AT(stx,assoc,ASE_STX_ASSOCIATION_KEY);
|
||||
ase_assert (ase_stx_classof(stx,symbol) == stx->class_symbol);
|
||||
|
||||
/* NOTE:
|
||||
* shallow comparison is enough for identity check
|
||||
* because a symbol can just be a key of a system dictionary
|
||||
*/
|
||||
if (xp_strxncmp(
|
||||
XP_STX_DATA(stx,key), XP_STX_SIZE(stx,key),
|
||||
XP_STX_DATA(stx,symbol), XP_STX_SIZE(stx,symbol)) == 0) break;
|
||||
if (ase_strxncmp(
|
||||
ASE_STX_DATA(stx,key), ASE_STX_SIZE(stx,key),
|
||||
ASE_STX_DATA(stx,symbol), ASE_STX_SIZE(stx,symbol)) == 0) break;
|
||||
|
||||
/* consider tally here too */
|
||||
index = index % (size - 1) + 1;
|
||||
@ -70,119 +70,119 @@ static xp_word_t __dict_find_slot (
|
||||
return index;
|
||||
}
|
||||
|
||||
static void __grow_dict (xp_stx_t* stx, xp_word_t dict)
|
||||
static void __grow_dict (ase_stx_t* stx, ase_word_t dict)
|
||||
{
|
||||
xp_word_t new, size, index, assoc;
|
||||
ase_word_t new, size, index, assoc;
|
||||
|
||||
/* WARNING:
|
||||
* if this assertion fails, adjust the initial size of the
|
||||
* system dictionary. i don't want this function to be called
|
||||
* during the bootstrapping.
|
||||
*/
|
||||
xp_assert (stx->class_system_dictionary != stx->nil);
|
||||
xp_assert (xp_stx_classof(stx,dict) == stx->class_system_dictionary);
|
||||
ase_assert (stx->class_system_dictionary != stx->nil);
|
||||
ase_assert (ase_stx_classof(stx,dict) == stx->class_system_dictionary);
|
||||
|
||||
size = XP_STX_SIZE(stx,dict);
|
||||
new = xp_stx_instantiate (stx,
|
||||
XP_STX_CLASS(stx,dict), XP_NULL, XP_NULL, (size - 1) * 2);
|
||||
XP_STX_WORD_AT(stx,new,0) = XP_STX_TO_SMALLINT(0);
|
||||
size = ASE_STX_SIZE(stx,dict);
|
||||
new = ase_stx_instantiate (stx,
|
||||
ASE_STX_CLASS(stx,dict), ASE_NULL, ASE_NULL, (size - 1) * 2);
|
||||
ASE_STX_WORD_AT(stx,new,0) = ASE_STX_TO_SMALLINT(0);
|
||||
|
||||
for (index = 1; index < size; index++) {
|
||||
assoc = XP_STX_WORD_AT(stx,dict,index);
|
||||
assoc = ASE_STX_WORD_AT(stx,dict,index);
|
||||
if (assoc == stx->nil) continue;
|
||||
|
||||
xp_stx_dict_put (stx, new,
|
||||
XP_STX_WORD_AT(stx,assoc,XP_STX_ASSOCIATION_KEY),
|
||||
XP_STX_WORD_AT(stx,assoc,XP_STX_ASSOCIATION_VALUE));
|
||||
ase_stx_dict_put (stx, new,
|
||||
ASE_STX_WORD_AT(stx,assoc,ASE_STX_ASSOCIATION_KEY),
|
||||
ASE_STX_WORD_AT(stx,assoc,ASE_STX_ASSOCIATION_VALUE));
|
||||
}
|
||||
|
||||
/* TODO: explore if dict can be immediately destroyed. */
|
||||
|
||||
xp_assert (xp_sizeof(xp_stx_object_t*) == xp_sizeof(xp_uint_t));
|
||||
XP_SWAP (XP_STX_OBJECT(stx,dict),
|
||||
XP_STX_OBJECT(stx,new),
|
||||
xp_stx_object_t*, xp_uint_t);
|
||||
ase_assert (ase_sizeof(ase_stx_object_t*) == ase_sizeof(ase_uint_t));
|
||||
ASE_SWAP (ASE_STX_OBJECT(stx,dict),
|
||||
ASE_STX_OBJECT(stx,new),
|
||||
ase_stx_object_t*, ase_uint_t);
|
||||
}
|
||||
|
||||
xp_word_t xp_stx_dict_lookup (
|
||||
xp_stx_t* stx, xp_word_t dict, const xp_char_t* key)
|
||||
ase_word_t ase_stx_dict_lookup (
|
||||
ase_stx_t* stx, ase_word_t dict, const ase_char_t* key)
|
||||
{
|
||||
xp_word_t size, hash, index, assoc, symbol;
|
||||
xp_stx_word_object_t* dict_obj;
|
||||
ase_word_t size, hash, index, assoc, symbol;
|
||||
ase_stx_word_object_t* dict_obj;
|
||||
|
||||
xp_assert (!XP_STX_IS_SMALLINT(dict) &&
|
||||
XP_STX_IS_WORD_OBJECT(stx, dict));
|
||||
xp_assert (dict == stx->smalltalk ||
|
||||
xp_stx_classof(stx,dict) == stx->class_system_dictionary);
|
||||
ase_assert (!ASE_STX_IS_SMALLINT(dict) &&
|
||||
ASE_STX_IS_WORD_OBJECT(stx, dict));
|
||||
ase_assert (dict == stx->smalltalk ||
|
||||
ase_stx_classof(stx,dict) == stx->class_system_dictionary);
|
||||
|
||||
size = XP_STX_SIZE(stx,dict);
|
||||
hash = xp_stx_hash(key, xp_strlen(key) * xp_sizeof(xp_char_t));
|
||||
size = ASE_STX_SIZE(stx,dict);
|
||||
hash = ase_stx_hash(key, ase_strlen(key) * ase_sizeof(ase_char_t));
|
||||
|
||||
/* consider tally, the only instance variable of a system dictionary */
|
||||
index = hash % (size - 1) + 1;
|
||||
|
||||
dict_obj = XP_STX_WORD_OBJECT(stx,dict);
|
||||
dict_obj = ASE_STX_WORD_OBJECT(stx,dict);
|
||||
|
||||
while (1) {
|
||||
assoc = dict_obj->data[index];
|
||||
if (assoc == stx->nil) break;
|
||||
|
||||
symbol = XP_STX_WORD_AT(stx,assoc,XP_STX_ASSOCIATION_KEY);
|
||||
xp_assert (xp_stx_classof(stx,symbol) == stx->class_symbol);
|
||||
symbol = ASE_STX_WORD_AT(stx,assoc,ASE_STX_ASSOCIATION_KEY);
|
||||
ase_assert (ase_stx_classof(stx,symbol) == stx->class_symbol);
|
||||
|
||||
if (xp_strxcmp (XP_STX_DATA(stx,symbol),
|
||||
XP_STX_SIZE(stx,symbol), key) == 0) break;
|
||||
if (ase_strxcmp (ASE_STX_DATA(stx,symbol),
|
||||
ASE_STX_SIZE(stx,symbol), key) == 0) break;
|
||||
|
||||
/* consider tally here too */
|
||||
index = index % (size - 1) + 1;
|
||||
}
|
||||
|
||||
return XP_STX_WORD_AT(stx,dict,index);
|
||||
return ASE_STX_WORD_AT(stx,dict,index);
|
||||
}
|
||||
|
||||
xp_word_t xp_stx_dict_get (xp_stx_t* stx, xp_word_t dict, xp_word_t key)
|
||||
ase_word_t ase_stx_dict_get (ase_stx_t* stx, ase_word_t dict, ase_word_t key)
|
||||
{
|
||||
return XP_STX_WORD_AT(stx,dict,__dict_find_slot(stx, dict, key));
|
||||
return ASE_STX_WORD_AT(stx,dict,__dict_find_slot(stx, dict, key));
|
||||
}
|
||||
|
||||
xp_word_t xp_stx_dict_put (
|
||||
xp_stx_t* stx, xp_word_t dict, xp_word_t key, xp_word_t value)
|
||||
ase_word_t ase_stx_dict_put (
|
||||
ase_stx_t* stx, ase_word_t dict, ase_word_t key, ase_word_t value)
|
||||
{
|
||||
xp_word_t slot, capa, tally, assoc;
|
||||
ase_word_t slot, capa, tally, assoc;
|
||||
|
||||
/* the dictionary must have at least one slot excluding tally */
|
||||
xp_assert (XP_STX_SIZE(stx,dict) > 1);
|
||||
ase_assert (ASE_STX_SIZE(stx,dict) > 1);
|
||||
|
||||
capa = XP_STX_SIZE(stx,dict) - 1;
|
||||
tally = XP_STX_FROM_SMALLINT(XP_STX_WORD_AT(stx,dict,0));
|
||||
capa = ASE_STX_SIZE(stx,dict) - 1;
|
||||
tally = ASE_STX_FROM_SMALLINT(ASE_STX_WORD_AT(stx,dict,0));
|
||||
if (capa <= tally + 1) {
|
||||
__grow_dict (stx, dict);
|
||||
/* refresh tally */
|
||||
tally = XP_STX_FROM_SMALLINT(XP_STX_WORD_AT(stx,dict,0));
|
||||
tally = ASE_STX_FROM_SMALLINT(ASE_STX_WORD_AT(stx,dict,0));
|
||||
}
|
||||
|
||||
slot = __dict_find_slot (stx, dict, key);
|
||||
|
||||
assoc = XP_STX_WORD_AT(stx,dict,slot);
|
||||
assoc = ASE_STX_WORD_AT(stx,dict,slot);
|
||||
if (assoc == stx->nil) {
|
||||
XP_STX_WORD_AT(stx,dict,slot) =
|
||||
ASE_STX_WORD_AT(stx,dict,slot) =
|
||||
__new_association (stx, key, value);
|
||||
XP_STX_WORD_AT(stx,dict,0) = XP_STX_TO_SMALLINT(tally + 1);
|
||||
ASE_STX_WORD_AT(stx,dict,0) = ASE_STX_TO_SMALLINT(tally + 1);
|
||||
}
|
||||
else XP_STX_WORD_AT(stx,assoc,XP_STX_ASSOCIATION_VALUE) = value;
|
||||
else ASE_STX_WORD_AT(stx,assoc,ASE_STX_ASSOCIATION_VALUE) = value;
|
||||
|
||||
return XP_STX_WORD_AT(stx,dict,slot);
|
||||
return ASE_STX_WORD_AT(stx,dict,slot);
|
||||
}
|
||||
|
||||
void xp_stx_dict_traverse (
|
||||
xp_stx_t* stx, xp_word_t dict,
|
||||
void (*func) (xp_stx_t*,xp_word_t,void*), void* data)
|
||||
void ase_stx_dict_traverse (
|
||||
ase_stx_t* stx, ase_word_t dict,
|
||||
void (*func) (ase_stx_t*,ase_word_t,void*), void* data)
|
||||
{
|
||||
xp_word_t index, assoc;
|
||||
xp_word_t size = XP_STX_SIZE(stx,dict);
|
||||
ase_word_t index, assoc;
|
||||
ase_word_t size = ASE_STX_SIZE(stx,dict);
|
||||
|
||||
for (index = 1; index < size; index++) {
|
||||
assoc = XP_STX_WORD_AT(stx,dict,index);
|
||||
assoc = ASE_STX_WORD_AT(stx,dict,index);
|
||||
if (assoc == stx->nil) continue;
|
||||
func (stx, assoc, data);
|
||||
}
|
||||
|
@ -1,38 +1,38 @@
|
||||
/*
|
||||
* $Id: dict.h,v 1.4 2005-08-18 15:28:18 bacon Exp $
|
||||
* $Id: dict.h,v 1.5 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_STX_DICT_H_
|
||||
#define _XP_STX_DICT_H_
|
||||
#ifndef _ASE_STX_DICT_H_
|
||||
#define _ASE_STX_DICT_H_
|
||||
|
||||
#include <xp/stx/stx.h>
|
||||
#include <ase/stx/stx.h>
|
||||
|
||||
#define XP_STX_ASSOCIATION_SIZE 2
|
||||
#define XP_STX_ASSOCIATION_KEY 0
|
||||
#define XP_STX_ASSOCIATION_VALUE 1
|
||||
#define ASE_STX_ASSOCIATION_SIZE 2
|
||||
#define ASE_STX_ASSOCIATION_KEY 0
|
||||
#define ASE_STX_ASSOCIATION_VALUE 1
|
||||
|
||||
struct xp_stx_association_t
|
||||
struct ase_stx_association_t
|
||||
{
|
||||
xp_stx_objhdr_t header;
|
||||
xp_word_t key;
|
||||
xp_word_t value;
|
||||
ase_stx_objhdr_t header;
|
||||
ase_word_t key;
|
||||
ase_word_t value;
|
||||
};
|
||||
|
||||
typedef struct xp_stx_association_t xp_stx_association_t;
|
||||
typedef struct ase_stx_association_t ase_stx_association_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
|
||||
xp_word_t xp_stx_dict_lookup (
|
||||
xp_stx_t* stx, xp_word_t dict, const xp_char_t* key);
|
||||
xp_word_t xp_stx_dict_get (
|
||||
xp_stx_t* stx, xp_word_t dict, xp_word_t key);
|
||||
xp_word_t xp_stx_dict_put (
|
||||
xp_stx_t* stx, xp_word_t dict, xp_word_t key, xp_word_t value);
|
||||
void xp_stx_dict_traverse (
|
||||
xp_stx_t* stx, xp_word_t dict,
|
||||
void (*func) (xp_stx_t*,xp_word_t,void*), void* data);
|
||||
ase_word_t ase_stx_dict_lookup (
|
||||
ase_stx_t* stx, ase_word_t dict, const ase_char_t* key);
|
||||
ase_word_t ase_stx_dict_get (
|
||||
ase_stx_t* stx, ase_word_t dict, ase_word_t key);
|
||||
ase_word_t ase_stx_dict_put (
|
||||
ase_stx_t* stx, ase_word_t dict, ase_word_t key, ase_word_t value);
|
||||
void ase_stx_dict_traverse (
|
||||
ase_stx_t* stx, ase_word_t dict,
|
||||
void (*func) (ase_stx_t*,ase_word_t,void*), void* data);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
180
ase/stx/interp.c
180
ase/stx/interp.c
@ -1,14 +1,14 @@
|
||||
/*
|
||||
* $Id: interp.c,v 1.19 2005-10-02 15:45:09 bacon Exp $
|
||||
* $Id: interp.c,v 1.20 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/stx/interp.h>
|
||||
#include <xp/stx/method.h>
|
||||
#include <xp/stx/object.h>
|
||||
#include <xp/stx/array.h>
|
||||
#include <xp/stx/class.h>
|
||||
#include <xp/bas/assert.h>
|
||||
#include <xp/bas/memory.h>
|
||||
#include <ase/stx/interp.h>
|
||||
#include <ase/stx/method.h>
|
||||
#include <ase/stx/object.h>
|
||||
#include <ase/stx/array.h>
|
||||
#include <ase/stx/class.h>
|
||||
#include <ase/bas/assert.h>
|
||||
#include <ase/bas/memory.h>
|
||||
|
||||
/*
|
||||
activation record
|
||||
@ -37,46 +37,46 @@ receiver
|
||||
|
||||
struct process_t
|
||||
{
|
||||
xp_word_t* stack;
|
||||
xp_word_t stack_size;
|
||||
xp_word_t stack_base;
|
||||
xp_word_t stack_top;
|
||||
ase_word_t* stack;
|
||||
ase_word_t stack_size;
|
||||
ase_word_t stack_base;
|
||||
ase_word_t stack_top;
|
||||
|
||||
xp_word_t receiver;
|
||||
xp_word_t method;
|
||||
xp_word_t pc;
|
||||
ase_word_t receiver;
|
||||
ase_word_t method;
|
||||
ase_word_t pc;
|
||||
|
||||
/* cached information about the method above */
|
||||
xp_word_t* literals;
|
||||
xp_byte_t* bytecodes;
|
||||
xp_word_t bytecode_size;
|
||||
xp_size_t argcount;
|
||||
xp_size_t tmpcount;
|
||||
ase_word_t* literals;
|
||||
ase_byte_t* bytecodes;
|
||||
ase_word_t bytecode_size;
|
||||
ase_size_t argcount;
|
||||
ase_size_t tmpcount;
|
||||
};
|
||||
|
||||
typedef struct process_t process_t;
|
||||
|
||||
static int __run_process (xp_stx_t* stx, process_t* proc);
|
||||
static int __push_to_stack (xp_stx_t* stx,
|
||||
process_t* proc, xp_word_t what, xp_word_t index);
|
||||
static int __store_from_stack (xp_stx_t* stx,
|
||||
process_t* proc, xp_word_t what, xp_word_t index);
|
||||
static int __send_message (xp_stx_t* stx, process_t* proc,
|
||||
xp_word_t nargs, xp_word_t selector, xp_bool_t to_super);
|
||||
static int __return_from_message (xp_stx_t* stx, process_t* proc);
|
||||
static int __dispatch_primitive (xp_stx_t* stx, process_t* proc, xp_word_t no);
|
||||
static int __run_process (ase_stx_t* stx, process_t* proc);
|
||||
static int __push_to_stack (ase_stx_t* stx,
|
||||
process_t* proc, ase_word_t what, ase_word_t index);
|
||||
static int __store_from_stack (ase_stx_t* stx,
|
||||
process_t* proc, ase_word_t what, ase_word_t index);
|
||||
static int __send_message (ase_stx_t* stx, process_t* proc,
|
||||
ase_word_t nargs, ase_word_t selector, ase_bool_t to_super);
|
||||
static int __return_from_message (ase_stx_t* stx, process_t* proc);
|
||||
static int __dispatch_primitive (ase_stx_t* stx, process_t* proc, ase_word_t no);
|
||||
|
||||
int xp_stx_interp (xp_stx_t* stx, xp_word_t receiver, xp_word_t method)
|
||||
int ase_stx_interp (ase_stx_t* stx, ase_word_t receiver, ase_word_t method)
|
||||
{
|
||||
process_t proc;
|
||||
xp_stx_method_t* mthobj;
|
||||
xp_word_t i;
|
||||
ase_stx_method_t* mthobj;
|
||||
ase_word_t i;
|
||||
int n;
|
||||
|
||||
// TODO: size of process stack.
|
||||
proc.stack = (xp_word_t*)xp_malloc (10000 * xp_sizeof(xp_word_t));
|
||||
if (proc.stack == XP_NULL) {
|
||||
xp_printf (XP_TEXT("out of memory in xp_stx_interp\n"));
|
||||
proc.stack = (ase_word_t*)ase_malloc (10000 * ase_sizeof(ase_word_t));
|
||||
if (proc.stack == ASE_NULL) {
|
||||
ase_printf (ASE_T("out of memory in ase_stx_interp\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -84,15 +84,15 @@ xp_printf (XP_TEXT("out of memory in xp_stx_interp\n"));
|
||||
proc.stack_base = 0;
|
||||
proc.stack_top = 0;
|
||||
|
||||
mthobj = (xp_stx_method_t*)XP_STX_OBJECT(stx,method);
|
||||
xp_assert (mthobj != XP_NULL);
|
||||
mthobj = (ase_stx_method_t*)ASE_STX_OBJECT(stx,method);
|
||||
ase_assert (mthobj != ASE_NULL);
|
||||
|
||||
proc.literals = mthobj->literals;
|
||||
proc.bytecodes = XP_STX_DATA(stx, mthobj->bytecodes);
|
||||
proc.bytecode_size = XP_STX_SIZE(stx, mthobj->bytecodes);
|
||||
proc.bytecodes = ASE_STX_DATA(stx, mthobj->bytecodes);
|
||||
proc.bytecode_size = ASE_STX_SIZE(stx, mthobj->bytecodes);
|
||||
/* TODO: disable the method with arguments for start-up */
|
||||
proc.argcount = XP_STX_FROM_SMALLINT(mthobj->argcount);
|
||||
proc.tmpcount = XP_STX_FROM_SMALLINT(mthobj->tmpcount);
|
||||
proc.argcount = ASE_STX_FROM_SMALLINT(mthobj->argcount);
|
||||
proc.tmpcount = ASE_STX_FROM_SMALLINT(mthobj->tmpcount);
|
||||
|
||||
proc.receiver = receiver;
|
||||
proc.method = method;
|
||||
@ -121,11 +121,11 @@ xp_printf (XP_TEXT("out of memory in xp_stx_interp\n"));
|
||||
|
||||
n = __run_process (stx, &proc);
|
||||
|
||||
xp_free (proc.stack);
|
||||
ase_free (proc.stack);
|
||||
return n;
|
||||
}
|
||||
|
||||
static int __run_process (xp_stx_t* stx, process_t* proc)
|
||||
static int __run_process (ase_stx_t* stx, process_t* proc)
|
||||
{
|
||||
int code, next, next2;
|
||||
|
||||
@ -133,7 +133,7 @@ static int __run_process (xp_stx_t* stx, process_t* proc)
|
||||
code = proc->bytecodes[proc->pc++];
|
||||
|
||||
#ifdef DEBUG
|
||||
xp_printf (XP_TEXT("code = 0x%x\n"), code);
|
||||
ase_printf (ASE_T("code = 0x%x\n"), code);
|
||||
#endif
|
||||
|
||||
if (code >= 0x00 && code <= 0x3F) {
|
||||
@ -176,27 +176,27 @@ static int __run_process (xp_stx_t* stx, process_t* proc)
|
||||
/* send message to self */
|
||||
next = proc->bytecodes[proc->pc++];
|
||||
if (__send_message (stx, proc, next >> 5,
|
||||
proc->literals[next & 0x1F], xp_false) == -1) break;
|
||||
proc->literals[next & 0x1F], ase_false) == -1) break;
|
||||
}
|
||||
else if (code == 0x71) {
|
||||
/* send message to super */
|
||||
next = proc->bytecodes[proc->pc++];
|
||||
if (__send_message (stx, proc, next >> 5,
|
||||
proc->literals[next & 0x1F], xp_true) == -1) break;
|
||||
proc->literals[next & 0x1F], ase_true) == -1) break;
|
||||
}
|
||||
else if (code == 0x72) {
|
||||
/* send message to self extended */
|
||||
next = proc->bytecodes[proc->pc++];
|
||||
next2 = proc->bytecodes[proc->pc++];
|
||||
if (__send_message (stx, proc, next >> 5,
|
||||
proc->literals[next2], xp_false) == -1) break;
|
||||
proc->literals[next2], ase_false) == -1) break;
|
||||
}
|
||||
else if (code == 0x73) {
|
||||
/* send message to super extended */
|
||||
next = proc->bytecodes[proc->pc++];
|
||||
next2 = proc->bytecodes[proc->pc++];
|
||||
if (__send_message (stx, proc, next >> 5,
|
||||
proc->literals[next2], xp_true) == -1) break;
|
||||
proc->literals[next2], ase_true) == -1) break;
|
||||
}
|
||||
|
||||
/* more code .... */
|
||||
@ -218,7 +218,7 @@ static int __run_process (xp_stx_t* stx, process_t* proc)
|
||||
}
|
||||
|
||||
else {
|
||||
xp_printf (XP_TEXT("INVALID OPCODE...........\n"));
|
||||
ase_printf (ASE_T("INVALID OPCODE...........\n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -226,13 +226,13 @@ break;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __push_to_stack (xp_stx_t* stx,
|
||||
process_t* proc, xp_word_t what, xp_word_t index)
|
||||
static int __push_to_stack (ase_stx_t* stx,
|
||||
process_t* proc, ase_word_t what, ase_word_t index)
|
||||
{
|
||||
switch (what) {
|
||||
case 0: /* receiver variable */
|
||||
proc->stack[proc->stack_top++] =
|
||||
XP_STX_WORD_AT(stx, proc->stack[proc->stack_base], index);
|
||||
ASE_STX_WORD_AT(stx, proc->stack[proc->stack_base], index);
|
||||
break;
|
||||
case 1: /* temporary variable */
|
||||
proc->stack[proc->stack_top++] =
|
||||
@ -248,12 +248,12 @@ static int __push_to_stack (xp_stx_t* stx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __store_from_stack (xp_stx_t* stx,
|
||||
process_t* proc, xp_word_t what, xp_word_t index)
|
||||
static int __store_from_stack (ase_stx_t* stx,
|
||||
process_t* proc, ase_word_t what, ase_word_t index)
|
||||
{
|
||||
switch (what) {
|
||||
case 4: /* receiver variable */
|
||||
XP_STX_WORD_AT(stx,proc->stack[proc->stack_base],index) = proc->stack[--proc->stack_top];
|
||||
ASE_STX_WORD_AT(stx,proc->stack[proc->stack_base],index) = proc->stack[--proc->stack_top];
|
||||
break;
|
||||
case 5: /* temporary location */
|
||||
proc->stack[proc->stack_base + 1 + index] = proc->stack[--proc->stack_top];
|
||||
@ -263,29 +263,29 @@ static int __store_from_stack (xp_stx_t* stx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __send_message (xp_stx_t* stx, process_t* proc,
|
||||
xp_word_t nargs, xp_word_t selector, xp_bool_t to_super)
|
||||
static int __send_message (ase_stx_t* stx, process_t* proc,
|
||||
ase_word_t nargs, ase_word_t selector, ase_bool_t to_super)
|
||||
{
|
||||
xp_word_t receiver, method;
|
||||
xp_word_t i, tmpcount, argcount;
|
||||
xp_stx_method_t* mthobj;
|
||||
ase_word_t receiver, method;
|
||||
ase_word_t i, tmpcount, argcount;
|
||||
ase_stx_method_t* mthobj;
|
||||
|
||||
xp_assert (XP_STX_CLASS(stx,selector) == stx->class_symbol);
|
||||
ase_assert (ASE_STX_CLASS(stx,selector) == stx->class_symbol);
|
||||
|
||||
receiver = proc->stack[proc->stack_top - nargs - 1];
|
||||
method = xp_stx_lookup_method (
|
||||
stx, XP_STX_CLASS(stx,receiver),
|
||||
XP_STX_DATA(stx,selector), to_super);
|
||||
method = ase_stx_lookup_method (
|
||||
stx, ASE_STX_CLASS(stx,receiver),
|
||||
ASE_STX_DATA(stx,selector), to_super);
|
||||
if (method == stx->nil) {
|
||||
xp_printf (XP_TEXT("cannot find the method....\n"));
|
||||
ase_printf (ASE_T("cannot find the method....\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
mthobj = (xp_stx_method_t*)XP_STX_OBJECT(stx,method);
|
||||
mthobj = (ase_stx_method_t*)ASE_STX_OBJECT(stx,method);
|
||||
|
||||
argcount = XP_STX_FROM_SMALLINT(mthobj->argcount);
|
||||
tmpcount = XP_STX_FROM_SMALLINT(mthobj->tmpcount);
|
||||
xp_assert (argcount == nargs);
|
||||
argcount = ASE_STX_FROM_SMALLINT(mthobj->argcount);
|
||||
tmpcount = ASE_STX_FROM_SMALLINT(mthobj->tmpcount);
|
||||
ase_assert (argcount == nargs);
|
||||
|
||||
/* secure space for temporaries */
|
||||
for (i = 0; i < tmpcount; i++) {
|
||||
@ -300,25 +300,25 @@ xp_printf (XP_TEXT("cannot find the method....\n"));
|
||||
proc->stack[proc->stack_top++] = proc->stack_base;
|
||||
|
||||
proc->stack_base = proc->stack_top - 3 - tmpcount - argcount - 1;
|
||||
xp_assert (proc->stack_base > 0);
|
||||
ase_assert (proc->stack_base > 0);
|
||||
|
||||
proc->receiver = receiver;
|
||||
proc->method = method;
|
||||
proc->pc = 0;
|
||||
|
||||
proc->literals = mthobj->literals;
|
||||
proc->bytecodes = XP_STX_DATA(stx, mthobj->bytecodes);
|
||||
proc->bytecode_size = XP_STX_SIZE(stx, mthobj->bytecodes);
|
||||
proc->bytecodes = ASE_STX_DATA(stx, mthobj->bytecodes);
|
||||
proc->bytecode_size = ASE_STX_SIZE(stx, mthobj->bytecodes);
|
||||
proc->argcount = argcount;
|
||||
proc->tmpcount = tmpcount;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __return_from_message (xp_stx_t* stx, process_t* proc)
|
||||
static int __return_from_message (ase_stx_t* stx, process_t* proc)
|
||||
{
|
||||
xp_word_t method, pc, stack_base;
|
||||
xp_stx_method_t* mthobj;
|
||||
ase_word_t method, pc, stack_base;
|
||||
ase_stx_method_t* mthobj;
|
||||
|
||||
if (proc->stack_base == 0) {
|
||||
/* return from the startup method */
|
||||
@ -329,8 +329,8 @@ static int __return_from_message (xp_stx_t* stx, process_t* proc)
|
||||
method = proc->stack[proc->stack_base + 1 + proc->tmpcount + proc->argcount + 1];
|
||||
pc = proc->stack[proc->stack_base + 1 + proc->tmpcount + proc->argcount];
|
||||
|
||||
mthobj = (xp_stx_method_t*)XP_STX_OBJECT(stx,method);
|
||||
xp_assert (mthobj != XP_NULL);
|
||||
mthobj = (ase_stx_method_t*)ASE_STX_OBJECT(stx,method);
|
||||
ase_assert (mthobj != ASE_NULL);
|
||||
|
||||
/* return value is located on top of the previous stack */
|
||||
proc->stack[proc->stack_base - 1] = proc->stack[proc->stack_top - 1];
|
||||
@ -344,35 +344,35 @@ static int __return_from_message (xp_stx_t* stx, process_t* proc)
|
||||
proc->pc = pc;
|
||||
|
||||
proc->literals = mthobj->literals;
|
||||
proc->bytecodes = XP_STX_DATA(stx, mthobj->bytecodes);
|
||||
proc->bytecode_size = XP_STX_SIZE(stx, mthobj->bytecodes);
|
||||
proc->argcount = XP_STX_FROM_SMALLINT(mthobj->argcount);
|
||||
proc->tmpcount = XP_STX_FROM_SMALLINT(mthobj->tmpcount);
|
||||
proc->bytecodes = ASE_STX_DATA(stx, mthobj->bytecodes);
|
||||
proc->bytecode_size = ASE_STX_SIZE(stx, mthobj->bytecodes);
|
||||
proc->argcount = ASE_STX_FROM_SMALLINT(mthobj->argcount);
|
||||
proc->tmpcount = ASE_STX_FROM_SMALLINT(mthobj->tmpcount);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int __dispatch_primitive (xp_stx_t* stx, process_t* proc, xp_word_t no)
|
||||
static int __dispatch_primitive (ase_stx_t* stx, process_t* proc, ase_word_t no)
|
||||
{
|
||||
switch (no) {
|
||||
case 0:
|
||||
xp_printf (XP_TEXT("[[ hello stx smalltalk ]]\n"));
|
||||
ase_printf (ASE_T("[[ hello stx smalltalk ]]\n"));
|
||||
break;
|
||||
case 1:
|
||||
xp_printf (XP_TEXT("<< AMAZING STX SMALLTALK WORLD >>\n"));
|
||||
ase_printf (ASE_T("<< AMAZING STX SMALLTALK WORLD >>\n"));
|
||||
break;
|
||||
case 2:
|
||||
xp_printf (XP_TEXT("<< FUNKY STX SMALLTALK >> %d\n"),
|
||||
XP_STX_FROM_SMALLINT(proc->stack[proc->stack_base + 1]));
|
||||
ase_printf (ASE_T("<< FUNKY STX SMALLTALK >> %d\n"),
|
||||
ASE_STX_FROM_SMALLINT(proc->stack[proc->stack_base + 1]));
|
||||
break;
|
||||
case 3:
|
||||
xp_printf (XP_TEXT("<< HIGH STX SMALLTALK >> %d, %d\n"),
|
||||
XP_STX_FROM_SMALLINT(proc->stack[proc->stack_base + 1]),
|
||||
XP_STX_FROM_SMALLINT(proc->stack[proc->stack_base + 2]));
|
||||
ase_printf (ASE_T("<< HIGH STX SMALLTALK >> %d, %d\n"),
|
||||
ASE_STX_FROM_SMALLINT(proc->stack[proc->stack_base + 1]),
|
||||
ASE_STX_FROM_SMALLINT(proc->stack[proc->stack_base + 2]));
|
||||
break;
|
||||
case 20:
|
||||
xp_printf (XP_TEXT("<< PRIMITIVE 20 >>\n"));
|
||||
ase_printf (ASE_T("<< PRIMITIVE 20 >>\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
* $Id: interp.h,v 1.6 2005-09-13 11:15:41 bacon Exp $
|
||||
* $Id: interp.h,v 1.7 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_STX_INTERP_H_
|
||||
#define _XP_STX_INTERP_H_
|
||||
#ifndef _ASE_STX_INTERP_H_
|
||||
#define _ASE_STX_INTERP_H_
|
||||
|
||||
#include <xp/stx/stx.h>
|
||||
#include <ase/stx/stx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int xp_stx_interp (xp_stx_t* stx, xp_word_t receiver, xp_word_t method);
|
||||
int ase_stx_interp (ase_stx_t* stx, ase_word_t receiver, ase_word_t method);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,29 +1,29 @@
|
||||
/*
|
||||
* $Id: memory.c,v 1.13 2005-12-05 15:11:29 bacon Exp $
|
||||
* $Id: memory.c,v 1.14 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/stx/memory.h>
|
||||
#include <xp/stx/misc.h>
|
||||
#include <ase/stx/memory.h>
|
||||
#include <ase/stx/misc.h>
|
||||
|
||||
xp_stx_memory_t* xp_stx_memory_open (
|
||||
xp_stx_memory_t* mem, xp_word_t capacity)
|
||||
ase_stx_memory_t* ase_stx_memory_open (
|
||||
ase_stx_memory_t* mem, ase_word_t capacity)
|
||||
{
|
||||
xp_stx_object_t** slots;
|
||||
xp_word_t n;
|
||||
ase_stx_object_t** slots;
|
||||
ase_word_t n;
|
||||
|
||||
xp_assert (capacity > 0);
|
||||
if (mem == XP_NULL) {
|
||||
mem = (xp_stx_memory_t*)xp_malloc(xp_sizeof(xp_stx_memory_t));
|
||||
if (mem == XP_NULL) return XP_NULL;
|
||||
mem->__dynamic = xp_true;
|
||||
ase_assert (capacity > 0);
|
||||
if (mem == ASE_NULL) {
|
||||
mem = (ase_stx_memory_t*)ase_malloc(ase_sizeof(ase_stx_memory_t));
|
||||
if (mem == ASE_NULL) return ASE_NULL;
|
||||
mem->__dynamic = ase_true;
|
||||
}
|
||||
else mem->__dynamic = xp_false;
|
||||
else mem->__dynamic = ase_false;
|
||||
|
||||
slots = (xp_stx_object_t**)xp_malloc (
|
||||
capacity * xp_sizeof(xp_stx_object_t*));
|
||||
if (slots == XP_NULL) {
|
||||
if (mem->__dynamic) xp_free (mem);
|
||||
mem = XP_NULL;
|
||||
slots = (ase_stx_object_t**)ase_malloc (
|
||||
capacity * ase_sizeof(ase_stx_object_t*));
|
||||
if (slots == ASE_NULL) {
|
||||
if (mem->__dynamic) ase_free (mem);
|
||||
mem = ASE_NULL;
|
||||
}
|
||||
|
||||
mem->capacity = capacity;
|
||||
@ -32,67 +32,67 @@ xp_stx_memory_t* xp_stx_memory_open (
|
||||
/* weave the free slot list */
|
||||
mem->free = &slots[0];
|
||||
for (n = 0; n < capacity - 1; n++) {
|
||||
mem->slots[n] = (xp_stx_object_t*)&mem->slots[n + 1];
|
||||
mem->slots[n] = (ase_stx_object_t*)&mem->slots[n + 1];
|
||||
}
|
||||
mem->slots[n] = XP_NULL;
|
||||
mem->slots[n] = ASE_NULL;
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
void xp_stx_memory_close (xp_stx_memory_t* mem)
|
||||
void ase_stx_memory_close (ase_stx_memory_t* mem)
|
||||
{
|
||||
/* TODO: free all linked objects... */
|
||||
|
||||
xp_free (mem->slots);
|
||||
ase_free (mem->slots);
|
||||
mem->capacity = 0;
|
||||
mem->slots = XP_NULL;
|
||||
mem->free = XP_NULL;
|
||||
if (mem->__dynamic) xp_free (mem);
|
||||
mem->slots = ASE_NULL;
|
||||
mem->free = ASE_NULL;
|
||||
if (mem->__dynamic) ase_free (mem);
|
||||
}
|
||||
|
||||
void xp_stx_memory_gc (xp_stx_memory_t* mem)
|
||||
void ase_stx_memory_gc (ase_stx_memory_t* mem)
|
||||
{
|
||||
/* TODO: implement this function */
|
||||
}
|
||||
|
||||
xp_word_t xp_stx_memory_alloc (xp_stx_memory_t* mem, xp_word_t nbytes)
|
||||
ase_word_t ase_stx_memory_alloc (ase_stx_memory_t* mem, ase_word_t nbytes)
|
||||
{
|
||||
xp_stx_object_t** slot;
|
||||
xp_stx_object_t* object;
|
||||
ase_stx_object_t** slot;
|
||||
ase_stx_object_t* object;
|
||||
|
||||
/* find the free object slot */
|
||||
if (mem->free == XP_NULL) {
|
||||
xp_stx_memory_gc (mem);
|
||||
if (mem->free == XP_NULL) return mem->capacity;;
|
||||
if (mem->free == ASE_NULL) {
|
||||
ase_stx_memory_gc (mem);
|
||||
if (mem->free == ASE_NULL) return mem->capacity;;
|
||||
}
|
||||
|
||||
object = (xp_stx_object_t*)xp_malloc (nbytes);
|
||||
if (object == XP_NULL) {
|
||||
xp_stx_memory_gc (mem);
|
||||
object = (xp_stx_object_t*)xp_malloc (nbytes);
|
||||
/*if (object == XP_NULL) return mem->capacity;*/
|
||||
if (object == XP_NULL) {
|
||||
xp_assert (XP_TEXT("MEMORY ALLOCATION ERROR\n") == XP_NULL);
|
||||
object = (ase_stx_object_t*)ase_malloc (nbytes);
|
||||
if (object == ASE_NULL) {
|
||||
ase_stx_memory_gc (mem);
|
||||
object = (ase_stx_object_t*)ase_malloc (nbytes);
|
||||
/*if (object == ASE_NULL) return mem->capacity;*/
|
||||
if (object == ASE_NULL) {
|
||||
ase_assert (ASE_T("MEMORY ALLOCATION ERROR\n") == ASE_NULL);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
slot = mem->free;
|
||||
mem->free = (xp_stx_object_t**)*slot;
|
||||
mem->free = (ase_stx_object_t**)*slot;
|
||||
*slot = object;
|
||||
|
||||
return (xp_word_t)(slot - mem->slots);
|
||||
return (ase_word_t)(slot - mem->slots);
|
||||
}
|
||||
|
||||
void xp_stx_memory_dealloc (xp_stx_memory_t* mem, xp_word_t object_index)
|
||||
void ase_stx_memory_dealloc (ase_stx_memory_t* mem, ase_word_t object_index)
|
||||
{
|
||||
/*
|
||||
* THIS IS PRIMITIVE LOW-LEVEL DEALLOC. THIS WILL NOT
|
||||
* DEALLOCATE MEMORY ALLOCATED FOR ITS INSTANCE VARIABLES.
|
||||
*/
|
||||
|
||||
xp_free (mem->slots[object_index]);
|
||||
mem->slots[object_index] = (xp_stx_object_t*)mem->free;
|
||||
ase_free (mem->slots[object_index]);
|
||||
mem->slots[object_index] = (ase_stx_object_t*)mem->free;
|
||||
mem->free = &mem->slots[object_index];
|
||||
}
|
||||
|
||||
|
@ -1,23 +1,23 @@
|
||||
/*
|
||||
* $Id: memory.h,v 1.8 2005-08-18 15:28:18 bacon Exp $
|
||||
* $Id: memory.h,v 1.9 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_STX_MEMORY_H_
|
||||
#define _XP_STX_MEMORY_H_
|
||||
#ifndef _ASE_STX_MEMORY_H_
|
||||
#define _ASE_STX_MEMORY_H_
|
||||
|
||||
#include <xp/stx/stx.h>
|
||||
#include <ase/stx/stx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
xp_stx_memory_t* xp_stx_memory_open (
|
||||
xp_stx_memory_t* mem, xp_word_t capacity);
|
||||
void xp_stx_memory_close (xp_stx_memory_t* mem);
|
||||
ase_stx_memory_t* ase_stx_memory_open (
|
||||
ase_stx_memory_t* mem, ase_word_t capacity);
|
||||
void ase_stx_memory_close (ase_stx_memory_t* mem);
|
||||
|
||||
void xp_stx_memory_gc (xp_stx_memory_t* mem);
|
||||
xp_word_t xp_stx_memory_alloc (xp_stx_memory_t* mem, xp_word_t size);
|
||||
void xp_stx_memory_dealloc (xp_stx_memory_t* mem, xp_word_t object_index);
|
||||
void ase_stx_memory_gc (ase_stx_memory_t* mem);
|
||||
ase_word_t ase_stx_memory_alloc (ase_stx_memory_t* mem, ase_word_t size);
|
||||
void ase_stx_memory_dealloc (ase_stx_memory_t* mem, ase_word_t object_index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
/*
|
||||
* $Id: method.h,v 1.8 2005-09-13 11:15:41 bacon Exp $
|
||||
* $Id: method.h,v 1.9 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_STX_METHOD_H_
|
||||
#define _XP_STX_METHOD_H_
|
||||
#ifndef _ASE_STX_METHOD_H_
|
||||
#define _ASE_STX_METHOD_H_
|
||||
|
||||
#include <xp/stx/stx.h>
|
||||
#include <ase/stx/stx.h>
|
||||
|
||||
#define XP_STX_METHOD_SIZE 5
|
||||
#define XP_STX_METHOD_TEXT 0
|
||||
#define XP_STX_METHOD_SELECTOR 1
|
||||
#define XP_STX_METHOD_BYTECODES 2
|
||||
#define XP_STX_METHOD_TMPCOUNT 3
|
||||
#define XP_STX_METHOD_ARGCOUNT 4
|
||||
#define ASE_STX_METHOD_SIZE 5
|
||||
#define ASE_STX_METHOD_TEXT 0
|
||||
#define ASE_STX_METHOD_SELECTOR 1
|
||||
#define ASE_STX_METHOD_BYTECODES 2
|
||||
#define ASE_STX_METHOD_TMPCOUNT 3
|
||||
#define ASE_STX_METHOD_ARGCOUNT 4
|
||||
|
||||
|
||||
/* dolphin smalltalk's flags representation
|
||||
@ -26,18 +26,18 @@
|
||||
Block flag SmallInteger flag"
|
||||
*/
|
||||
|
||||
struct xp_stx_method_t
|
||||
struct ase_stx_method_t
|
||||
{
|
||||
xp_stx_objhdr_t header;
|
||||
xp_word_t text;
|
||||
xp_word_t selector; /* is this necessary? */
|
||||
xp_word_t bytecodes;
|
||||
xp_word_t tmpcount;
|
||||
xp_word_t argcount;
|
||||
xp_word_t literals[1];
|
||||
ase_stx_objhdr_t header;
|
||||
ase_word_t text;
|
||||
ase_word_t selector; /* is this necessary? */
|
||||
ase_word_t bytecodes;
|
||||
ase_word_t tmpcount;
|
||||
ase_word_t argcount;
|
||||
ase_word_t literals[1];
|
||||
};
|
||||
|
||||
typedef struct xp_stx_method_t xp_stx_method_t;
|
||||
typedef struct ase_stx_method_t ase_stx_method_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -1,29 +1,29 @@
|
||||
/*
|
||||
* $Id: misc.c,v 1.7 2005-07-05 11:15:51 bacon Exp $
|
||||
* $Id: misc.c,v 1.8 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/stx/misc.h>
|
||||
#include <ase/stx/misc.h>
|
||||
|
||||
xp_word_t xp_stx_hash (const void* data, xp_word_t len)
|
||||
ase_word_t ase_stx_hash (const void* data, ase_word_t len)
|
||||
{
|
||||
xp_word_t h = 0;
|
||||
xp_byte_t* bp, * be;
|
||||
ase_word_t h = 0;
|
||||
ase_byte_t* bp, * be;
|
||||
|
||||
bp = (xp_byte_t*)data; be = bp + len;
|
||||
bp = (ase_byte_t*)data; be = bp + len;
|
||||
while (bp < be) h = h * 31 + *bp++;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
xp_word_t xp_stx_strhash (const xp_char_t* str)
|
||||
ase_word_t ase_stx_strhash (const ase_char_t* str)
|
||||
{
|
||||
xp_word_t h = 0;
|
||||
xp_byte_t* bp, * be;
|
||||
const xp_char_t* p = str;
|
||||
ase_word_t h = 0;
|
||||
ase_byte_t* bp, * be;
|
||||
const ase_char_t* p = str;
|
||||
|
||||
while (*p != XP_CHAR('\0')) {
|
||||
bp = (xp_byte_t*)p;
|
||||
be = bp + xp_sizeof(xp_char_t);
|
||||
while (*p != ASE_T('\0')) {
|
||||
bp = (ase_byte_t*)p;
|
||||
be = bp + ase_sizeof(ase_char_t);
|
||||
while (bp < be) h = h * 31 + *bp++;
|
||||
p++;
|
||||
}
|
||||
@ -31,15 +31,15 @@ xp_word_t xp_stx_strhash (const xp_char_t* str)
|
||||
return h;
|
||||
}
|
||||
|
||||
xp_word_t xp_stx_strxhash (const xp_char_t* str, xp_word_t len)
|
||||
ase_word_t ase_stx_strxhash (const ase_char_t* str, ase_word_t len)
|
||||
{
|
||||
xp_word_t h = 0;
|
||||
xp_byte_t* bp, * be;
|
||||
const xp_char_t* p = str, * end = str + len;
|
||||
ase_word_t h = 0;
|
||||
ase_byte_t* bp, * be;
|
||||
const ase_char_t* p = str, * end = str + len;
|
||||
|
||||
while (p < end) {
|
||||
bp = (xp_byte_t*)p;
|
||||
be = bp + xp_sizeof(xp_char_t);
|
||||
bp = (ase_byte_t*)p;
|
||||
be = bp + ase_sizeof(ase_char_t);
|
||||
while (bp < be) h = h * 31 + *bp++;
|
||||
p++;
|
||||
}
|
||||
@ -47,17 +47,17 @@ xp_word_t xp_stx_strxhash (const xp_char_t* str, xp_word_t len)
|
||||
return h;
|
||||
}
|
||||
|
||||
xp_char_t* xp_stx_strword (
|
||||
const xp_char_t* str, const xp_char_t* word, xp_word_t* word_index)
|
||||
ase_char_t* ase_stx_strword (
|
||||
const ase_char_t* str, const ase_char_t* word, ase_word_t* word_index)
|
||||
{
|
||||
xp_char_t* p = (xp_char_t*)str;
|
||||
xp_char_t* tok;
|
||||
xp_size_t len;
|
||||
xp_word_t index = 0;
|
||||
ase_char_t* p = (ase_char_t*)str;
|
||||
ase_char_t* tok;
|
||||
ase_size_t len;
|
||||
ase_word_t index = 0;
|
||||
|
||||
while (p != XP_NULL) {
|
||||
p = xp_strtok (p, XP_TEXT(""), &tok, &len);
|
||||
if (xp_strxcmp (tok, len, word) == 0) {
|
||||
while (p != ASE_NULL) {
|
||||
p = ase_strtok (p, ASE_T(""), &tok, &len);
|
||||
if (ase_strxcmp (tok, len, word) == 0) {
|
||||
*word_index = index;
|
||||
return tok;
|
||||
}
|
||||
@ -66,5 +66,5 @@ xp_char_t* xp_stx_strword (
|
||||
}
|
||||
|
||||
*word_index = index;
|
||||
return XP_NULL;
|
||||
return ASE_NULL;
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
/*
|
||||
* $Id: misc.h,v 1.15 2005-08-18 15:28:18 bacon Exp $
|
||||
* $Id: misc.h,v 1.16 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_STX_MISC_H_
|
||||
#define _XP_STX_MISC_H_
|
||||
#ifndef _ASE_STX_MISC_H_
|
||||
#define _ASE_STX_MISC_H_
|
||||
|
||||
#include <xp/stx/stx.h>
|
||||
#include <ase/stx/stx.h>
|
||||
|
||||
/* TODO: remove this header later */
|
||||
#include <xp/bas/stdio.h>
|
||||
#include <ase/bas/stdio.h>
|
||||
|
||||
#ifdef _DOS
|
||||
#include <stdlib.h>
|
||||
@ -18,25 +18,25 @@
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define xp_assert assert
|
||||
#define xp_malloc malloc
|
||||
#define xp_realloc realloc
|
||||
#define xp_free free
|
||||
#define xp_va_list va_list
|
||||
#define xp_va_start va_start
|
||||
#define xp_va_end va_end
|
||||
#define xp_va_arg va_arg
|
||||
#define xp_isspace isspace
|
||||
#define xp_isdigit isdigit
|
||||
#define xp_isalpha isalpha
|
||||
#define xp_isalnum isalnum
|
||||
#define ase_assert assert
|
||||
#define ase_malloc malloc
|
||||
#define ase_realloc realloc
|
||||
#define ase_free free
|
||||
#define ase_va_list va_list
|
||||
#define ase_va_start va_start
|
||||
#define ase_va_end va_end
|
||||
#define ase_va_arg va_arg
|
||||
#define ase_isspace isspace
|
||||
#define ase_isdigit isdigit
|
||||
#define ase_isalpha isalpha
|
||||
#define ase_isalnum isalnum
|
||||
#else
|
||||
#include <xp/bas/memory.h>
|
||||
#include <xp/bas/assert.h>
|
||||
#include <xp/bas/stdarg.h>
|
||||
#include <xp/bas/ctype.h>
|
||||
#include <xp/bas/string.h>
|
||||
#include <xp/bas/stdlib.h>
|
||||
#include <ase/bas/memory.h>
|
||||
#include <ase/bas/assert.h>
|
||||
#include <ase/bas/stdarg.h>
|
||||
#include <ase/bas/ctype.h>
|
||||
#include <ase/bas/string.h>
|
||||
#include <ase/bas/stdlib.h>
|
||||
#endif
|
||||
|
||||
#if defined(__BORLANDC__) || defined(_MSC_VER)
|
||||
@ -49,12 +49,12 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
xp_word_t xp_stx_hash (const void* data, xp_word_t len);
|
||||
xp_word_t xp_stx_strhash (const xp_char_t* str);
|
||||
xp_word_t xp_stx_strxhash (const xp_char_t* str, xp_word_t len);
|
||||
ase_word_t ase_stx_hash (const void* data, ase_word_t len);
|
||||
ase_word_t ase_stx_strhash (const ase_char_t* str);
|
||||
ase_word_t ase_stx_strxhash (const ase_char_t* str, ase_word_t len);
|
||||
|
||||
xp_char_t* xp_stx_strword (
|
||||
const xp_char_t* str, const xp_char_t* word, xp_word_t* word_index);
|
||||
ase_char_t* ase_stx_strword (
|
||||
const ase_char_t* str, const ase_char_t* word, ase_word_t* word_index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
122
ase/stx/name.c
122
ase/stx/name.c
@ -1,74 +1,74 @@
|
||||
/*
|
||||
* $Id: name.c,v 1.3 2005-12-05 15:11:29 bacon Exp $
|
||||
* $Id: name.c,v 1.4 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/stx/name.h>
|
||||
#include <xp/stx/misc.h>
|
||||
#include <ase/stx/name.h>
|
||||
#include <ase/stx/misc.h>
|
||||
|
||||
xp_stx_name_t* xp_stx_name_open (
|
||||
xp_stx_name_t* name, xp_word_t capacity)
|
||||
ase_stx_name_t* ase_stx_name_open (
|
||||
ase_stx_name_t* name, ase_word_t capacity)
|
||||
{
|
||||
if (capacity == 0)
|
||||
capacity = xp_countof(name->static_buffer) - 1;
|
||||
capacity = ase_countof(name->static_buffer) - 1;
|
||||
|
||||
if (name == XP_NULL) {
|
||||
name = (xp_stx_name_t*)
|
||||
xp_malloc (xp_sizeof(xp_stx_name_t));
|
||||
if (name == XP_NULL) return XP_NULL;
|
||||
name->__dynamic = xp_true;
|
||||
if (name == ASE_NULL) {
|
||||
name = (ase_stx_name_t*)
|
||||
ase_malloc (ase_sizeof(ase_stx_name_t));
|
||||
if (name == ASE_NULL) return ASE_NULL;
|
||||
name->__dynamic = ase_true;
|
||||
}
|
||||
else name->__dynamic = xp_false;
|
||||
else name->__dynamic = ase_false;
|
||||
|
||||
if (capacity < xp_countof(name->static_buffer)) {
|
||||
if (capacity < ase_countof(name->static_buffer)) {
|
||||
name->buffer = name->static_buffer;
|
||||
}
|
||||
else {
|
||||
name->buffer = (xp_char_t*)
|
||||
xp_malloc ((capacity + 1) * xp_sizeof(xp_char_t));
|
||||
if (name->buffer == XP_NULL) {
|
||||
if (name->__dynamic) xp_free (name);
|
||||
return XP_NULL;
|
||||
name->buffer = (ase_char_t*)
|
||||
ase_malloc ((capacity + 1) * ase_sizeof(ase_char_t));
|
||||
if (name->buffer == ASE_NULL) {
|
||||
if (name->__dynamic) ase_free (name);
|
||||
return ASE_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
name->size = 0;
|
||||
name->capacity = capacity;
|
||||
name->buffer[0] = XP_CHAR('\0');
|
||||
name->buffer[0] = ASE_T('\0');
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
void xp_stx_name_close (xp_stx_name_t* name)
|
||||
void ase_stx_name_close (ase_stx_name_t* name)
|
||||
{
|
||||
if (name->capacity >= xp_countof(name->static_buffer)) {
|
||||
xp_assert (name->buffer != name->static_buffer);
|
||||
xp_free (name->buffer);
|
||||
if (name->capacity >= ase_countof(name->static_buffer)) {
|
||||
ase_assert (name->buffer != name->static_buffer);
|
||||
ase_free (name->buffer);
|
||||
}
|
||||
if (name->__dynamic) xp_free (name);
|
||||
if (name->__dynamic) ase_free (name);
|
||||
}
|
||||
|
||||
int xp_stx_name_addc (xp_stx_name_t* name, xp_cint_t c)
|
||||
int ase_stx_name_addc (ase_stx_name_t* name, ase_cint_t c)
|
||||
{
|
||||
if (name->size >= name->capacity) {
|
||||
/* double the capacity. */
|
||||
xp_size_t new_capacity = name->capacity * 2;
|
||||
ase_size_t new_capacity = name->capacity * 2;
|
||||
|
||||
if (new_capacity >= xp_countof(name->static_buffer)) {
|
||||
xp_char_t* space;
|
||||
if (new_capacity >= ase_countof(name->static_buffer)) {
|
||||
ase_char_t* space;
|
||||
|
||||
if (name->capacity < xp_countof(name->static_buffer)) {
|
||||
space = (xp_char_t*)xp_malloc (
|
||||
(new_capacity + 1) * xp_sizeof(xp_char_t));
|
||||
if (space == XP_NULL) return -1;
|
||||
if (name->capacity < ase_countof(name->static_buffer)) {
|
||||
space = (ase_char_t*)ase_malloc (
|
||||
(new_capacity + 1) * ase_sizeof(ase_char_t));
|
||||
if (space == ASE_NULL) return -1;
|
||||
|
||||
/* don't need to copy up to the terminating null */
|
||||
xp_memcpy (space, name->buffer,
|
||||
name->capacity * xp_sizeof(xp_char_t));
|
||||
ase_memcpy (space, name->buffer,
|
||||
name->capacity * ase_sizeof(ase_char_t));
|
||||
}
|
||||
else {
|
||||
space = (xp_char_t*)xp_realloc (name->buffer,
|
||||
(new_capacity + 1) * xp_sizeof(xp_char_t));
|
||||
if (space == XP_NULL) return -1;
|
||||
space = (ase_char_t*)ase_realloc (name->buffer,
|
||||
(new_capacity + 1) * ase_sizeof(ase_char_t));
|
||||
if (space == ASE_NULL) return -1;
|
||||
}
|
||||
|
||||
name->buffer = space;
|
||||
@ -78,63 +78,63 @@ int xp_stx_name_addc (xp_stx_name_t* name, xp_cint_t c)
|
||||
}
|
||||
|
||||
name->buffer[name->size++] = c;
|
||||
name->buffer[name->size] = XP_CHAR('\0');
|
||||
name->buffer[name->size] = ASE_T('\0');
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xp_stx_name_adds (xp_stx_name_t* name, const xp_char_t* s)
|
||||
int ase_stx_name_adds (ase_stx_name_t* name, const ase_char_t* s)
|
||||
{
|
||||
while (*s != XP_CHAR('\0')) {
|
||||
if (xp_stx_name_addc(name, *s) == -1) return -1;
|
||||
while (*s != ASE_T('\0')) {
|
||||
if (ase_stx_name_addc(name, *s) == -1) return -1;
|
||||
s++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void xp_stx_name_clear (xp_stx_name_t* name)
|
||||
void ase_stx_name_clear (ase_stx_name_t* name)
|
||||
{
|
||||
name->size = 0;
|
||||
name->buffer[0] = XP_CHAR('\0');
|
||||
name->buffer[0] = ASE_T('\0');
|
||||
}
|
||||
|
||||
xp_char_t* xp_stx_name_yield (xp_stx_name_t* name, xp_word_t capacity)
|
||||
ase_char_t* ase_stx_name_yield (ase_stx_name_t* name, ase_word_t capacity)
|
||||
{
|
||||
xp_char_t* old_buffer, * new_buffer;
|
||||
ase_char_t* old_buffer, * new_buffer;
|
||||
|
||||
if (capacity == 0)
|
||||
capacity = xp_countof(name->static_buffer) - 1;
|
||||
capacity = ase_countof(name->static_buffer) - 1;
|
||||
|
||||
if (name->capacity < xp_countof(name->static_buffer)) {
|
||||
old_buffer = (xp_char_t*)
|
||||
xp_malloc((name->capacity + 1) * xp_sizeof(xp_char_t));
|
||||
if (old_buffer == XP_NULL) return XP_NULL;
|
||||
xp_memcpy (old_buffer, name->buffer,
|
||||
(name->capacity + 1) * xp_sizeof(xp_char_t));
|
||||
if (name->capacity < ase_countof(name->static_buffer)) {
|
||||
old_buffer = (ase_char_t*)
|
||||
ase_malloc((name->capacity + 1) * ase_sizeof(ase_char_t));
|
||||
if (old_buffer == ASE_NULL) return ASE_NULL;
|
||||
ase_memcpy (old_buffer, name->buffer,
|
||||
(name->capacity + 1) * ase_sizeof(ase_char_t));
|
||||
}
|
||||
else old_buffer = name->buffer;
|
||||
|
||||
if (capacity < xp_countof(name->static_buffer)) {
|
||||
if (capacity < ase_countof(name->static_buffer)) {
|
||||
new_buffer = name->static_buffer;
|
||||
}
|
||||
else {
|
||||
new_buffer = (xp_char_t*)
|
||||
xp_malloc((capacity + 1) * xp_sizeof(xp_char_t));
|
||||
if (new_buffer == XP_NULL) return XP_NULL;
|
||||
new_buffer = (ase_char_t*)
|
||||
ase_malloc((capacity + 1) * ase_sizeof(ase_char_t));
|
||||
if (new_buffer == ASE_NULL) return ASE_NULL;
|
||||
}
|
||||
|
||||
name->buffer = new_buffer;
|
||||
name->size = 0;
|
||||
name->capacity = capacity;
|
||||
name->buffer[0] = XP_CHAR('\0');
|
||||
name->buffer[0] = ASE_T('\0');
|
||||
|
||||
return old_buffer;
|
||||
}
|
||||
|
||||
int xp_stx_name_compare (xp_stx_name_t* name, const xp_char_t* str)
|
||||
int ase_stx_name_compare (ase_stx_name_t* name, const ase_char_t* str)
|
||||
{
|
||||
xp_char_t* p = name->buffer;
|
||||
xp_word_t index = 0;
|
||||
ase_char_t* p = name->buffer;
|
||||
ase_word_t index = 0;
|
||||
|
||||
while (index < name->size) {
|
||||
if (*p > *str) return 1;
|
||||
@ -142,5 +142,5 @@ int xp_stx_name_compare (xp_stx_name_t* name, const xp_char_t* str)
|
||||
index++; p++; str++;
|
||||
}
|
||||
|
||||
return (*str == XP_CHAR('\0'))? 0: -1;
|
||||
return (*str == ASE_T('\0'))? 0: -1;
|
||||
}
|
||||
|
@ -1,36 +1,36 @@
|
||||
/*
|
||||
* $Id: name.h,v 1.4 2005-12-05 15:11:29 bacon Exp $
|
||||
* $Id: name.h,v 1.5 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_STX_NAME_H_
|
||||
#define _XP_STX_NAME_H_
|
||||
#ifndef _ASE_STX_NAME_H_
|
||||
#define _ASE_STX_NAME_H_
|
||||
|
||||
#include <xp/stx/stx.h>
|
||||
#include <ase/stx/stx.h>
|
||||
|
||||
struct xp_stx_name_t
|
||||
struct ase_stx_name_t
|
||||
{
|
||||
xp_word_t capacity;
|
||||
xp_word_t size;
|
||||
xp_char_t* buffer;
|
||||
xp_char_t static_buffer[128];
|
||||
xp_bool_t __dynamic;
|
||||
ase_word_t capacity;
|
||||
ase_word_t size;
|
||||
ase_char_t* buffer;
|
||||
ase_char_t static_buffer[128];
|
||||
ase_bool_t __dynamic;
|
||||
};
|
||||
|
||||
typedef struct xp_stx_name_t xp_stx_name_t;
|
||||
typedef struct ase_stx_name_t ase_stx_name_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
xp_stx_name_t* xp_stx_name_open (
|
||||
xp_stx_name_t* name, xp_word_t capacity);
|
||||
void xp_stx_name_close (xp_stx_name_t* name);
|
||||
ase_stx_name_t* ase_stx_name_open (
|
||||
ase_stx_name_t* name, ase_word_t capacity);
|
||||
void ase_stx_name_close (ase_stx_name_t* name);
|
||||
|
||||
int xp_stx_name_addc (xp_stx_name_t* name, xp_cint_t c);
|
||||
int xp_stx_name_adds (xp_stx_name_t* name, const xp_char_t* s);
|
||||
void xp_stx_name_clear (xp_stx_name_t* name);
|
||||
xp_char_t* xp_stx_name_yield (xp_stx_name_t* name, xp_word_t capacity);
|
||||
int xp_stx_name_compare (xp_stx_name_t* name, const xp_char_t* str);
|
||||
int ase_stx_name_addc (ase_stx_name_t* name, ase_cint_t c);
|
||||
int ase_stx_name_adds (ase_stx_name_t* name, const ase_char_t* s);
|
||||
void ase_stx_name_clear (ase_stx_name_t* name);
|
||||
ase_char_t* ase_stx_name_yield (ase_stx_name_t* name, ase_word_t capacity);
|
||||
int ase_stx_name_compare (ase_stx_name_t* name, const ase_char_t* str);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
232
ase/stx/object.c
232
ase/stx/object.c
@ -1,38 +1,38 @@
|
||||
/*
|
||||
* $Id: object.c,v 1.40 2005-07-19 16:09:34 bacon Exp $
|
||||
* $Id: object.c,v 1.41 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/stx/object.h>
|
||||
#include <xp/stx/memory.h>
|
||||
#include <xp/stx/symbol.h>
|
||||
#include <xp/stx/class.h>
|
||||
#include <xp/stx/misc.h>
|
||||
#include <ase/stx/object.h>
|
||||
#include <ase/stx/memory.h>
|
||||
#include <ase/stx/symbol.h>
|
||||
#include <ase/stx/class.h>
|
||||
#include <ase/stx/misc.h>
|
||||
|
||||
/* n: number of instance variables */
|
||||
xp_word_t xp_stx_alloc_word_object (
|
||||
xp_stx_t* stx, const xp_word_t* data, xp_word_t nfields,
|
||||
const xp_word_t* variable_data, xp_word_t variable_nfields)
|
||||
ase_word_t ase_stx_alloc_word_object (
|
||||
ase_stx_t* stx, const ase_word_t* data, ase_word_t nfields,
|
||||
const ase_word_t* variable_data, ase_word_t variable_nfields)
|
||||
{
|
||||
xp_word_t idx, n;
|
||||
xp_stx_word_object_t* obj;
|
||||
ase_word_t idx, n;
|
||||
ase_stx_word_object_t* obj;
|
||||
|
||||
xp_assert (stx->nil == XP_STX_NIL);
|
||||
ase_assert (stx->nil == ASE_STX_NIL);
|
||||
|
||||
/* bytes to allocated =
|
||||
* (number of instance variables +
|
||||
* number of variable instance variables) * word_size
|
||||
*/
|
||||
n = nfields + variable_nfields;
|
||||
idx = xp_stx_memory_alloc (&stx->memory,
|
||||
n * xp_sizeof(xp_word_t) + xp_sizeof(xp_stx_object_t));
|
||||
idx = ase_stx_memory_alloc (&stx->memory,
|
||||
n * ase_sizeof(ase_word_t) + ase_sizeof(ase_stx_object_t));
|
||||
if (idx >= stx->memory.capacity) return idx; /* failed TODO: return a difference value OINDEX_INVALID */
|
||||
|
||||
idx = XP_STX_TO_OINDEX(idx);
|
||||
obj = XP_STX_WORD_OBJECT(stx,idx);
|
||||
idx = ASE_STX_TO_OINDEX(idx);
|
||||
obj = ASE_STX_WORD_OBJECT(stx,idx);
|
||||
obj->header.class = stx->nil;
|
||||
obj->header.access = (n << 2) | XP_STX_WORD_INDEXED;
|
||||
obj->header.access = (n << 2) | ASE_STX_WORD_INDEXED;
|
||||
|
||||
if (variable_data == XP_NULL) {
|
||||
if (variable_data == ASE_NULL) {
|
||||
while (n > nfields) obj->data[--n] = stx->nil;
|
||||
}
|
||||
else {
|
||||
@ -41,7 +41,7 @@ xp_word_t xp_stx_alloc_word_object (
|
||||
}
|
||||
}
|
||||
|
||||
if (data == XP_NULL) {
|
||||
if (data == ASE_NULL) {
|
||||
while (n > 0) obj->data[--n] = stx->nil;
|
||||
}
|
||||
else {
|
||||
@ -54,24 +54,24 @@ xp_word_t xp_stx_alloc_word_object (
|
||||
}
|
||||
|
||||
/* n: number of bytes */
|
||||
xp_word_t xp_stx_alloc_byte_object (
|
||||
xp_stx_t* stx, const xp_byte_t* data, xp_word_t n)
|
||||
ase_word_t ase_stx_alloc_byte_object (
|
||||
ase_stx_t* stx, const ase_byte_t* data, ase_word_t n)
|
||||
{
|
||||
xp_word_t idx;
|
||||
xp_stx_byte_object_t* obj;
|
||||
ase_word_t idx;
|
||||
ase_stx_byte_object_t* obj;
|
||||
|
||||
xp_assert (stx->nil == XP_STX_NIL);
|
||||
ase_assert (stx->nil == ASE_STX_NIL);
|
||||
|
||||
idx = xp_stx_memory_alloc (
|
||||
&stx->memory, n + xp_sizeof(xp_stx_object_t));
|
||||
idx = ase_stx_memory_alloc (
|
||||
&stx->memory, n + ase_sizeof(ase_stx_object_t));
|
||||
if (idx >= stx->memory.capacity) return idx; /* failed */
|
||||
|
||||
idx = XP_STX_TO_OINDEX(idx);
|
||||
obj = XP_STX_BYTE_OBJECT(stx,idx);
|
||||
idx = ASE_STX_TO_OINDEX(idx);
|
||||
obj = ASE_STX_BYTE_OBJECT(stx,idx);
|
||||
obj->header.class = stx->nil;
|
||||
obj->header.access = (n << 2) | XP_STX_BYTE_INDEXED;
|
||||
obj->header.access = (n << 2) | ASE_STX_BYTE_INDEXED;
|
||||
|
||||
if (data == XP_NULL) {
|
||||
if (data == ASE_NULL) {
|
||||
while (n-- > 0) obj->data[n] = 0;
|
||||
}
|
||||
else {
|
||||
@ -81,35 +81,35 @@ xp_word_t xp_stx_alloc_byte_object (
|
||||
return idx;
|
||||
}
|
||||
|
||||
xp_word_t xp_stx_alloc_char_object (
|
||||
xp_stx_t* stx, const xp_char_t* str)
|
||||
ase_word_t ase_stx_alloc_char_object (
|
||||
ase_stx_t* stx, const ase_char_t* str)
|
||||
{
|
||||
return (str == XP_NULL)?
|
||||
xp_stx_alloc_char_objectx (stx, XP_NULL, 0):
|
||||
xp_stx_alloc_char_objectx (stx, str, xp_strlen(str));
|
||||
return (str == ASE_NULL)?
|
||||
ase_stx_alloc_char_objectx (stx, ASE_NULL, 0):
|
||||
ase_stx_alloc_char_objectx (stx, str, ase_strlen(str));
|
||||
}
|
||||
|
||||
/* n: number of characters */
|
||||
xp_word_t xp_stx_alloc_char_objectx (
|
||||
xp_stx_t* stx, const xp_char_t* str, xp_word_t n)
|
||||
ase_word_t ase_stx_alloc_char_objectx (
|
||||
ase_stx_t* stx, const ase_char_t* str, ase_word_t n)
|
||||
{
|
||||
xp_word_t idx;
|
||||
xp_stx_char_object_t* obj;
|
||||
ase_word_t idx;
|
||||
ase_stx_char_object_t* obj;
|
||||
|
||||
xp_assert (stx->nil == XP_STX_NIL);
|
||||
ase_assert (stx->nil == ASE_STX_NIL);
|
||||
|
||||
idx = xp_stx_memory_alloc (&stx->memory,
|
||||
(n + 1) * xp_sizeof(xp_char_t) + xp_sizeof(xp_stx_object_t));
|
||||
idx = ase_stx_memory_alloc (&stx->memory,
|
||||
(n + 1) * ase_sizeof(ase_char_t) + ase_sizeof(ase_stx_object_t));
|
||||
if (idx >= stx->memory.capacity) return idx; /* failed */
|
||||
|
||||
idx = XP_STX_TO_OINDEX(idx);
|
||||
obj = XP_STX_CHAR_OBJECT(stx,idx);
|
||||
idx = ASE_STX_TO_OINDEX(idx);
|
||||
obj = ASE_STX_CHAR_OBJECT(stx,idx);
|
||||
obj->header.class = stx->nil;
|
||||
obj->header.access = (n << 2) | XP_STX_CHAR_INDEXED;
|
||||
obj->data[n] = XP_CHAR('\0');
|
||||
obj->header.access = (n << 2) | ASE_STX_CHAR_INDEXED;
|
||||
obj->data[n] = ASE_T('\0');
|
||||
|
||||
if (str == XP_NULL) {
|
||||
while (n-- > 0) obj->data[n] = XP_CHAR('\0');
|
||||
if (str == ASE_NULL) {
|
||||
while (n-- > 0) obj->data[n] = ASE_T('\0');
|
||||
}
|
||||
else {
|
||||
while (n-- > 0) obj->data[n] = str[n];
|
||||
@ -118,129 +118,129 @@ xp_word_t xp_stx_alloc_char_objectx (
|
||||
return idx;
|
||||
}
|
||||
|
||||
xp_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...)
|
||||
ase_word_t ase_stx_allocn_char_object (ase_stx_t* stx, ...)
|
||||
{
|
||||
xp_word_t idx, n = 0;
|
||||
const xp_char_t* p;
|
||||
xp_va_list ap;
|
||||
xp_stx_char_object_t* obj;
|
||||
ase_word_t idx, n = 0;
|
||||
const ase_char_t* p;
|
||||
ase_va_list ap;
|
||||
ase_stx_char_object_t* obj;
|
||||
|
||||
xp_assert (stx->nil == XP_STX_NIL);
|
||||
ase_assert (stx->nil == ASE_STX_NIL);
|
||||
|
||||
xp_va_start (ap, stx);
|
||||
while ((p = xp_va_arg(ap, const xp_char_t*)) != XP_NULL) {
|
||||
n += xp_strlen(p);
|
||||
ase_va_start (ap, stx);
|
||||
while ((p = ase_va_arg(ap, const ase_char_t*)) != ASE_NULL) {
|
||||
n += ase_strlen(p);
|
||||
}
|
||||
xp_va_end (ap);
|
||||
ase_va_end (ap);
|
||||
|
||||
idx = xp_stx_memory_alloc (&stx->memory,
|
||||
(n + 1) * xp_sizeof(xp_char_t) + xp_sizeof(xp_stx_object_t));
|
||||
idx = ase_stx_memory_alloc (&stx->memory,
|
||||
(n + 1) * ase_sizeof(ase_char_t) + ase_sizeof(ase_stx_object_t));
|
||||
if (idx >= stx->memory.capacity) return idx; /* failed */
|
||||
|
||||
idx = XP_STX_TO_OINDEX(idx);
|
||||
obj = XP_STX_CHAR_OBJECT(stx,idx);
|
||||
idx = ASE_STX_TO_OINDEX(idx);
|
||||
obj = ASE_STX_CHAR_OBJECT(stx,idx);
|
||||
obj->header.class = stx->nil;
|
||||
obj->header.access = (n << 2) | XP_STX_CHAR_INDEXED;
|
||||
obj->data[n] = XP_CHAR('\0');
|
||||
obj->header.access = (n << 2) | ASE_STX_CHAR_INDEXED;
|
||||
obj->data[n] = ASE_T('\0');
|
||||
|
||||
xp_va_start (ap, stx);
|
||||
ase_va_start (ap, stx);
|
||||
n = 0;
|
||||
while ((p = xp_va_arg(ap, const xp_char_t*)) != XP_NULL) {
|
||||
while (*p != XP_CHAR('\0')) {
|
||||
/*XP_STX_CHAR_AT(stx,idx,n++) = *p++;*/
|
||||
while ((p = ase_va_arg(ap, const ase_char_t*)) != ASE_NULL) {
|
||||
while (*p != ASE_T('\0')) {
|
||||
/*ASE_STX_CHAR_AT(stx,idx,n++) = *p++;*/
|
||||
obj->data[n++] = *p++;
|
||||
}
|
||||
}
|
||||
xp_va_end (ap);
|
||||
ase_va_end (ap);
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
xp_word_t xp_stx_hash_object (xp_stx_t* stx, xp_word_t object)
|
||||
ase_word_t ase_stx_hash_object (ase_stx_t* stx, ase_word_t object)
|
||||
{
|
||||
xp_word_t hv;
|
||||
ase_word_t hv;
|
||||
|
||||
if (XP_STX_IS_SMALLINT(object)) {
|
||||
xp_word_t tmp = XP_STX_FROM_SMALLINT(object);
|
||||
hv = xp_stx_hash(&tmp, xp_sizeof(tmp));
|
||||
if (ASE_STX_IS_SMALLINT(object)) {
|
||||
ase_word_t tmp = ASE_STX_FROM_SMALLINT(object);
|
||||
hv = ase_stx_hash(&tmp, ase_sizeof(tmp));
|
||||
}
|
||||
else if (XP_STX_IS_CHAR_OBJECT(stx,object)) {
|
||||
else if (ASE_STX_IS_CHAR_OBJECT(stx,object)) {
|
||||
/* the additional null is not taken into account */
|
||||
hv = xp_stx_hash (XP_STX_DATA(stx,object),
|
||||
XP_STX_SIZE(stx,object) * xp_sizeof(xp_char_t));
|
||||
hv = ase_stx_hash (ASE_STX_DATA(stx,object),
|
||||
ASE_STX_SIZE(stx,object) * ase_sizeof(ase_char_t));
|
||||
}
|
||||
else if (XP_STX_IS_BYTE_OBJECT(stx,object)) {
|
||||
hv = xp_stx_hash (
|
||||
XP_STX_DATA(stx,object), XP_STX_SIZE(stx,object));
|
||||
else if (ASE_STX_IS_BYTE_OBJECT(stx,object)) {
|
||||
hv = ase_stx_hash (
|
||||
ASE_STX_DATA(stx,object), ASE_STX_SIZE(stx,object));
|
||||
}
|
||||
else {
|
||||
xp_assert (XP_STX_IS_WORD_OBJECT(stx,object));
|
||||
hv = xp_stx_hash (XP_STX_DATA(stx,object),
|
||||
XP_STX_SIZE(stx,object) * xp_sizeof(xp_word_t));
|
||||
ase_assert (ASE_STX_IS_WORD_OBJECT(stx,object));
|
||||
hv = ase_stx_hash (ASE_STX_DATA(stx,object),
|
||||
ASE_STX_SIZE(stx,object) * ase_sizeof(ase_word_t));
|
||||
}
|
||||
|
||||
return hv;
|
||||
}
|
||||
|
||||
xp_word_t xp_stx_instantiate (
|
||||
xp_stx_t* stx, xp_word_t class, const void* data,
|
||||
const void* variable_data, xp_word_t variable_nfields)
|
||||
ase_word_t ase_stx_instantiate (
|
||||
ase_stx_t* stx, ase_word_t class, const void* data,
|
||||
const void* variable_data, ase_word_t variable_nfields)
|
||||
{
|
||||
xp_stx_class_t* class_obj;
|
||||
xp_word_t spec, nfields, new;
|
||||
ase_stx_class_t* class_obj;
|
||||
ase_word_t spec, nfields, new;
|
||||
int indexable;
|
||||
|
||||
xp_assert (class != stx->class_smallinteger);
|
||||
class_obj = (xp_stx_class_t*)XP_STX_OBJECT(stx, class);
|
||||
ase_assert (class != stx->class_smallinteger);
|
||||
class_obj = (ase_stx_class_t*)ASE_STX_OBJECT(stx, class);
|
||||
|
||||
/* don't instantiate a metaclass whose instance must be
|
||||
created in a different way */
|
||||
/* TODO: maybe delete the following line */
|
||||
xp_assert (class_obj->header.class != stx->class_metaclass);
|
||||
xp_assert (XP_STX_IS_SMALLINT(class_obj->spec));
|
||||
ase_assert (class_obj->header.class != stx->class_metaclass);
|
||||
ase_assert (ASE_STX_IS_SMALLINT(class_obj->spec));
|
||||
|
||||
spec = XP_STX_FROM_SMALLINT(class_obj->spec);
|
||||
nfields = (spec >> XP_STX_SPEC_INDEXABLE_BITS);
|
||||
indexable = spec & XP_STX_SPEC_INDEXABLE_MASK;
|
||||
spec = ASE_STX_FROM_SMALLINT(class_obj->spec);
|
||||
nfields = (spec >> ASE_STX_SPEC_INDEXABLE_BITS);
|
||||
indexable = spec & ASE_STX_SPEC_INDEXABLE_MASK;
|
||||
|
||||
if (indexable == XP_STX_SPEC_BYTE_INDEXABLE) {
|
||||
xp_assert (nfields == 0 && data == XP_NULL);
|
||||
new = xp_stx_alloc_byte_object(
|
||||
if (indexable == ASE_STX_SPEC_BYTE_INDEXABLE) {
|
||||
ase_assert (nfields == 0 && data == ASE_NULL);
|
||||
new = ase_stx_alloc_byte_object(
|
||||
stx, variable_data, variable_nfields);
|
||||
}
|
||||
else if (indexable == XP_STX_SPEC_CHAR_INDEXABLE) {
|
||||
xp_assert (nfields == 0 && data == XP_NULL);
|
||||
new = xp_stx_alloc_char_objectx(
|
||||
else if (indexable == ASE_STX_SPEC_CHAR_INDEXABLE) {
|
||||
ase_assert (nfields == 0 && data == ASE_NULL);
|
||||
new = ase_stx_alloc_char_objectx(
|
||||
stx, variable_data, variable_nfields);
|
||||
}
|
||||
else if (indexable == XP_STX_SPEC_WORD_INDEXABLE) {
|
||||
new = xp_stx_alloc_word_object (
|
||||
else if (indexable == ASE_STX_SPEC_WORD_INDEXABLE) {
|
||||
new = ase_stx_alloc_word_object (
|
||||
stx, data, nfields, variable_data, variable_nfields);
|
||||
}
|
||||
else {
|
||||
xp_assert (indexable == XP_STX_SPEC_NOT_INDEXABLE);
|
||||
xp_assert (variable_nfields == 0 && variable_data == XP_NULL);
|
||||
new = xp_stx_alloc_word_object (
|
||||
stx, data, nfields, XP_NULL, 0);
|
||||
ase_assert (indexable == ASE_STX_SPEC_NOT_INDEXABLE);
|
||||
ase_assert (variable_nfields == 0 && variable_data == ASE_NULL);
|
||||
new = ase_stx_alloc_word_object (
|
||||
stx, data, nfields, ASE_NULL, 0);
|
||||
}
|
||||
|
||||
XP_STX_CLASS(stx, new) = class;
|
||||
ASE_STX_CLASS(stx, new) = class;
|
||||
return new;
|
||||
}
|
||||
|
||||
xp_word_t xp_stx_class (xp_stx_t* stx, xp_word_t obj)
|
||||
ase_word_t ase_stx_class (ase_stx_t* stx, ase_word_t obj)
|
||||
{
|
||||
return XP_STX_IS_SMALLINT(obj)?
|
||||
stx->class_smallinteger: XP_STX_CLASS(stx,obj);
|
||||
return ASE_STX_IS_SMALLINT(obj)?
|
||||
stx->class_smallinteger: ASE_STX_CLASS(stx,obj);
|
||||
}
|
||||
|
||||
xp_word_t xp_stx_classof (xp_stx_t* stx, xp_word_t obj)
|
||||
ase_word_t ase_stx_classof (ase_stx_t* stx, ase_word_t obj)
|
||||
{
|
||||
return XP_STX_IS_SMALLINT(obj)?
|
||||
stx->class_smallinteger: XP_STX_CLASS(stx,obj);
|
||||
return ASE_STX_IS_SMALLINT(obj)?
|
||||
stx->class_smallinteger: ASE_STX_CLASS(stx,obj);
|
||||
}
|
||||
|
||||
xp_word_t xp_stx_sizeof (xp_stx_t* stx, xp_word_t obj)
|
||||
ase_word_t ase_stx_sizeof (ase_stx_t* stx, ase_word_t obj)
|
||||
{
|
||||
return XP_STX_IS_SMALLINT(obj)? 1: XP_STX_SIZE(stx,obj);
|
||||
return ASE_STX_IS_SMALLINT(obj)? 1: ASE_STX_SIZE(stx,obj);
|
||||
}
|
||||
|
@ -1,36 +1,36 @@
|
||||
/*
|
||||
* $Id: object.h,v 1.30 2005-08-18 15:28:18 bacon Exp $
|
||||
* $Id: object.h,v 1.31 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_STX_OBJECT_H_
|
||||
#define _XP_STX_OBJECT_H_
|
||||
#ifndef _ASE_STX_OBJECT_H_
|
||||
#define _ASE_STX_OBJECT_H_
|
||||
|
||||
#include <xp/stx/stx.h>
|
||||
#include <ase/stx/stx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
xp_word_t xp_stx_alloc_word_object (
|
||||
xp_stx_t* stx, const xp_word_t* data, xp_word_t nfields,
|
||||
const xp_word_t* variable_data, xp_word_t variable_nfields);
|
||||
ase_word_t ase_stx_alloc_word_object (
|
||||
ase_stx_t* stx, const ase_word_t* data, ase_word_t nfields,
|
||||
const ase_word_t* variable_data, ase_word_t variable_nfields);
|
||||
|
||||
xp_word_t xp_stx_alloc_byte_object (
|
||||
xp_stx_t* stx, const xp_byte_t* data, xp_word_t n);
|
||||
ase_word_t ase_stx_alloc_byte_object (
|
||||
ase_stx_t* stx, const ase_byte_t* data, ase_word_t n);
|
||||
|
||||
xp_word_t xp_stx_alloc_char_object (
|
||||
xp_stx_t* stx, const xp_char_t* str);
|
||||
xp_word_t xp_stx_alloc_char_objectx (
|
||||
xp_stx_t* stx, const xp_char_t* str, xp_word_t n);
|
||||
xp_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...);
|
||||
ase_word_t ase_stx_alloc_char_object (
|
||||
ase_stx_t* stx, const ase_char_t* str);
|
||||
ase_word_t ase_stx_alloc_char_objectx (
|
||||
ase_stx_t* stx, const ase_char_t* str, ase_word_t n);
|
||||
ase_word_t ase_stx_allocn_char_object (ase_stx_t* stx, ...);
|
||||
|
||||
xp_word_t xp_stx_hash_object (xp_stx_t* stx, xp_word_t object);
|
||||
ase_word_t ase_stx_hash_object (ase_stx_t* stx, ase_word_t object);
|
||||
|
||||
xp_word_t xp_stx_instantiate (
|
||||
xp_stx_t* stx, xp_word_t class_index, const void* data,
|
||||
const void* variable_data, xp_word_t variable_nfields);
|
||||
xp_word_t xp_stx_classof (xp_stx_t* stx, xp_word_t obj);
|
||||
xp_word_t xp_stx_sizeof (xp_stx_t* stx, xp_word_t obj);
|
||||
ase_word_t ase_stx_instantiate (
|
||||
ase_stx_t* stx, ase_word_t class_index, const void* data,
|
||||
const void* variable_data, ase_word_t variable_nfields);
|
||||
ase_word_t ase_stx_classof (ase_stx_t* stx, ase_word_t obj);
|
||||
ase_word_t ase_stx_sizeof (ase_stx_t* stx, ase_word_t obj);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
916
ase/stx/parser.c
916
ase/stx/parser.c
File diff suppressed because it is too large
Load Diff
116
ase/stx/parser.h
116
ase/stx/parser.h
@ -1,104 +1,104 @@
|
||||
/*
|
||||
* $Id: parser.h,v 1.36 2006-01-30 16:44:03 bacon Exp $
|
||||
* $Id: parser.h,v 1.37 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_STX_PARSER_H_
|
||||
#define _XP_STX_PARSER_H_
|
||||
#ifndef _ASE_STX_PARSER_H_
|
||||
#define _ASE_STX_PARSER_H_
|
||||
|
||||
#include <xp/stx/stx.h>
|
||||
#include <xp/stx/name.h>
|
||||
#include <xp/stx/token.h>
|
||||
#include <xp/bas/arr.h>
|
||||
#include <ase/stx/stx.h>
|
||||
#include <ase/stx/name.h>
|
||||
#include <ase/stx/token.h>
|
||||
#include <ase/bas/arr.h>
|
||||
|
||||
enum
|
||||
{
|
||||
XP_STX_PARSER_ERROR_NONE,
|
||||
ASE_STX_PARSER_ERROR_NONE,
|
||||
|
||||
/* system errors */
|
||||
XP_STX_PARSER_ERROR_INPUT_FUNC,
|
||||
XP_STX_PARSER_ERROR_INPUT,
|
||||
XP_STX_PARSER_ERROR_MEMORY,
|
||||
ASE_STX_PARSER_ERROR_INPUT_FUNC,
|
||||
ASE_STX_PARSER_ERROR_INPUT,
|
||||
ASE_STX_PARSER_ERROR_MEMORY,
|
||||
|
||||
/* lexical errors */
|
||||
XP_STX_PARSER_ERROR_CHAR,
|
||||
XP_STX_PARSER_ERROR_CHARLIT,
|
||||
XP_STX_PARSER_ERROR_STRLIT,
|
||||
XP_STX_PARSER_ERROR_LITERAL,
|
||||
ASE_STX_PARSER_ERROR_CHAR,
|
||||
ASE_STX_PARSER_ERROR_CHARLIT,
|
||||
ASE_STX_PARSER_ERROR_STRLIT,
|
||||
ASE_STX_PARSER_ERROR_LITERAL,
|
||||
|
||||
/* syntatic error */
|
||||
XP_STX_PARSER_ERROR_MESSAGE_SELECTOR,
|
||||
XP_STX_PARSER_ERROR_ARGUMENT_NAME,
|
||||
XP_STX_PARSER_ERROR_TOO_MANY_ARGUMENTS,
|
||||
ASE_STX_PARSER_ERROR_MESSAGE_SELECTOR,
|
||||
ASE_STX_PARSER_ERROR_ARGUMENT_NAME,
|
||||
ASE_STX_PARSER_ERROR_TOO_MANY_ARGUMENTS,
|
||||
|
||||
XP_STX_PARSER_ERROR_PRIMITIVE_KEYWORD,
|
||||
XP_STX_PARSER_ERROR_PRIMITIVE_NUMBER,
|
||||
XP_STX_PARSER_ERROR_PRIMITIVE_NUMBER_RANGE,
|
||||
XP_STX_PARSER_ERROR_PRIMITIVE_NOT_CLOSED,
|
||||
ASE_STX_PARSER_ERROR_PRIMITIVE_KEYWORD,
|
||||
ASE_STX_PARSER_ERROR_PRIMITIVE_NUMBER,
|
||||
ASE_STX_PARSER_ERROR_PRIMITIVE_NUMBER_RANGE,
|
||||
ASE_STX_PARSER_ERROR_PRIMITIVE_NOT_CLOSED,
|
||||
|
||||
XP_STX_PARSER_ERROR_TEMPORARIES_NOT_CLOSED,
|
||||
XP_STX_PARSER_ERROR_TOO_MANY_TEMPORARIES,
|
||||
XP_STX_PARSER_ERROR_PSEUDO_VARIABLE,
|
||||
XP_STX_PARSER_ERROR_PRIMARY,
|
||||
ASE_STX_PARSER_ERROR_TEMPORARIES_NOT_CLOSED,
|
||||
ASE_STX_PARSER_ERROR_TOO_MANY_TEMPORARIES,
|
||||
ASE_STX_PARSER_ERROR_PSEUDO_VARIABLE,
|
||||
ASE_STX_PARSER_ERROR_PRIMARY,
|
||||
|
||||
XP_STX_PARSER_ERROR_NO_PERIOD,
|
||||
XP_STX_PARSER_ERROR_NO_RPAREN,
|
||||
XP_STX_PARSER_ERROR_BLOCK_ARGUMENT_NAME,
|
||||
XP_STX_PARSER_ERROR_BLOCK_ARGUMENT_LIST,
|
||||
XP_STX_PARSER_ERROR_BLOCK_NOT_CLOSED,
|
||||
ASE_STX_PARSER_ERROR_NO_PERIOD,
|
||||
ASE_STX_PARSER_ERROR_NO_RPAREN,
|
||||
ASE_STX_PARSER_ERROR_BLOCK_ARGUMENT_NAME,
|
||||
ASE_STX_PARSER_ERROR_BLOCK_ARGUMENT_LIST,
|
||||
ASE_STX_PARSER_ERROR_BLOCK_NOT_CLOSED,
|
||||
|
||||
XP_STX_PARSER_ERROR_UNDECLARED_NAME,
|
||||
XP_STX_PARSER_ERROR_TOO_MANY_LITERALS
|
||||
ASE_STX_PARSER_ERROR_UNDECLARED_NAME,
|
||||
ASE_STX_PARSER_ERROR_TOO_MANY_LITERALS
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
/* input_func cmd */
|
||||
XP_STX_PARSER_INPUT_OPEN,
|
||||
XP_STX_PARSER_INPUT_CLOSE,
|
||||
XP_STX_PARSER_INPUT_CONSUME,
|
||||
XP_STX_PARSER_INPUT_REWIND
|
||||
ASE_STX_PARSER_INPUT_OPEN,
|
||||
ASE_STX_PARSER_INPUT_CLOSE,
|
||||
ASE_STX_PARSER_INPUT_CONSUME,
|
||||
ASE_STX_PARSER_INPUT_REWIND
|
||||
};
|
||||
|
||||
typedef struct xp_stx_parser_t xp_stx_parser_t;
|
||||
typedef struct ase_stx_parser_t ase_stx_parser_t;
|
||||
|
||||
struct xp_stx_parser_t
|
||||
struct ase_stx_parser_t
|
||||
{
|
||||
xp_stx_t* stx;
|
||||
ase_stx_t* stx;
|
||||
int error_code;
|
||||
|
||||
xp_word_t method_class;
|
||||
xp_stx_name_t method_name;
|
||||
ase_word_t method_class;
|
||||
ase_stx_name_t method_name;
|
||||
|
||||
xp_char_t* temporaries[256]; /* TODO: different size? or dynamic? */
|
||||
xp_word_t argument_count;
|
||||
xp_word_t temporary_count;
|
||||
ase_char_t* temporaries[256]; /* TODO: different size? or dynamic? */
|
||||
ase_word_t argument_count;
|
||||
ase_word_t temporary_count;
|
||||
|
||||
xp_word_t literals[256]; /* TODO: make it a dynamic array */
|
||||
xp_word_t literal_count;
|
||||
ase_word_t literals[256]; /* TODO: make it a dynamic array */
|
||||
ase_word_t literal_count;
|
||||
|
||||
xp_arr_t bytecode;
|
||||
ase_arr_t bytecode;
|
||||
|
||||
xp_stx_token_t token;
|
||||
xp_cint_t curc;
|
||||
xp_cint_t ungotc[5];
|
||||
xp_size_t ungotc_count;
|
||||
ase_stx_token_t token;
|
||||
ase_cint_t curc;
|
||||
ase_cint_t ungotc[5];
|
||||
ase_size_t ungotc_count;
|
||||
|
||||
void* input_owner;
|
||||
int (*input_func) (int cmd, void* owner, void* arg);
|
||||
|
||||
xp_bool_t __dynamic;
|
||||
ase_bool_t __dynamic;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
xp_stx_parser_t* xp_stx_parser_open (xp_stx_parser_t* parser, xp_stx_t* stx);
|
||||
void xp_stx_parser_close (xp_stx_parser_t* parser);
|
||||
ase_stx_parser_t* ase_stx_parser_open (ase_stx_parser_t* parser, ase_stx_t* stx);
|
||||
void ase_stx_parser_close (ase_stx_parser_t* parser);
|
||||
|
||||
const xp_char_t* xp_stx_parser_error_string (xp_stx_parser_t* parser);
|
||||
int xp_stx_parser_parse_method (
|
||||
xp_stx_parser_t* parser, xp_word_t method_class, void* input);
|
||||
const ase_char_t* ase_stx_parser_error_string (ase_stx_parser_t* parser);
|
||||
int ase_stx_parser_parse_method (
|
||||
ase_stx_parser_t* parser, ase_word_t method_class, void* input);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,70 +1,70 @@
|
||||
/*
|
||||
* $Id: stx.c,v 1.40 2005-12-05 15:11:29 bacon Exp $
|
||||
* $Id: stx.c,v 1.41 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/stx/stx.h>
|
||||
#include <xp/stx/memory.h>
|
||||
#include <xp/stx/misc.h>
|
||||
#include <ase/stx/stx.h>
|
||||
#include <ase/stx/memory.h>
|
||||
#include <ase/stx/misc.h>
|
||||
|
||||
xp_stx_t* xp_stx_open (xp_stx_t* stx, xp_word_t capacity)
|
||||
ase_stx_t* ase_stx_open (ase_stx_t* stx, ase_word_t capacity)
|
||||
{
|
||||
xp_word_t i;
|
||||
ase_word_t i;
|
||||
|
||||
if (stx == XP_NULL) {
|
||||
stx = (xp_stx_t*)xp_malloc (xp_sizeof(stx));
|
||||
if (stx == XP_NULL) return XP_NULL;
|
||||
stx->__dynamic = xp_true;
|
||||
if (stx == ASE_NULL) {
|
||||
stx = (ase_stx_t*)ase_malloc (ase_sizeof(stx));
|
||||
if (stx == ASE_NULL) return ASE_NULL;
|
||||
stx->__dynamic = ase_true;
|
||||
}
|
||||
else stx->__dynamic = xp_false;
|
||||
else stx->__dynamic = ase_false;
|
||||
|
||||
if (xp_stx_memory_open (&stx->memory, capacity) == XP_NULL) {
|
||||
if (stx->__dynamic) xp_free (stx);
|
||||
return XP_NULL;
|
||||
if (ase_stx_memory_open (&stx->memory, capacity) == ASE_NULL) {
|
||||
if (stx->__dynamic) ase_free (stx);
|
||||
return ASE_NULL;
|
||||
}
|
||||
|
||||
stx->symtab.size = 0;
|
||||
stx->symtab.capacity = 128; /* TODO: symbol table size */
|
||||
stx->symtab.datum = (xp_word_t*)xp_malloc (
|
||||
xp_sizeof(xp_word_t) * stx->symtab.capacity);
|
||||
if (stx->symtab.datum == XP_NULL) {
|
||||
xp_stx_memory_close (&stx->memory);
|
||||
if (stx->__dynamic) xp_free (stx);
|
||||
return XP_NULL;
|
||||
stx->symtab.datum = (ase_word_t*)ase_malloc (
|
||||
ase_sizeof(ase_word_t) * stx->symtab.capacity);
|
||||
if (stx->symtab.datum == ASE_NULL) {
|
||||
ase_stx_memory_close (&stx->memory);
|
||||
if (stx->__dynamic) ase_free (stx);
|
||||
return ASE_NULL;
|
||||
}
|
||||
|
||||
stx->nil = XP_STX_NIL;
|
||||
stx->true = XP_STX_TRUE;
|
||||
stx->false = XP_STX_FALSE;
|
||||
stx->nil = ASE_STX_NIL;
|
||||
stx->true = ASE_STX_TRUE;
|
||||
stx->false = ASE_STX_FALSE;
|
||||
|
||||
stx->smalltalk = XP_STX_NIL;
|
||||
stx->smalltalk = ASE_STX_NIL;
|
||||
|
||||
stx->class_symbol = XP_STX_NIL;
|
||||
stx->class_metaclass = XP_STX_NIL;
|
||||
stx->class_association = XP_STX_NIL;
|
||||
stx->class_symbol = ASE_STX_NIL;
|
||||
stx->class_metaclass = ASE_STX_NIL;
|
||||
stx->class_association = ASE_STX_NIL;
|
||||
|
||||
stx->class_object = XP_STX_NIL;
|
||||
stx->class_class = XP_STX_NIL;
|
||||
stx->class_array = XP_STX_NIL;
|
||||
stx->class_bytearray = XP_STX_NIL;
|
||||
stx->class_string = XP_STX_NIL;
|
||||
stx->class_character = XP_STX_NIL;
|
||||
stx->class_context = XP_STX_NIL;
|
||||
stx->class_system_dictionary = XP_STX_NIL;
|
||||
stx->class_method = XP_STX_NIL;
|
||||
stx->class_smallinteger = XP_STX_NIL;
|
||||
stx->class_object = ASE_STX_NIL;
|
||||
stx->class_class = ASE_STX_NIL;
|
||||
stx->class_array = ASE_STX_NIL;
|
||||
stx->class_bytearray = ASE_STX_NIL;
|
||||
stx->class_string = ASE_STX_NIL;
|
||||
stx->class_character = ASE_STX_NIL;
|
||||
stx->class_context = ASE_STX_NIL;
|
||||
stx->class_system_dictionary = ASE_STX_NIL;
|
||||
stx->class_method = ASE_STX_NIL;
|
||||
stx->class_smallinteger = ASE_STX_NIL;
|
||||
|
||||
for (i = 0; i < stx->symtab.capacity; i++) {
|
||||
stx->symtab.datum[i] = stx->nil;
|
||||
}
|
||||
|
||||
stx->__wantabort = xp_false;
|
||||
stx->__wantabort = ase_false;
|
||||
return stx;
|
||||
}
|
||||
|
||||
void xp_stx_close (xp_stx_t* stx)
|
||||
void ase_stx_close (ase_stx_t* stx)
|
||||
{
|
||||
xp_free (stx->symtab.datum);
|
||||
xp_stx_memory_close (&stx->memory);
|
||||
if (stx->__dynamic) xp_free (stx);
|
||||
ase_free (stx->symtab.datum);
|
||||
ase_stx_memory_close (&stx->memory);
|
||||
if (stx->__dynamic) ase_free (stx);
|
||||
}
|
||||
|
||||
|
204
ase/stx/stx.h
204
ase/stx/stx.h
@ -1,160 +1,160 @@
|
||||
/*
|
||||
* $Id: stx.h,v 1.45 2005-12-05 15:11:29 bacon Exp $
|
||||
* $Id: stx.h,v 1.46 2007-03-22 11:19:28 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_STX_STX_H_
|
||||
#define _XP_STX_STX_H_
|
||||
#ifndef _ASE_STX_STX_H_
|
||||
#define _ASE_STX_STX_H_
|
||||
|
||||
#include <xp/types.h>
|
||||
#include <xp/macros.h>
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
typedef struct xp_stx_objhdr_t xp_stx_objhdr_t;
|
||||
typedef struct xp_stx_object_t xp_stx_object_t;
|
||||
typedef struct xp_stx_word_object_t xp_stx_word_object_t;
|
||||
typedef struct xp_stx_byte_object_t xp_stx_byte_object_t;
|
||||
typedef struct xp_stx_char_object_t xp_stx_char_object_t;
|
||||
typedef struct xp_stx_memory_t xp_stx_memory_t;
|
||||
typedef struct xp_stx_symtab_t xp_stx_symtab_t;
|
||||
typedef struct xp_stx_t xp_stx_t;
|
||||
typedef struct ase_stx_objhdr_t ase_stx_objhdr_t;
|
||||
typedef struct ase_stx_object_t ase_stx_object_t;
|
||||
typedef struct ase_stx_word_object_t ase_stx_word_object_t;
|
||||
typedef struct ase_stx_byte_object_t ase_stx_byte_object_t;
|
||||
typedef struct ase_stx_char_object_t ase_stx_char_object_t;
|
||||
typedef struct ase_stx_memory_t ase_stx_memory_t;
|
||||
typedef struct ase_stx_symtab_t ase_stx_symtab_t;
|
||||
typedef struct ase_stx_t ase_stx_t;
|
||||
|
||||
/* common object structure */
|
||||
struct xp_stx_objhdr_t
|
||||
struct ase_stx_objhdr_t
|
||||
{
|
||||
/* access - type: 2; size: rest;
|
||||
* type - word indexed: 00 byte indexed: 01 char indexed: 10
|
||||
*/
|
||||
xp_word_t access;
|
||||
xp_word_t class;
|
||||
ase_word_t access;
|
||||
ase_word_t class;
|
||||
};
|
||||
|
||||
struct xp_stx_object_t
|
||||
struct ase_stx_object_t
|
||||
{
|
||||
xp_stx_objhdr_t header;
|
||||
ase_stx_objhdr_t header;
|
||||
};
|
||||
|
||||
struct xp_stx_word_object_t
|
||||
struct ase_stx_word_object_t
|
||||
{
|
||||
xp_stx_objhdr_t header;
|
||||
xp_word_t data[1];
|
||||
ase_stx_objhdr_t header;
|
||||
ase_word_t data[1];
|
||||
};
|
||||
|
||||
struct xp_stx_byte_object_t
|
||||
struct ase_stx_byte_object_t
|
||||
{
|
||||
xp_stx_objhdr_t header;
|
||||
xp_byte_t data[1];
|
||||
ase_stx_objhdr_t header;
|
||||
ase_byte_t data[1];
|
||||
};
|
||||
|
||||
struct xp_stx_char_object_t
|
||||
struct ase_stx_char_object_t
|
||||
{
|
||||
xp_stx_objhdr_t header;
|
||||
xp_char_t data[1];
|
||||
ase_stx_objhdr_t header;
|
||||
ase_char_t data[1];
|
||||
};
|
||||
|
||||
|
||||
struct xp_stx_memory_t
|
||||
struct ase_stx_memory_t
|
||||
{
|
||||
xp_word_t capacity;
|
||||
xp_stx_object_t** slots;
|
||||
xp_stx_object_t** free;
|
||||
xp_bool_t __dynamic;
|
||||
ase_word_t capacity;
|
||||
ase_stx_object_t** slots;
|
||||
ase_stx_object_t** free;
|
||||
ase_bool_t __dynamic;
|
||||
};
|
||||
|
||||
struct xp_stx_symtab_t
|
||||
struct ase_stx_symtab_t
|
||||
{
|
||||
xp_word_t* datum;
|
||||
xp_word_t size;
|
||||
xp_word_t capacity;
|
||||
ase_word_t* datum;
|
||||
ase_word_t size;
|
||||
ase_word_t capacity;
|
||||
};
|
||||
|
||||
struct xp_stx_t
|
||||
struct ase_stx_t
|
||||
{
|
||||
xp_stx_memory_t memory;
|
||||
xp_stx_symtab_t symtab;
|
||||
ase_stx_memory_t memory;
|
||||
ase_stx_symtab_t symtab;
|
||||
|
||||
xp_word_t nil;
|
||||
xp_word_t true;
|
||||
xp_word_t false;
|
||||
ase_word_t nil;
|
||||
ase_word_t true;
|
||||
ase_word_t false;
|
||||
|
||||
xp_word_t smalltalk;
|
||||
ase_word_t smalltalk;
|
||||
|
||||
xp_word_t class_symbol;
|
||||
xp_word_t class_metaclass;
|
||||
xp_word_t class_association;
|
||||
ase_word_t class_symbol;
|
||||
ase_word_t class_metaclass;
|
||||
ase_word_t class_association;
|
||||
|
||||
xp_word_t class_object;
|
||||
xp_word_t class_class;
|
||||
xp_word_t class_array;
|
||||
xp_word_t class_bytearray;
|
||||
xp_word_t class_string;
|
||||
xp_word_t class_character;
|
||||
xp_word_t class_context;
|
||||
xp_word_t class_system_dictionary;
|
||||
xp_word_t class_method;
|
||||
xp_word_t class_smallinteger;
|
||||
ase_word_t class_object;
|
||||
ase_word_t class_class;
|
||||
ase_word_t class_array;
|
||||
ase_word_t class_bytearray;
|
||||
ase_word_t class_string;
|
||||
ase_word_t class_character;
|
||||
ase_word_t class_context;
|
||||
ase_word_t class_system_dictionary;
|
||||
ase_word_t class_method;
|
||||
ase_word_t class_smallinteger;
|
||||
|
||||
xp_bool_t __dynamic;
|
||||
xp_bool_t __wantabort; /* TODO: make it a function pointer */
|
||||
ase_bool_t __dynamic;
|
||||
ase_bool_t __wantabort; /* TODO: make it a function pointer */
|
||||
};
|
||||
|
||||
#define XP_STX_IS_SMALLINT(x) (((x) & 0x01) == 0x01)
|
||||
#define XP_STX_TO_SMALLINT(x) (((x) << 1) | 0x01)
|
||||
#define XP_STX_FROM_SMALLINT(x) ((x) >> 1)
|
||||
#define ASE_STX_IS_SMALLINT(x) (((x) & 0x01) == 0x01)
|
||||
#define ASE_STX_TO_SMALLINT(x) (((x) << 1) | 0x01)
|
||||
#define ASE_STX_FROM_SMALLINT(x) ((x) >> 1)
|
||||
|
||||
#define XP_STX_IS_OINDEX(x) (((x) & 0x01) == 0x00)
|
||||
#define XP_STX_TO_OINDEX(x) (((x) << 1) | 0x00)
|
||||
#define XP_STX_FROM_OINDEX(x) ((x) >> 1)
|
||||
#define ASE_STX_IS_OINDEX(x) (((x) & 0x01) == 0x00)
|
||||
#define ASE_STX_TO_OINDEX(x) (((x) << 1) | 0x00)
|
||||
#define ASE_STX_FROM_OINDEX(x) ((x) >> 1)
|
||||
|
||||
#define XP_STX_NIL XP_STX_TO_OINDEX(0)
|
||||
#define XP_STX_TRUE XP_STX_TO_OINDEX(1)
|
||||
#define XP_STX_FALSE XP_STX_TO_OINDEX(2)
|
||||
#define ASE_STX_NIL ASE_STX_TO_OINDEX(0)
|
||||
#define ASE_STX_TRUE ASE_STX_TO_OINDEX(1)
|
||||
#define ASE_STX_FALSE ASE_STX_TO_OINDEX(2)
|
||||
|
||||
#define XP_STX_OBJECT(stx,idx) (((stx)->memory).slots[XP_STX_FROM_OINDEX(idx)])
|
||||
#define XP_STX_CLASS(stx,idx) (XP_STX_OBJECT(stx,(idx))->header.class)
|
||||
#define XP_STX_ACCESS(stx,idx) (XP_STX_OBJECT(stx,(idx))->header.access)
|
||||
#define XP_STX_DATA(stx,idx) ((void*)(XP_STX_OBJECT(stx,idx) + 1))
|
||||
#define ASE_STX_OBJECT(stx,idx) (((stx)->memory).slots[ASE_STX_FROM_OINDEX(idx)])
|
||||
#define ASE_STX_CLASS(stx,idx) (ASE_STX_OBJECT(stx,(idx))->header.class)
|
||||
#define ASE_STX_ACCESS(stx,idx) (ASE_STX_OBJECT(stx,(idx))->header.access)
|
||||
#define ASE_STX_DATA(stx,idx) ((void*)(ASE_STX_OBJECT(stx,idx) + 1))
|
||||
|
||||
#define XP_STX_TYPE(stx,idx) (XP_STX_ACCESS(stx,idx) & 0x03)
|
||||
#define XP_STX_SIZE(stx,idx) (XP_STX_ACCESS(stx,idx) >> 0x02)
|
||||
#define ASE_STX_TYPE(stx,idx) (ASE_STX_ACCESS(stx,idx) & 0x03)
|
||||
#define ASE_STX_SIZE(stx,idx) (ASE_STX_ACCESS(stx,idx) >> 0x02)
|
||||
|
||||
#define XP_STX_WORD_INDEXED (0x00)
|
||||
#define XP_STX_BYTE_INDEXED (0x01)
|
||||
#define XP_STX_CHAR_INDEXED (0x02)
|
||||
#define ASE_STX_WORD_INDEXED (0x00)
|
||||
#define ASE_STX_BYTE_INDEXED (0x01)
|
||||
#define ASE_STX_CHAR_INDEXED (0x02)
|
||||
|
||||
#define XP_STX_IS_WORD_OBJECT(stx,idx) \
|
||||
(XP_STX_TYPE(stx,idx) == XP_STX_WORD_INDEXED)
|
||||
#define XP_STX_IS_BYTE_OBJECT(stx,idx) \
|
||||
(XP_STX_TYPE(stx,idx) == XP_STX_BYTE_INDEXED)
|
||||
#define XP_STX_IS_CHAR_OBJECT(stx,idx) \
|
||||
(XP_STX_TYPE(stx,idx) == XP_STX_CHAR_INDEXED)
|
||||
#define ASE_STX_IS_WORD_OBJECT(stx,idx) \
|
||||
(ASE_STX_TYPE(stx,idx) == ASE_STX_WORD_INDEXED)
|
||||
#define ASE_STX_IS_BYTE_OBJECT(stx,idx) \
|
||||
(ASE_STX_TYPE(stx,idx) == ASE_STX_BYTE_INDEXED)
|
||||
#define ASE_STX_IS_CHAR_OBJECT(stx,idx) \
|
||||
(ASE_STX_TYPE(stx,idx) == ASE_STX_CHAR_INDEXED)
|
||||
|
||||
#define XP_STX_WORD_OBJECT(stx,idx) \
|
||||
((xp_stx_word_object_t*)XP_STX_OBJECT(stx,idx))
|
||||
#define XP_STX_BYTE_OBJECT(stx,idx) \
|
||||
((xp_stx_byte_object_t*)XP_STX_OBJECT(stx,idx))
|
||||
#define XP_STX_CHAR_OBJECT(stx,idx) \
|
||||
((xp_stx_char_object_t*)XP_STX_OBJECT(stx,idx))
|
||||
#define ASE_STX_WORD_OBJECT(stx,idx) \
|
||||
((ase_stx_word_object_t*)ASE_STX_OBJECT(stx,idx))
|
||||
#define ASE_STX_BYTE_OBJECT(stx,idx) \
|
||||
((ase_stx_byte_object_t*)ASE_STX_OBJECT(stx,idx))
|
||||
#define ASE_STX_CHAR_OBJECT(stx,idx) \
|
||||
((ase_stx_char_object_t*)ASE_STX_OBJECT(stx,idx))
|
||||
|
||||
/*
|
||||
#define XP_STX_WORD_AT(stx,idx,n) \
|
||||
(((xp_word_t*)(XP_STX_OBJECT(stx,idx) + 1))[n])
|
||||
#define XP_STX_BYTE_AT(stx,idx,n) \
|
||||
(((xp_byte_t*)(XP_STX_OBJECT(stx,idx) + 1))[n])
|
||||
#define XP_STX_CHAR_AT(stx,idx,n) \
|
||||
(((xp_char_t*)(XP_STX_OBJECT(stx,idx) + 1))[n])
|
||||
#define ASE_STX_WORD_AT(stx,idx,n) \
|
||||
(((ase_word_t*)(ASE_STX_OBJECT(stx,idx) + 1))[n])
|
||||
#define ASE_STX_BYTE_AT(stx,idx,n) \
|
||||
(((ase_byte_t*)(ASE_STX_OBJECT(stx,idx) + 1))[n])
|
||||
#define ASE_STX_CHAR_AT(stx,idx,n) \
|
||||
(((ase_char_t*)(ASE_STX_OBJECT(stx,idx) + 1))[n])
|
||||
*/
|
||||
#define XP_STX_WORD_AT(stx,idx,n) \
|
||||
(XP_STX_WORD_OBJECT(stx,idx)->data[n])
|
||||
#define XP_STX_BYTE_AT(stx,idx,n) \
|
||||
(XP_STX_BYTE_OBJECT(stx,idx)->data[n])
|
||||
#define XP_STX_CHAR_AT(stx,idx,n) \
|
||||
(XP_STX_CHAR_OBJECT(stx,idx)->data[n])
|
||||
#define ASE_STX_WORD_AT(stx,idx,n) \
|
||||
(ASE_STX_WORD_OBJECT(stx,idx)->data[n])
|
||||
#define ASE_STX_BYTE_AT(stx,idx,n) \
|
||||
(ASE_STX_BYTE_OBJECT(stx,idx)->data[n])
|
||||
#define ASE_STX_CHAR_AT(stx,idx,n) \
|
||||
(ASE_STX_CHAR_OBJECT(stx,idx)->data[n])
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
xp_stx_t* xp_stx_open (xp_stx_t* stx, xp_word_t capacity);
|
||||
void xp_stx_close (xp_stx_t* stx);
|
||||
ase_stx_t* ase_stx_open (ase_stx_t* stx, ase_word_t capacity);
|
||||
void ase_stx_close (ase_stx_t* stx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user