added partial code to parse message sending expressions
This commit is contained in:
parent
e6137a5864
commit
dab7285c45
1322
stix/lib/comp.c
1322
stix/lib/comp.c
File diff suppressed because it is too large
Load Diff
@ -95,7 +95,9 @@ stix_oop_t stix_moveoop (stix_t* stix, stix_oop_t oop)
|
||||
if (!oop) return oop;
|
||||
#endif
|
||||
|
||||
|
||||
STIX_ASSERT (STIX_OOP_IS_POINTER(oop));
|
||||
/*if (STIX_OOP_IS_POINTER(oop)) return oop;*/
|
||||
|
||||
if (STIX_OBJ_GET_FLAGS_MOVED(oop))
|
||||
{
|
||||
@ -188,8 +190,8 @@ void stix_gc (stix_t* stix)
|
||||
stix_oow_t i;
|
||||
stix_cb_t* cb;
|
||||
|
||||
printf ("STARTING GC curheap base %p ptr %p newheap base %p ptr %p\n",
|
||||
stix->curheap->base, stix->curheap->ptr, stix->newheap->base, stix->newheap->ptr);
|
||||
/*printf ("STARTING GC curheap base %p ptr %p newheap base %p ptr %p\n",
|
||||
stix->curheap->base, stix->curheap->ptr, stix->newheap->base, stix->newheap->ptr);*/
|
||||
/* TODO: allocate common objects like _nil and the root dictionary
|
||||
* in the permanant heap. minimize moving around */
|
||||
old_nil = stix->_nil;
|
||||
|
@ -176,7 +176,7 @@ static int ignite_2 (stix_t* stix)
|
||||
stix->sysdic = (stix_oop_set_t)tmp;
|
||||
|
||||
/* Export the system dictionary via the first class variable of the Stix class */
|
||||
((stix_oop_class_t)stix->_stix)->classvar[0] = (stix_oop_t)stix->sysdic;
|
||||
((stix_oop_class_t)stix->_stix)->vars[0] = (stix_oop_t)stix->sysdic;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -225,6 +225,7 @@ static char* syntax_error_msg[] =
|
||||
"} expected",
|
||||
"( expected",
|
||||
") expected",
|
||||
"] expected",
|
||||
". expected",
|
||||
"| expected",
|
||||
"> expected",
|
||||
@ -246,6 +247,7 @@ static char* syntax_error_msg[] =
|
||||
"unusable variable in compiled code",
|
||||
"inaccessible variable",
|
||||
"wrong expression primary",
|
||||
"too many arguments",
|
||||
"wrong primitive number"
|
||||
};
|
||||
|
||||
|
@ -185,11 +185,17 @@ stix_oop_t stix_instantiate (stix_t* stix, stix_oop_t _class, const void* vptr,
|
||||
* the variable part(indexed instance variables) are allowed. */
|
||||
oop = stix_allocoopobj(stix, named_instvar + vlen);
|
||||
|
||||
STIX_ASSERT (vptr == STIX_NULL);
|
||||
/*
|
||||
This function is not GC-safe. so i don't want to initialize
|
||||
propagate the payload of a pointer object. The caller can
|
||||
call this function and initialize payloads then.
|
||||
if (oop && vptr && vlen > 0)
|
||||
{
|
||||
stix_oop_oop_t hdr = (stix_oop_oop_t)oop;
|
||||
STIX_MEMCPY (&hdr->slot[named_instvar], vptr, vlen * STIX_SIZEOF(stix_oop_t));
|
||||
}
|
||||
*/
|
||||
break;
|
||||
|
||||
case STIX_OBJ_TYPE_CHAR:
|
||||
|
@ -270,6 +270,7 @@ enum stix_synerrnum_t
|
||||
STIX_SYNERR_RBRACE, /* } expected */
|
||||
STIX_SYNERR_LPAREN, /* ( expected */
|
||||
STIX_SYNERR_RPAREN, /* ) expected */
|
||||
STIX_SYNERR_RBRACK, /* ] expected */
|
||||
STIX_SYNERR_PERIOD, /* . expected */
|
||||
STIX_SYNERR_VBAR, /* | expected */
|
||||
STIX_SYNERR_GT, /* > expected */
|
||||
@ -291,6 +292,7 @@ enum stix_synerrnum_t
|
||||
STIX_SYNERR_VARUNUSE, /* unsuable variable in compiled code */
|
||||
STIX_SYNERR_VARINACC, /* inaccessible variable - e.g. accessing an instance variable from a class method is not allowed. */
|
||||
STIX_SYNERR_PRIMARY, /* wrong expression primary */
|
||||
STIX_SYNERR_ARGFLOOD, /* too many arguments */
|
||||
STIX_SYNERR_PRIMITIVENO /* wrong primitive number */
|
||||
};
|
||||
typedef enum stix_synerrnum_t stix_synerrnum_t;
|
||||
@ -310,129 +312,6 @@ struct stix_synerr_t
|
||||
typedef struct stix_synerr_t stix_synerr_t;
|
||||
|
||||
|
||||
/**
|
||||
* The stix_code_t type defines byte-code enumerators.
|
||||
*/
|
||||
enum stix_code_id_t
|
||||
{
|
||||
/* 0-15 */
|
||||
STIX_PUSH_RECEIVER_VARIABLE = 0x00,
|
||||
|
||||
/* 16-31 */
|
||||
STIX_PUSH_TEMPORARY_LOCATION = 0x10,
|
||||
|
||||
/* 32-63 */
|
||||
STIX_PUSH_LITERAL_CONSTANT = 0x20,
|
||||
|
||||
/* 64-95 */
|
||||
STIX_PUSH_LITERAL_VARIABLE = 0x40,
|
||||
|
||||
/* 96-103 */
|
||||
STIX_POP_STORE_RECEIVER_VARIABLE = 0x60,
|
||||
|
||||
/* 104-111 */
|
||||
STIX_POP_STORE_TEMPORARY_LOCATION = 0x68,
|
||||
|
||||
/* 112-119 */
|
||||
STIX_PUSH_RECEIVER = 0x70,
|
||||
STIX_PUSH_TRUE = 0x71,
|
||||
STIX_PUSH_FALSE = 0x72,
|
||||
STIX_PUSH_NIL = 0x73,
|
||||
STIX_PUSH_MINUSONE = 0x74,
|
||||
STIX_PUSH_ZERO = 0x75,
|
||||
STIX_PUSH_ONE = 0x76,
|
||||
STIX_PUSH_TWO = 0x77,
|
||||
|
||||
/* 120-123 */
|
||||
STIX_RETURN_RECEIVER = 0x78,
|
||||
STIX_RETURN_TRUE = 0x79,
|
||||
STIX_RETURN_FALSE = 0x7A,
|
||||
STIX_RETURN_NIL = 0x7B,
|
||||
|
||||
/* 124-125 */
|
||||
STIX_RETURN_FROM_MESSAGE = 0x7C,
|
||||
STIX_RETURN_FROM_BLOCK = 0x7D,
|
||||
|
||||
/* 128 */
|
||||
STIX_PUSH_EXTENDED = 0x80,
|
||||
|
||||
/* 129 */
|
||||
STIX_STORE_EXTENDED = 0x81,
|
||||
|
||||
/* 130 */
|
||||
STIX_POP_STORE_EXTENDED = 0x82,
|
||||
|
||||
/* 131 */
|
||||
STIX_SEND_TO_SELF = 0x83,
|
||||
|
||||
/* 132 */
|
||||
STIX_SEND_TO_SUPER = 0x84,
|
||||
|
||||
/* 133 */
|
||||
STIX_SEND_TO_SELF_EXTENDED = 0x85,
|
||||
|
||||
/* 134 */
|
||||
STIX_SEND_TO_SUPER_EXTENDED = 0x86,
|
||||
|
||||
/* 135 */
|
||||
STIX_POP_STACK_TOP = 0x87,
|
||||
|
||||
/* 136 */
|
||||
STIX_DUP_STACK_TOP = 0x88,
|
||||
|
||||
/* 137 */
|
||||
STIX_PUSH_ACTIVE_CONTEXT = 0x89,
|
||||
|
||||
/* 138 */
|
||||
STIX_DO_PRIMITIVE = 0x8A,
|
||||
|
||||
/* 144-151 */
|
||||
STIX_JUMP = 0x90,
|
||||
|
||||
/* 152-159 */
|
||||
STIX_POP_JUMP_ON_FALSE = 0x98,
|
||||
|
||||
/* 160-167 */
|
||||
STIX_JUMP_EXTENDED = 0xA0,
|
||||
|
||||
/* 168-171 */
|
||||
STIX_POP_JUMP_ON_TRUE_EXTENDED = 0xA8,
|
||||
|
||||
/* 172-175 */
|
||||
STIX_POP_JUMP_ON_FALSE_EXTENDED = 0xAC,
|
||||
|
||||
#if 0
|
||||
STIX_PUSH_RECEIVER_VARIABLE_EXTENDED = 0x60
|
||||
STIX_PUSH_TEMPORARY_LOCATION_EXTENDED = 0x61
|
||||
STIX_PUSH_LITERAL_CONSTANT_EXTENDED = 0x62
|
||||
STIX_PUSH_LITERAL_VARIABLE_EXTENDED = 0x63
|
||||
STIX_STORE_RECEIVER_VARIABLE_EXTENDED = 0x64
|
||||
STIX_STORE_TEMPORARY_LOCATION_EXTENDED = 0x65
|
||||
|
||||
STIX_POP_STACK_TOP = 0x67
|
||||
STIX_DUPLICATE_STACK_TOP = 0x68
|
||||
STIX_PUSH_ACTIVE_CONTEXT = 0x69
|
||||
STIX_PUSH_NIL = 0x6A
|
||||
STIX_PUSH_TRUE = 0x6B
|
||||
STIX_PUSH_FALSE = 0x6C
|
||||
STIX_PUSH_RECEIVER = 0x6D
|
||||
|
||||
STIX_SEND_TO_SELF = 0x70
|
||||
STIX_SEND_TO_SUPER = 0x71
|
||||
STIX_SEND_TO_SELF_EXTENDED = 0x72
|
||||
STIX_SEND_TO_SUPER_EXTENDED = 0x73
|
||||
|
||||
STIX_RETURN_RECEIVER = 0x78
|
||||
STIX_RETURN_TRUE = 0x79
|
||||
STIX_RETURN_FALSE = 0x7A
|
||||
STIX_RETURN_NIL = 0x7B
|
||||
STIX_RETURN_FROM_MESSAGE = 0x7C
|
||||
STIX_RETURN_FROM_BLOCK = 0x7D
|
||||
|
||||
STIX_DO_PRIMITIVE = 0xF0
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef enum stix_code_id_t stix_code_id_t;
|
||||
|
||||
|
||||
@ -475,7 +354,6 @@ struct stix_compiler_t
|
||||
stix_uch_t ilchr;
|
||||
stix_ucs_t ilchr_ucs;
|
||||
|
||||
|
||||
/* information about a class being compiled */
|
||||
struct
|
||||
{
|
||||
@ -518,6 +396,14 @@ struct stix_compiler_t
|
||||
stix_ucs_t assignees;
|
||||
stix_size_t assignees_capa;
|
||||
|
||||
/* buffer to store binary selectors being worked on */
|
||||
stix_ucs_t binsels;
|
||||
stix_size_t binsels_capa;
|
||||
|
||||
/* buffer to store keyword selectors being worked on */
|
||||
stix_ucs_t kwsels;
|
||||
stix_size_t kwsels_capa;
|
||||
|
||||
/* method name */
|
||||
stix_ucs_t name;
|
||||
stix_size_t name_capa;
|
||||
|
@ -523,7 +523,7 @@ struct stix_class_t
|
||||
stix_oop_set_t classmths; /* class methods, MethodDictionary */
|
||||
|
||||
/* indexed part afterwards */
|
||||
stix_oop_t classvar[1]; /* most classes have no class variables. better to be 0 */
|
||||
stix_oop_t vars[1]; /* class instance variables and class variables. */
|
||||
};
|
||||
typedef struct stix_class_t stix_class_t;
|
||||
typedef struct stix_class_t* stix_oop_class_t;
|
||||
|
@ -47,11 +47,22 @@ method-return-statement := "^" method-expression
|
||||
|
||||
method-expression := method-assignment-expression | basic-expression
|
||||
method-assignment-expression := identifier ":=" method-expression
|
||||
basic-expression := expression-primary (message cascaded-message)?
|
||||
basic-expression := expression-primary (message-expression cascaded-message-expression)?
|
||||
expression-primary := identifier | literal | block-constructor | ( "(" method-expression ")" )
|
||||
|
||||
----------------------------------------------------------
|
||||
|
||||
message-expression := (unary-message-expression+ binary-message-expresson* keyword-message-expression?) |
|
||||
(binary-message-expression+ keyword-message-expression?) |
|
||||
keyword-message-expression
|
||||
cascaded-message-expression := (";" message-expression)*
|
||||
keyword-message-expression := (keyword keyword-argument)+
|
||||
keyword-argument := expression-primary unary-selector* binary-message-expression*
|
||||
binary-message-expression := binary-selector binary-argument
|
||||
binary-argument := expression-primary unary-selector*
|
||||
|
||||
------------------------------------------------------------
|
||||
|
||||
#include '....'.
|
||||
|
||||
#class Test(Object)
|
||||
|
Loading…
Reference in New Issue
Block a user