*** empty log message ***
This commit is contained in:
parent
774f884b2d
commit
ecfccc31f7
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: bootstrp.c,v 1.20 2005-07-05 06:26:33 bacon Exp $
|
* $Id: bootstrp.c,v 1.21 2005-07-05 09:02:13 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/bootstrp.h>
|
#include <xp/stx/bootstrp.h>
|
||||||
@ -122,11 +122,10 @@ static class_info_t class_info[] =
|
|||||||
{
|
{
|
||||||
XP_TEXT("Method"),
|
XP_TEXT("Method"),
|
||||||
XP_TEXT("Object"),
|
XP_TEXT("Object"),
|
||||||
XP_TEXT("text message bytecodes literals stackSize temporarySize"),
|
XP_TEXT("text selector bytecodes"),
|
||||||
//XP_NULL,
|
|
||||||
XP_TEXT("Win32Errors"), // TODO: REMOVE THIS
|
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_STX_SPEC_NOT_INDEXABLE
|
XP_NULL,
|
||||||
|
XP_STX_SPEC_WORD_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("Magnitude"),
|
XP_TEXT("Magnitude"),
|
||||||
@ -248,7 +247,7 @@ xp_word_t xp_stx_new_array (xp_stx_t* stx, xp_word_t size)
|
|||||||
xp_word_t x;
|
xp_word_t x;
|
||||||
|
|
||||||
xp_assert (stx->class_array != stx->nil);
|
xp_assert (stx->class_array != stx->nil);
|
||||||
x = xp_stx_alloc_word_object (stx, XP_NULL, size);
|
x = xp_stx_alloc_word_object (stx, XP_NULL, 0, XP_NULL, size);
|
||||||
XP_STX_CLASS(stx,x) = stx->class_array;
|
XP_STX_CLASS(stx,x) = stx->class_array;
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
@ -280,6 +279,7 @@ int xp_stx_bootstrap (xp_stx_t* stx)
|
|||||||
stx->class_bytearray = xp_stx_new_class (stx, XP_TEXT("ByteArray"));
|
stx->class_bytearray = xp_stx_new_class (stx, XP_TEXT("ByteArray"));
|
||||||
stx->class_string = xp_stx_new_class (stx, XP_TEXT("String"));
|
stx->class_string = xp_stx_new_class (stx, XP_TEXT("String"));
|
||||||
stx->class_dictionary = xp_stx_new_class (stx, XP_TEXT("Dictionary"));
|
stx->class_dictionary = xp_stx_new_class (stx, XP_TEXT("Dictionary"));
|
||||||
|
stx->class_method = xp_stx_new_class (stx, XP_TEXT("Method"));
|
||||||
|
|
||||||
__create_builtin_classes (stx);
|
__create_builtin_classes (stx);
|
||||||
|
|
||||||
@ -341,9 +341,9 @@ static void __create_bootstrapping_objects (xp_stx_t* stx)
|
|||||||
xp_word_t symbol_Pairlink;
|
xp_word_t symbol_Pairlink;
|
||||||
|
|
||||||
/* allocate three keyword objects */
|
/* allocate three keyword objects */
|
||||||
stx->nil = xp_stx_alloc_word_object (stx, XP_NULL, 0);
|
stx->nil = xp_stx_alloc_word_object (stx, XP_NULL, 0, XP_NULL, 0);
|
||||||
stx->true = xp_stx_alloc_word_object (stx, XP_NULL, 0);
|
stx->true = xp_stx_alloc_word_object (stx, XP_NULL, 0, XP_NULL, 0);
|
||||||
stx->false = xp_stx_alloc_word_object (stx, XP_NULL, 0);
|
stx->false = xp_stx_alloc_word_object (stx, XP_NULL, 0, XP_NULL, 0);
|
||||||
|
|
||||||
xp_assert (stx->nil == XP_STX_NIL);
|
xp_assert (stx->nil == XP_STX_NIL);
|
||||||
xp_assert (stx->true == XP_STX_TRUE);
|
xp_assert (stx->true == XP_STX_TRUE);
|
||||||
@ -351,30 +351,40 @@ static void __create_bootstrapping_objects (xp_stx_t* stx)
|
|||||||
|
|
||||||
/* symbol table & system dictionary */
|
/* symbol table & system dictionary */
|
||||||
/* TODO: symbol table and dictionary size */
|
/* TODO: symbol table and dictionary size */
|
||||||
stx->symbol_table = xp_stx_alloc_word_object (stx, XP_NULL, 1000);
|
stx->symbol_table = xp_stx_alloc_word_object (
|
||||||
stx->smalltalk = xp_stx_alloc_word_object (stx, XP_NULL, 2000);
|
stx, XP_NULL, 0, XP_NULL, 1000);
|
||||||
|
stx->smalltalk = xp_stx_alloc_word_object (
|
||||||
|
stx, XP_NULL, 0, XP_NULL, 2000);
|
||||||
|
|
||||||
stx->class_symlink = /* Symlink */
|
/* Symlink */
|
||||||
xp_stx_alloc_word_object(stx, XP_NULL, XP_STX_CLASS_SIZE);
|
stx->class_symlink = xp_stx_alloc_word_object(
|
||||||
stx->class_symbol = /* Symbol */
|
stx, XP_NULL, XP_STX_CLASS_SIZE, XP_NULL, 0);
|
||||||
xp_stx_alloc_word_object(stx, XP_NULL, XP_STX_CLASS_SIZE);
|
/* Symbol */
|
||||||
stx->class_metaclass = /* Metaclass */
|
stx->class_symbol = xp_stx_alloc_word_object(
|
||||||
xp_stx_alloc_word_object(stx, XP_NULL, XP_STX_CLASS_SIZE);
|
stx, XP_NULL, XP_STX_CLASS_SIZE, XP_NULL, 0);
|
||||||
stx->class_pairlink = /* Pairlink */
|
/* Metaclass */
|
||||||
xp_stx_alloc_word_object(stx, XP_NULL, XP_STX_CLASS_SIZE);
|
stx->class_metaclass = xp_stx_alloc_word_object(
|
||||||
|
stx, XP_NULL, XP_STX_CLASS_SIZE, XP_NULL, 0);
|
||||||
|
/* Pairlink */
|
||||||
|
stx->class_pairlink = xp_stx_alloc_word_object(
|
||||||
|
stx, XP_NULL, XP_STX_CLASS_SIZE, XP_NULL, 0);
|
||||||
|
|
||||||
/* Metaclass is a class so it has the same structure
|
/* Metaclass is a class so it has the same structure
|
||||||
* as a normal class. "Metaclass class" is an instance of
|
* as a normal class. "Metaclass class" is an instance of
|
||||||
* Metaclass. */
|
* Metaclass. */
|
||||||
|
|
||||||
class_SymlinkMeta = /* Symlink class */
|
/* Symlink class */
|
||||||
xp_stx_alloc_word_object(stx, XP_NULL, XP_STX_METACLASS_SIZE);
|
class_SymlinkMeta = xp_stx_alloc_word_object(
|
||||||
class_SymbolMeta = /* Symbol class */
|
stx, XP_NULL, XP_STX_METACLASS_SIZE, XP_NULL, 0);
|
||||||
xp_stx_alloc_word_object(stx, XP_NULL, XP_STX_METACLASS_SIZE);
|
/* Symbol class */
|
||||||
class_MetaclassMeta = /* Metaclass class */
|
class_SymbolMeta = xp_stx_alloc_word_object(
|
||||||
xp_stx_alloc_word_object(stx, XP_NULL, XP_STX_METACLASS_SIZE);
|
stx, XP_NULL, XP_STX_METACLASS_SIZE, XP_NULL, 0);
|
||||||
class_PairlinkMeta = /* Pairlink class */
|
/* Metaclass class */
|
||||||
xp_stx_alloc_word_object(stx, XP_NULL, XP_STX_METACLASS_SIZE);
|
class_MetaclassMeta = xp_stx_alloc_word_object(
|
||||||
|
stx, XP_NULL, XP_STX_METACLASS_SIZE, XP_NULL, 0);
|
||||||
|
/* Pairlink class */
|
||||||
|
class_PairlinkMeta = xp_stx_alloc_word_object(
|
||||||
|
stx, XP_NULL, XP_STX_METACLASS_SIZE, XP_NULL, 0);
|
||||||
|
|
||||||
/* (Symlink class) setClass: Metaclass */
|
/* (Symlink class) setClass: Metaclass */
|
||||||
XP_STX_CLASS(stx,class_SymlinkMeta) = stx->class_metaclass;
|
XP_STX_CLASS(stx,class_SymlinkMeta) = stx->class_metaclass;
|
||||||
@ -641,7 +651,8 @@ static xp_word_t __make_classvar_dict (
|
|||||||
const xp_char_t* name;
|
const xp_char_t* name;
|
||||||
|
|
||||||
dict = xp_stx_instantiate (
|
dict = xp_stx_instantiate (
|
||||||
stx, stx->class_dictionary, XP_NULL, __count_names(names));
|
stx, stx->class_dictionary,
|
||||||
|
XP_NULL, XP_NULL, __count_names(names));
|
||||||
|
|
||||||
do {
|
do {
|
||||||
while (*p == XP_CHAR(' ') ||
|
while (*p == XP_CHAR(' ') ||
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: class.c,v 1.18 2005-07-05 06:26:33 bacon Exp $
|
* $Id: class.c,v 1.19 2005-07-05 09:02:13 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/class.h>
|
#include <xp/stx/class.h>
|
||||||
@ -13,7 +13,8 @@ xp_word_t xp_stx_new_class (xp_stx_t* stx, const xp_char_t* name)
|
|||||||
xp_word_t meta, class;
|
xp_word_t meta, class;
|
||||||
xp_word_t class_name;
|
xp_word_t class_name;
|
||||||
|
|
||||||
meta = xp_stx_alloc_word_object (stx, XP_NULL, XP_STX_METACLASS_SIZE);
|
meta = xp_stx_alloc_word_object (
|
||||||
|
stx, XP_NULL, XP_STX_METACLASS_SIZE, XP_NULL, 0);
|
||||||
XP_STX_CLASS(stx,meta) = stx->class_metaclass;
|
XP_STX_CLASS(stx,meta) = stx->class_metaclass;
|
||||||
/* the spec of the metaclass must be the spec of its
|
/* the spec of the metaclass must be the spec of its
|
||||||
* instance. so the XP_STX_CLASS_SIZE is set */
|
* instance. so the XP_STX_CLASS_SIZE is set */
|
||||||
@ -21,7 +22,8 @@ xp_word_t xp_stx_new_class (xp_stx_t* stx, const xp_char_t* name)
|
|||||||
XP_STX_TO_SMALLINT((XP_STX_CLASS_SIZE << XP_STX_SPEC_INDEXABLE_BITS) | XP_STX_SPEC_NOT_INDEXABLE);
|
XP_STX_TO_SMALLINT((XP_STX_CLASS_SIZE << XP_STX_SPEC_INDEXABLE_BITS) | XP_STX_SPEC_NOT_INDEXABLE);
|
||||||
|
|
||||||
/* the spec of the class is set later in __create_builtin_classes */
|
/* 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);
|
class = xp_stx_alloc_word_object (
|
||||||
|
stx, XP_NULL, XP_STX_CLASS_SIZE, XP_NULL, 0);
|
||||||
XP_STX_CLASS(stx,class) = meta;
|
XP_STX_CLASS(stx,class) = meta;
|
||||||
class_name = xp_stx_new_symbol (stx, name);
|
class_name = xp_stx_new_symbol (stx, name);
|
||||||
XP_STX_WORDAT(stx,class,XP_STX_CLASS_NAME) = class_name;
|
XP_STX_WORDAT(stx,class,XP_STX_CLASS_NAME) = class_name;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: context.c,v 1.9 2005-07-05 06:26:33 bacon Exp $
|
* $Id: context.c,v 1.10 2005-07-05 09:02:13 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/context.h>
|
#include <xp/stx/context.h>
|
||||||
@ -13,7 +13,8 @@ xp_word_t xp_stx_new_context (xp_stx_t* stx,
|
|||||||
xp_word_t context;
|
xp_word_t context;
|
||||||
xp_stx_context_t* obj;
|
xp_stx_context_t* obj;
|
||||||
|
|
||||||
context = xp_stx_alloc_word_object(stx, XP_NULL, XP_STX_CONTEXT_SIZE);
|
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 = (xp_stx_context_t*)XP_STX_OBJECT(stx,context);
|
||||||
obj->header.class = xp_stx_lookup_class(stx,XP_TEXT("Context"));
|
obj->header.class = xp_stx_lookup_class(stx,XP_TEXT("Context"));
|
||||||
obj->ip = XP_STX_TO_SMALLINT(0);
|
obj->ip = XP_STX_TO_SMALLINT(0);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: hash.c,v 1.22 2005-07-05 06:26:33 bacon Exp $
|
* $Id: hash.c,v 1.23 2005-07-05 09:02:13 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/hash.h>
|
#include <xp/stx/hash.h>
|
||||||
@ -12,7 +12,8 @@ xp_word_t xp_stx_new_pairlink (
|
|||||||
xp_word_t x;
|
xp_word_t x;
|
||||||
xp_stx_pairlink_t* obj;
|
xp_stx_pairlink_t* obj;
|
||||||
|
|
||||||
x = xp_stx_alloc_word_object (stx, XP_NULL, XP_STX_PAIRLINK_SIZE);
|
x = xp_stx_alloc_word_object (
|
||||||
|
stx, XP_NULL, XP_STX_PAIRLINK_SIZE, XP_NULL, 0);
|
||||||
obj = (xp_stx_pairlink_t*)XP_STX_WORD_OBJECT(stx, x);
|
obj = (xp_stx_pairlink_t*)XP_STX_WORD_OBJECT(stx, x);
|
||||||
obj->header.class = stx->class_pairlink;
|
obj->header.class = stx->class_pairlink;
|
||||||
obj->link = stx->nil;
|
obj->link = stx->nil;
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
/*
|
|
||||||
* $Id: method.c,v 1.1 2005-07-04 11:32:41 bacon Exp $
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <xp/stx/method.h>
|
|
||||||
|
|
||||||
int xp_stx_new_method (xp_stx_t* stx, xp_word_t size)
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: method.h,v 1.1 2005-07-04 11:32:41 bacon Exp $
|
* $Id: method.h,v 1.2 2005-07-05 09:02:13 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_STX_METHOD_H_
|
#ifndef _XP_STX_METHOD_H_
|
||||||
@ -7,20 +7,26 @@
|
|||||||
|
|
||||||
#include <xp/stx/stx.h>
|
#include <xp/stx/stx.h>
|
||||||
|
|
||||||
#define XP_STX_METHOD_SIZE 6
|
#define XP_STX_METHOD_SIZE 3
|
||||||
#define XP_STX_METHOD_TEXT 0
|
#define XP_STX_METHOD_TEXT 0
|
||||||
#define XP_STX_METHOD_MESSAGE 1
|
#define XP_STX_METHOD_SELECTOR 1
|
||||||
#define XP_STX_METHOD_BYTECODES 2
|
#define XP_STX_METHOD_BYTECODES 2
|
||||||
#define XP_STX_METHOD_LITERALS 3
|
|
||||||
#define XP_STX_METHOD_STACK_SIZE 4
|
struct xp_stx_method_t
|
||||||
#define XP_STX_METHOD_TEMPORARY_SIZE 5
|
{
|
||||||
|
xp_stx_objhdr_t header;
|
||||||
|
xp_word_t text;
|
||||||
|
xp_word_t selector; /* is this necessary? */
|
||||||
|
xp_word_t bytecodes;
|
||||||
|
xp_word_t literals[1];
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct xp_stx_method_t xp_stx_method_t;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int xp_stx_new_method (xp_stx_t* stx, xp_word_t size);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: object.c,v 1.31 2005-07-05 06:26:33 bacon Exp $
|
* $Id: object.c,v 1.32 2005-07-05 09:02:13 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/object.h>
|
#include <xp/stx/object.h>
|
||||||
@ -11,33 +11,43 @@
|
|||||||
|
|
||||||
/* n: number of instance variables */
|
/* n: number of instance variables */
|
||||||
xp_word_t xp_stx_alloc_word_object (
|
xp_word_t xp_stx_alloc_word_object (
|
||||||
xp_stx_t* stx, const xp_word_t* data, xp_word_t n)
|
xp_stx_t* stx, const xp_word_t* data, xp_word_t nfields,
|
||||||
|
const xp_word_t* variable_data, xp_word_t variable_nfields)
|
||||||
{
|
{
|
||||||
xp_word_t idx;
|
xp_word_t idx, n;
|
||||||
xp_stx_word_object_t* obj;
|
xp_stx_word_object_t* obj;
|
||||||
|
|
||||||
/* bytes to allocidxed =
|
xp_assert (stx->nil == XP_STX_NIL);
|
||||||
* number of instance variables * word_size
|
|
||||||
|
/* 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,
|
idx = xp_stx_memory_alloc (&stx->memory,
|
||||||
n * xp_sizeof(xp_word_t) + xp_sizeof(xp_stx_object_t));
|
n * xp_sizeof(xp_word_t) + xp_sizeof(xp_stx_object_t));
|
||||||
if (idx >= stx->memory.capacity) return idx; /* failed */
|
if (idx >= stx->memory.capacity) return idx; /* failed */
|
||||||
|
|
||||||
xp_assert (stx->nil == XP_STX_NIL);
|
|
||||||
|
|
||||||
/*
|
|
||||||
XP_STX_CLASS(stx,idx) = stx->nil;
|
|
||||||
XP_STX_ACCESS(stx,idx) = (n << 2) | XP_STX_WORD_INDEXED;
|
|
||||||
while (n-- > 0) XP_STX_AT(stx,idx,n) = stx->nil;
|
|
||||||
*/
|
|
||||||
obj = XP_STX_WORD_OBJECT(stx,idx);
|
obj = XP_STX_WORD_OBJECT(stx,idx);
|
||||||
obj->header.class = stx->nil;
|
obj->header.class = stx->nil;
|
||||||
obj->header.access = (n << 2) | XP_STX_WORD_INDEXED;
|
obj->header.access = (n << 2) | XP_STX_WORD_INDEXED;
|
||||||
if (data == XP_NULL) {
|
|
||||||
while (n-- > 0) obj->data[n] = stx->nil;
|
if (variable_data == XP_NULL) {
|
||||||
|
while (n > nfields) obj->data[--n] = stx->nil;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while (n-- > 0) obj->data[n] = data[n];
|
while (n > nfields) {
|
||||||
|
n--; obj->data[n] = variable_data[n - nfields];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data == XP_NULL) {
|
||||||
|
while (n > 0) obj->data[--n] = stx->nil;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
while (n > 0) {
|
||||||
|
n--; obj->data[n] = data[n];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return idx;
|
return idx;
|
||||||
@ -50,17 +60,12 @@ xp_word_t xp_stx_alloc_byte_object (
|
|||||||
xp_word_t idx;
|
xp_word_t idx;
|
||||||
xp_stx_byte_object_t* obj;
|
xp_stx_byte_object_t* obj;
|
||||||
|
|
||||||
|
xp_assert (stx->nil == XP_STX_NIL);
|
||||||
|
|
||||||
idx = xp_stx_memory_alloc (
|
idx = xp_stx_memory_alloc (
|
||||||
&stx->memory, n + xp_sizeof(xp_stx_object_t));
|
&stx->memory, n + xp_sizeof(xp_stx_object_t));
|
||||||
if (idx >= stx->memory.capacity) return idx; /* failed */
|
if (idx >= stx->memory.capacity) return idx; /* failed */
|
||||||
|
|
||||||
xp_assert (stx->nil == XP_STX_NIL);
|
|
||||||
|
|
||||||
/*
|
|
||||||
XP_STX_CLASS(stx,idx) = stx->nil;
|
|
||||||
XP_STX_ACCESS(stx,idx) = (n << 2) | XP_STX_BYTE_INDEXED;
|
|
||||||
while (n-- > 0) XP_STX_BYTEAT(stx,idx,n) = 0;
|
|
||||||
*/
|
|
||||||
obj = XP_STX_BYTE_OBJECT(stx,idx);
|
obj = XP_STX_BYTE_OBJECT(stx,idx);
|
||||||
obj->header.class = stx->nil;
|
obj->header.class = stx->nil;
|
||||||
obj->header.access = (n << 2) | XP_STX_BYTE_INDEXED;
|
obj->header.access = (n << 2) | XP_STX_BYTE_INDEXED;
|
||||||
@ -83,24 +88,19 @@ xp_word_t xp_stx_alloc_char_object (
|
|||||||
xp_stx_alloc_char_objectx (stx, str, xp_strlen(str));
|
xp_stx_alloc_char_objectx (stx, str, xp_strlen(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* n: number of characters */
|
||||||
xp_word_t xp_stx_alloc_char_objectx (
|
xp_word_t xp_stx_alloc_char_objectx (
|
||||||
xp_stx_t* stx, const xp_char_t* str, xp_word_t n)
|
xp_stx_t* stx, const xp_char_t* str, xp_word_t n)
|
||||||
{
|
{
|
||||||
xp_word_t idx;
|
xp_word_t idx;
|
||||||
xp_stx_char_object_t* obj;
|
xp_stx_char_object_t* obj;
|
||||||
|
|
||||||
|
xp_assert (stx->nil == XP_STX_NIL);
|
||||||
|
|
||||||
idx = xp_stx_memory_alloc (&stx->memory,
|
idx = xp_stx_memory_alloc (&stx->memory,
|
||||||
(n + 1) * xp_sizeof(xp_char_t) + xp_sizeof(xp_stx_object_t));
|
(n + 1) * xp_sizeof(xp_char_t) + xp_sizeof(xp_stx_object_t));
|
||||||
if (idx >= stx->memory.capacity) return idx; /* failed */
|
if (idx >= stx->memory.capacity) return idx; /* failed */
|
||||||
|
|
||||||
xp_assert (stx->nil == XP_STX_NIL);
|
|
||||||
|
|
||||||
/*
|
|
||||||
XP_STX_CLASS(stx,idx) = stx->nil;
|
|
||||||
XP_STX_ACCESS(stx,idx) = (n << 2) | XP_STX_CHAR_INDEXED;
|
|
||||||
XP_STX_CHARAT(stx,idx,n) = XP_CHAR('\0');
|
|
||||||
while (n-- > 0) XP_STX_CHARAT(stx,idx,n) = str[n];
|
|
||||||
*/
|
|
||||||
obj = XP_STX_CHAR_OBJECT(stx,idx);
|
obj = XP_STX_CHAR_OBJECT(stx,idx);
|
||||||
obj->header.class = stx->nil;
|
obj->header.class = stx->nil;
|
||||||
obj->header.access = (n << 2) | XP_STX_CHAR_INDEXED;
|
obj->header.access = (n << 2) | XP_STX_CHAR_INDEXED;
|
||||||
@ -135,11 +135,6 @@ xp_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...)
|
|||||||
|
|
||||||
xp_assert (stx->nil == XP_STX_NIL);
|
xp_assert (stx->nil == XP_STX_NIL);
|
||||||
|
|
||||||
/*
|
|
||||||
XP_STX_CLASS(stx,idx) = stx->nil;
|
|
||||||
XP_STX_ACCESS(stx,idx) = (n << 2) | XP_STX_CHAR_INDEXED;
|
|
||||||
XP_STX_CHARAT(stx,idx,n) = XP_CHAR('\0');
|
|
||||||
*/
|
|
||||||
obj = XP_STX_CHAR_OBJECT(stx,idx);
|
obj = XP_STX_CHAR_OBJECT(stx,idx);
|
||||||
obj->header.class = stx->nil;
|
obj->header.class = stx->nil;
|
||||||
obj->header.access = (n << 2) | XP_STX_CHAR_INDEXED;
|
obj->header.access = (n << 2) | XP_STX_CHAR_INDEXED;
|
||||||
@ -166,14 +161,14 @@ xp_word_t xp_stx_hash_char_object (xp_stx_t* stx, xp_word_t idx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
xp_word_t xp_stx_instantiate (
|
xp_word_t xp_stx_instantiate (
|
||||||
xp_stx_t* stx, xp_word_t class_index, const void* data, xp_word_t size)
|
xp_stx_t* stx, xp_word_t class_index, const void* data,
|
||||||
|
const void* variable_data, xp_word_t variable_nfields)
|
||||||
{
|
{
|
||||||
xp_stx_class_t* class_obj;
|
xp_stx_class_t* class_obj;
|
||||||
xp_word_t spec, nfields, new;
|
xp_word_t spec, nfields, new;
|
||||||
int indexable;
|
int indexable;
|
||||||
|
|
||||||
class_obj = (xp_stx_class_t*)
|
class_obj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx, class_index);
|
||||||
XP_STX_WORD_OBJECT(stx, class_index);
|
|
||||||
|
|
||||||
/* don't instantiate a metaclass whose instance must be
|
/* don't instantiate a metaclass whose instance must be
|
||||||
created in a different way */
|
created in a different way */
|
||||||
@ -185,24 +180,24 @@ xp_word_t xp_stx_instantiate (
|
|||||||
indexable = spec & XP_STX_SPEC_INDEXABLE_MASK;
|
indexable = spec & XP_STX_SPEC_INDEXABLE_MASK;
|
||||||
|
|
||||||
if (indexable == XP_STX_SPEC_BYTE_INDEXABLE) {
|
if (indexable == XP_STX_SPEC_BYTE_INDEXABLE) {
|
||||||
xp_assert (nfields == 0);
|
xp_assert (nfields == 0 && data == XP_NULL);
|
||||||
new = xp_stx_alloc_byte_object (
|
new = xp_stx_alloc_byte_object(
|
||||||
stx, data, nfields + size);
|
stx, variable_data, variable_nfields);
|
||||||
}
|
}
|
||||||
else if (indexable == XP_STX_SPEC_CHAR_INDEXABLE) {
|
else if (indexable == XP_STX_SPEC_CHAR_INDEXABLE) {
|
||||||
xp_assert (nfields == 0);
|
xp_assert (nfields == 0 && data == XP_NULL);
|
||||||
new = xp_stx_alloc_char_objectx (
|
new = xp_stx_alloc_char_objectx(
|
||||||
stx, data, nfields + size);
|
stx, variable_data, variable_nfields);
|
||||||
}
|
}
|
||||||
else if (indexable == XP_STX_SPEC_WORD_INDEXABLE) {
|
else if (indexable == XP_STX_SPEC_WORD_INDEXABLE) {
|
||||||
new = xp_stx_alloc_word_object (
|
new = xp_stx_alloc_word_object (
|
||||||
stx, data, nfields + size);
|
stx, data, nfields, variable_data, variable_nfields);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
xp_assert (indexable == XP_STX_SPEC_NOT_INDEXABLE);
|
xp_assert (indexable == XP_STX_SPEC_NOT_INDEXABLE);
|
||||||
xp_assert (size == 0);
|
xp_assert (variable_nfields == 0 && variable_data == XP_NULL);
|
||||||
new = xp_stx_alloc_word_object (
|
new = xp_stx_alloc_word_object (
|
||||||
stx, data, nfields + size);
|
stx, data, nfields, XP_NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
XP_STX_CLASS(stx, new) = class_index;
|
XP_STX_CLASS(stx, new) = class_index;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: object.h,v 1.21 2005-07-05 06:26:33 bacon Exp $
|
* $Id: object.h,v 1.22 2005-07-05 09:02:13 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_STX_OBJECT_H_
|
#ifndef _XP_STX_OBJECT_H_
|
||||||
@ -16,7 +16,8 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
xp_word_t xp_stx_alloc_word_object (
|
xp_word_t xp_stx_alloc_word_object (
|
||||||
xp_stx_t* stx, const xp_word_t* data, xp_word_t n);
|
xp_stx_t* stx, const xp_word_t* data, xp_word_t nfields,
|
||||||
|
const xp_word_t* variable_data, xp_word_t variable_nfields);
|
||||||
|
|
||||||
xp_word_t xp_stx_alloc_byte_object (
|
xp_word_t xp_stx_alloc_byte_object (
|
||||||
xp_stx_t* stx, const xp_byte_t* data, xp_word_t n);
|
xp_stx_t* stx, const xp_byte_t* data, xp_word_t n);
|
||||||
@ -30,7 +31,8 @@ xp_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...);
|
|||||||
xp_word_t xp_stx_hash_char_object (xp_stx_t* stx, xp_word_t idx);
|
xp_word_t xp_stx_hash_char_object (xp_stx_t* stx, xp_word_t idx);
|
||||||
|
|
||||||
xp_word_t xp_stx_instantiate (
|
xp_word_t xp_stx_instantiate (
|
||||||
xp_stx_t* stx, xp_word_t class_index, const void* data, xp_word_t size);
|
xp_stx_t* stx, xp_word_t class_index, const void* data,
|
||||||
|
const void* variable_data, xp_word_t variable_nfields);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: parser.c,v 1.51 2005-07-05 06:26:33 bacon Exp $
|
* $Id: parser.c,v 1.52 2005-07-05 09:02:13 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/parser.h>
|
#include <xp/stx/parser.h>
|
||||||
#include <xp/stx/object.h>
|
#include <xp/stx/object.h>
|
||||||
#include <xp/stx/class.h>
|
#include <xp/stx/class.h>
|
||||||
|
#include <xp/stx/method.h>
|
||||||
|
#include <xp/stx/symbol.h>
|
||||||
#include <xp/stx/misc.h>
|
#include <xp/stx/misc.h>
|
||||||
|
|
||||||
static int __parse_method (
|
static int __parse_method (
|
||||||
@ -74,7 +76,7 @@ xp_stx_parser_t* xp_stx_parser_open (xp_stx_parser_t* parser, xp_stx_t* stx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (xp_array_open (
|
if (xp_array_open (
|
||||||
&parser->byte_code, 256,
|
&parser->bytecode, 256,
|
||||||
xp_sizeof(xp_byte_t), XP_NULL) == XP_NULL) {
|
xp_sizeof(xp_byte_t), XP_NULL) == XP_NULL) {
|
||||||
xp_stx_name_close (&parser->method_name);
|
xp_stx_name_close (&parser->method_name);
|
||||||
xp_stx_token_close (&parser->token);
|
xp_stx_token_close (&parser->token);
|
||||||
@ -106,7 +108,7 @@ void xp_stx_parser_close (xp_stx_parser_t* parser)
|
|||||||
xp_free (parser->temporary[--parser->temporary_count]);
|
xp_free (parser->temporary[--parser->temporary_count]);
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_array_close (&parser->byte_code);
|
xp_array_close (&parser->bytecode);
|
||||||
xp_stx_name_close (&parser->method_name);
|
xp_stx_name_close (&parser->method_name);
|
||||||
xp_stx_token_close (&parser->token);
|
xp_stx_token_close (&parser->token);
|
||||||
|
|
||||||
@ -265,6 +267,7 @@ static int __parse_method (
|
|||||||
GET_TOKEN (parser);
|
GET_TOKEN (parser);
|
||||||
|
|
||||||
xp_stx_name_clear (&parser->method_name);
|
xp_stx_name_clear (&parser->method_name);
|
||||||
|
xp_array_clear (&parser->bytecode);
|
||||||
|
|
||||||
while (parser->argument_count > 0) {
|
while (parser->argument_count > 0) {
|
||||||
xp_free (parser->argument[--parser->argument_count]);
|
xp_free (parser->argument[--parser->argument_count]);
|
||||||
@ -287,7 +290,10 @@ static int __finish_method (xp_stx_parser_t* parser)
|
|||||||
{
|
{
|
||||||
xp_stx_t* stx = parser->stx;
|
xp_stx_t* stx = parser->stx;
|
||||||
xp_stx_class_t* class_obj;
|
xp_stx_class_t* class_obj;
|
||||||
xp_word_t bytecodes;
|
xp_stx_method_t* method_obj;
|
||||||
|
xp_word_t method, selector;
|
||||||
|
|
||||||
|
xp_assert (parser->bytecode.size != 0);
|
||||||
|
|
||||||
class_obj = (xp_stx_class_t*)
|
class_obj = (xp_stx_class_t*)
|
||||||
XP_STX_WORD_OBJECT(stx, parser->method_class);
|
XP_STX_WORD_OBJECT(stx, parser->method_class);
|
||||||
@ -295,30 +301,31 @@ static int __finish_method (xp_stx_parser_t* parser)
|
|||||||
if (class_obj->methods == stx->nil) {
|
if (class_obj->methods == stx->nil) {
|
||||||
/* TODO: reconfigure method dictionary size */
|
/* TODO: reconfigure method dictionary size */
|
||||||
class_obj->methods = xp_stx_instantiate (
|
class_obj->methods = xp_stx_instantiate (
|
||||||
stx, stx->class_dictionary, XP_NULL, 64);
|
stx, stx->class_dictionary, XP_NULL, XP_NULL, 64);
|
||||||
}
|
}
|
||||||
xp_assert (class_obj->methods != stx->nil);
|
xp_assert (class_obj->methods != stx->nil);
|
||||||
|
|
||||||
/*
|
selector = xp_stx_new_symbolx (
|
||||||
bytecodes = xp_stx_instantiate (
|
stx, parser->method_name.buffer, parser->method_name.size);
|
||||||
stx, stx->class_bytearray,
|
|
||||||
parser->bytecodes, parser->bytecode_size);
|
method = xp_stx_instantiate(stx, stx->class_method,
|
||||||
*/
|
XP_NULL, parser->literals, parser->literal_count);
|
||||||
|
method_obj = (xp_stx_method_t*)XP_STX_WORD_OBJECT(stx, method);
|
||||||
|
|
||||||
/* TODO: text saving must be optional */
|
/* TODO: text saving must be optional */
|
||||||
/*
|
/*method_obj->text = xp_stx_instantiate (
|
||||||
method_obj->text =
|
stx, stx->class_string, XP_NULL,
|
||||||
xp_stx_new_string (stx, parser->text);
|
parser->text, xp_strlen(parser->text));
|
||||||
|
*/
|
||||||
method_obj->message =
|
method_obj->selector = selector;
|
||||||
xp_stx_new_symbol (stx, parser->method_name);
|
method_obj->bytecodes = xp_stx_instantiate (
|
||||||
method_obj->bytecodes = bytecodes;
|
stx, stx->class_bytearray, XP_NULL,
|
||||||
//method_obj->literals =
|
parser->bytecode.buffer, parser->bytecode.size);
|
||||||
|
/*
|
||||||
method_obj->stack_size = XP_STX_TO_SMALLINT(100);
|
method_obj->stack_size = XP_STX_TO_SMALLINT(100);
|
||||||
method_obj->temporary_size =
|
method_obj->temporary_size =
|
||||||
XP_STX_TO_SMALLINT(parser->temporary_count);
|
XP_STX_TO_SMALLINT(parser->temporary_count);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: parser.h,v 1.28 2005-07-04 11:47:25 bacon Exp $
|
* $Id: parser.h,v 1.29 2005-07-05 09:02:13 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_STX_PARSER_H_
|
#ifndef _XP_STX_PARSER_H_
|
||||||
@ -74,7 +74,7 @@ struct xp_stx_parser_t
|
|||||||
xp_word_t literals[256]; /* TODO: make it a dynamic array */
|
xp_word_t literals[256]; /* TODO: make it a dynamic array */
|
||||||
xp_word_t literal_count;
|
xp_word_t literal_count;
|
||||||
|
|
||||||
xp_array_t byte_code;
|
xp_array_t bytecode;
|
||||||
|
|
||||||
xp_stx_token_t token;
|
xp_stx_token_t token;
|
||||||
xp_cint_t curc;
|
xp_cint_t curc;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: stx.c,v 1.31 2005-07-05 04:29:31 bacon Exp $
|
* $Id: stx.c,v 1.32 2005-07-05 09:02:13 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/stx.h>
|
#include <xp/stx/stx.h>
|
||||||
@ -38,6 +38,7 @@ xp_stx_t* xp_stx_open (xp_stx_t* stx, xp_word_t capacity)
|
|||||||
stx->class_array = XP_STX_NIL;
|
stx->class_array = XP_STX_NIL;
|
||||||
stx->class_string = XP_STX_NIL;
|
stx->class_string = XP_STX_NIL;
|
||||||
stx->class_dictionary = XP_STX_NIL;
|
stx->class_dictionary = XP_STX_NIL;
|
||||||
|
stx->class_method = XP_STX_NIL;
|
||||||
|
|
||||||
stx->__wantabort = xp_false;
|
stx->__wantabort = xp_false;
|
||||||
return stx;
|
return stx;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: stx.h,v 1.31 2005-07-05 04:29:31 bacon Exp $
|
* $Id: stx.h,v 1.32 2005-07-05 09:02:13 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_STX_STX_H_
|
#ifndef _XP_STX_STX_H_
|
||||||
@ -79,6 +79,7 @@ struct xp_stx_t
|
|||||||
xp_word_t class_bytearray;
|
xp_word_t class_bytearray;
|
||||||
xp_word_t class_string;
|
xp_word_t class_string;
|
||||||
xp_word_t class_dictionary;
|
xp_word_t class_dictionary;
|
||||||
|
xp_word_t class_method;
|
||||||
|
|
||||||
xp_bool_t __malloced;
|
xp_bool_t __malloced;
|
||||||
xp_bool_t __wantabort; /* TODO: make it a function pointer */
|
xp_bool_t __wantabort; /* TODO: make it a function pointer */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: symbol.c,v 1.12 2005-07-05 06:28:03 bacon Exp $
|
* $Id: symbol.c,v 1.13 2005-07-05 09:02:13 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/symbol.h>
|
#include <xp/stx/symbol.h>
|
||||||
@ -10,7 +10,8 @@ xp_word_t xp_stx_new_symlink (xp_stx_t* stx, xp_word_t sym)
|
|||||||
{
|
{
|
||||||
xp_word_t x;
|
xp_word_t x;
|
||||||
|
|
||||||
x = xp_stx_alloc_word_object (stx, XP_NULL, XP_STX_SYMLINK_SIZE);
|
x = xp_stx_alloc_word_object(
|
||||||
|
stx, XP_NULL, XP_STX_SYMLINK_SIZE, XP_NULL, 0);
|
||||||
XP_STX_CLASS(stx,x) = stx->class_symlink;
|
XP_STX_CLASS(stx,x) = stx->class_symlink;
|
||||||
XP_STX_WORDAT(stx,x,XP_STX_SYMLINK_LINK) = stx->nil;
|
XP_STX_WORDAT(stx,x,XP_STX_SYMLINK_LINK) = stx->nil;
|
||||||
XP_STX_WORDAT(stx,x,XP_STX_SYMLINK_SYMBOL) = sym;
|
XP_STX_WORDAT(stx,x,XP_STX_SYMLINK_SYMBOL) = sym;
|
||||||
|
@ -10,8 +10,8 @@ perform: method with: x with: y with: z with: a with: b with: c
|
|||||||
"
|
"
|
||||||
b := -30 xxx nil this.
|
b := -30 xxx nil this.
|
||||||
"instanceClass := 10."
|
"instanceClass := 10."
|
||||||
literals := 20.
|
selector := 20.
|
||||||
Win32Errors := 10.
|
"Win32Errors := 10."
|
||||||
|
|
||||||
(jjj xxx: 10 xy) zzz: (10 fuck: 20 you: 40) yyy: kkk.
|
(jjj xxx: 10 xy) zzz: (10 fuck: 20 you: 40) yyy: kkk.
|
||||||
[ spec plus: 20]
|
[ spec plus: 20]
|
||||||
|
Loading…
Reference in New Issue
Block a user