diff --git a/stix/lib/comp.c b/stix/lib/comp.c index 6b26039..b228efb 100644 --- a/stix/lib/comp.c +++ b/stix/lib/comp.c @@ -1520,7 +1520,7 @@ done: * the position returned here doesn't consider * class instance variables that can be potentially * placed before the class variables. */ - var->cls = (stix_oop_class_t)super; + //???? var->cls = (stix_oop_class_t)super; /* THIS PART IS WRONG. FIX IT??? */ break; case VAR_CLASSINST: @@ -3304,6 +3304,7 @@ static int compile_class_definition (stix_t* stix) /* reset the structure to hold information about a class to be compiled */ stix->c->cls.flags = 0; + stix->c->cls.indexed_type = STIX_OBJ_TYPE_OOP; stix->c->cls.name.len = 0; stix->c->cls.supername.len = 0; diff --git a/stix/lib/exec.c b/stix/lib/exec.c index d9d18cb..85443d6 100644 --- a/stix/lib/exec.c +++ b/stix/lib/exec.c @@ -309,11 +309,15 @@ static int primitive_dump (stix_t* stix, stix_ooi_t nargs) STIX_ASSERT (nargs >= 0); - dump_object (stix, STACK_GET(stix, stix->sp - nargs), "receiver"); + printf ("RECEIVER:"); + print_object (stix, STACK_GET(stix, stix->sp - nargs)); + printf ("\n"); for (i = nargs; i > 0; ) { --i; - dump_object (stix, STACK_GET(stix, stix->sp - i), "argument"); + printf ("ARGUMENT:"); + print_object (stix, STACK_GET(stix, stix->sp - i)); + printf ("\n"); } STACK_POPS (stix, nargs); @@ -613,8 +617,8 @@ static primitive_t primitives[] = int stix_execute (stix_t* stix) { - volatile stix_oop_method_t mth; - volatile stix_oop_byte_t code; + stix_oop_method_t mth; + stix_oop_byte_t code; stix_byte_t bc, cmd; stix_ooi_t b1; @@ -715,7 +719,7 @@ printf ("JUMP %d\n", (int)b1); } obj = (stix_oop_oop_t)stix->active_context->origin->method->slot[obj_index]; -printf ("PUSH OBJVAR %d %d - ", (int)b1, (int)obj_index); +printf ("PUSH OBJVAR index=%d object_index_in_literal_frame=%d - ", (int)b1, (int)obj_index); STIX_ASSERT (STIX_OBJ_GET_FLAGS_TYPE(obj) == STIX_OBJ_TYPE_OOP); STIX_ASSERT (obj_index < STIX_OBJ_GET_SIZE(obj)); @@ -733,11 +737,13 @@ printf ("\n"); if (cmd == CMD_EXTEND_DOUBLE) obj_index = (obj_index << 8) | code->slot[stix->ip++]; -printf ("STORE OBJVAR %d %d\n", (int)b1, (int)obj_index); +printf ("STORE OBJVAR index=%d object_index_in_literal_frame=%d - ", (int)b1, (int)obj_index); obj = (stix_oop_oop_t)stix->active_context->origin->method->slot[obj_index]; STIX_ASSERT (STIX_OBJ_GET_FLAGS_TYPE(obj) == STIX_OBJ_TYPE_OOP); STIX_ASSERT (obj_index < STIX_OBJ_GET_SIZE(obj)); obj->slot[b1] = STACK_GETTOP(stix); +print_object (stix, obj->slot[b1]); +printf ("\n"); break; } diff --git a/stix/lib/gc.c b/stix/lib/gc.c index f559a79..4d146c2 100644 --- a/stix/lib/gc.c +++ b/stix/lib/gc.c @@ -164,12 +164,17 @@ static stix_uint8_t* scan_new_heap (stix_t* stix, stix_uint8_t* ptr) if (stix->_context && STIX_OBJ_GET_CLASS(oop) == stix->_context) { -/* TODO: need to do the same for block context?? */ - /* the stack in the context object doesn't need to be in - * full. the slots above the stack pointer are garbages. */ + /* the stack in the context object doesn't need to be + * scanned in full. the slots above the stack pointer + * are garbages. */ size = STIX_CONTEXT_NAMED_INSTVARS + STIX_OOP_TO_SMINT(((stix_oop_context_t)oop)->sp) + 1; } + else if (stix->_block_context && STIX_OBJ_GET_CLASS(oop) == stix->_block_context) + { + size = STIX_BLOCK_CONTEXT_NAMED_INSTVARS + + STIX_OOP_TO_SMINT(((stix_oop_block_context_t)oop)->sp) + 1; + } else { size = STIX_OBJ_GET_SIZE(oop); @@ -240,7 +245,6 @@ void stix_gc (stix_t* stix) stix->_association = stix_moveoop (stix, stix->_association); stix->_context = stix_moveoop (stix, stix->_context); stix->_block_context = stix_moveoop (stix, stix->_block_context); - /*stix->_process = stix_moveoop (stix, stix->_process);*/ stix->_true_class = stix_moveoop (stix, stix->_true_class); stix->_false_class = stix_moveoop (stix, stix->_false_class); stix->_character = stix_moveoop (stix, stix->_character); diff --git a/stix/lib/ignite.c b/stix/lib/ignite.c index f290ff3..76a4da0 100644 --- a/stix/lib/ignite.c +++ b/stix/lib/ignite.c @@ -118,18 +118,20 @@ static int ignite_1 (stix_t* stix) stix->_stix = alloc_kernel_class (stix, 1, STIX_CLASS_SPEC_MAKE(0, 0, STIX_OBJ_TYPE_OOP)); stix->_nil_object = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 0, STIX_OBJ_TYPE_OOP)); stix->_object = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 0, STIX_OBJ_TYPE_OOP)); + stix->_string = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 1, STIX_OBJ_TYPE_CHAR)); + + stix->_symbol = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 1, STIX_OBJ_TYPE_CHAR)); stix->_array = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 1, STIX_OBJ_TYPE_OOP)); stix->_byte_array = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 1, STIX_OBJ_TYPE_BYTE)); - stix->_string = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 1, STIX_OBJ_TYPE_CHAR)); - stix->_symbol = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 1, STIX_OBJ_TYPE_CHAR)); stix->_symbol_set = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_SET_NAMED_INSTVARS, 0, STIX_OBJ_TYPE_OOP)); stix->_system_dictionary = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_SET_NAMED_INSTVARS, 0, STIX_OBJ_TYPE_OOP)); + stix->_method_dictionary = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_SET_NAMED_INSTVARS, 0, STIX_OBJ_TYPE_OOP)); stix->_method = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_METHOD_NAMED_INSTVARS, 1, STIX_OBJ_TYPE_OOP)); stix->_association = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_ASSOCIATION_NAMED_INSTVARS, 0, STIX_OBJ_TYPE_OOP)); stix->_context = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_CONTEXT_NAMED_INSTVARS, 1, STIX_OBJ_TYPE_OOP)); stix->_block_context = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_BLOCK_CONTEXT_NAMED_INSTVARS, 1, STIX_OBJ_TYPE_OOP)); - /*stix->_process = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_PROCESS_NAMED_INSTVARS, 0, STIX_OBJ_TYPE_OOP));*/ + stix->_true_class = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 0, STIX_OBJ_TYPE_OOP)); stix->_false_class = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 0, STIX_OBJ_TYPE_OOP)); /* TOOD: what is a proper spec for Character and SmallInteger? @@ -139,12 +141,16 @@ static int ignite_1 (stix_t* stix) stix->_small_integer = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 0, STIX_OBJ_TYPE_OOP)); if (!stix->_stix || !stix->_nil_object || - !stix->_object || !stix->_array || - !stix->_byte_array || !stix->_string || - !stix->_symbol || !stix->_symbol_set || - !stix->_system_dictionary || !stix->_method_dictionary || + !stix->_object || !stix->_string || + + !stix->_symbol || !stix->_array || + !stix->_byte_array || !stix->_symbol_set || + !stix->_system_dictionary || + + !stix->_method_dictionary || !stix->_method || !stix->_association || !stix->_context || - !stix->_block_context || /*!stix->_process ||*/ + !stix->_block_context || + !stix->_true_class || !stix->_false_class || !stix->_character || !stix->_small_integer) return -1; @@ -214,7 +220,6 @@ static int ignite_3 (stix_t* stix) { 13, { 'M','e','t','h','o','d','C','o','n','t','e','x','t' } }, { 12, { 'B','l','o','c','k','C','o','n','t','e','x','t' } }, - /*{ 7, { 'P','r','o','c','e','s','s' } },*/ { 4, { 'T','r','u','e' } }, { 5, { 'F','a','l','s','e' } }, { 9, { 'C','h','a','r','a','c','t','e','r' } }, diff --git a/stix/lib/stix.h b/stix/lib/stix.h index cbbdba0..def4238 100644 --- a/stix/lib/stix.h +++ b/stix/lib/stix.h @@ -714,17 +714,19 @@ struct stix_t stix_oop_t _class; /* Class */ stix_oop_t _object; /* Object */ stix_oop_t _string; /* String */ + stix_oop_t _symbol; /* Symbol */ stix_oop_t _array; /* Array */ stix_oop_t _byte_array; /* ByteArray */ stix_oop_t _symbol_set; /* SymbolSet */ stix_oop_t _system_dictionary; /* SystemDictionary */ + stix_oop_t _method_dictionary; /* MethodDictionary */ stix_oop_t _method; /* CompiledMethod */ stix_oop_t _association; /* Association */ stix_oop_t _context; /* MethodContext */ stix_oop_t _block_context; /* BlockContext */ - /*stix_oop_t _process; */ /* Process */ + stix_oop_t _true_class; /* True */ stix_oop_t _false_class; /* False */ stix_oop_t _character; /* Character */