cleaned up bootstrapping code a bit
This commit is contained in:
parent
37cf7be1bb
commit
fb48e48889
@ -71,6 +71,7 @@ class Semaphore(Object)
|
|||||||
method(#primitive) wait.
|
method(#primitive) wait.
|
||||||
|
|
||||||
(*
|
(*
|
||||||
|
TODO: timed wait...
|
||||||
method waitWithTimeout: seconds
|
method waitWithTimeout: seconds
|
||||||
{
|
{
|
||||||
<primitive: #_semaphore_wait>
|
<primitive: #_semaphore_wait>
|
||||||
@ -122,6 +123,51 @@ class Semaphore(Object)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SemaphoreGroup(Object)
|
||||||
|
{
|
||||||
|
var arr, size := 0.
|
||||||
|
|
||||||
|
(* TODO: good idea to a shortcut way to prohibit a certain method in the heirarchy chain?
|
||||||
|
|
||||||
|
method(#class,#prohibited) new.
|
||||||
|
method(#class,#prohibited) new: size.
|
||||||
|
method(#class,#abstract) xxx. => method(#class) xxx { self subclassResponsibility: #xxxx }
|
||||||
|
*)
|
||||||
|
|
||||||
|
method(#class) new { self messageProhibited: #new }
|
||||||
|
method(#class) new: size { self messageProhibited: #new: }
|
||||||
|
|
||||||
|
method(#class,#variadic) with()
|
||||||
|
{
|
||||||
|
| i x arr |
|
||||||
|
|
||||||
|
i := 0.
|
||||||
|
x := thisContext vargCount.
|
||||||
|
|
||||||
|
arr := Array new: x.
|
||||||
|
while (i < x)
|
||||||
|
{
|
||||||
|
arr at: i put: (thisContext vargAt: i).
|
||||||
|
i := i + 1.
|
||||||
|
}.
|
||||||
|
|
||||||
|
^self basicNew initialize: arr.
|
||||||
|
}
|
||||||
|
|
||||||
|
method initialize
|
||||||
|
{
|
||||||
|
self.arr := Array new: 10.
|
||||||
|
}
|
||||||
|
|
||||||
|
method initialize: arr
|
||||||
|
{
|
||||||
|
self.size := arr size.
|
||||||
|
self.arr := arr.
|
||||||
|
}
|
||||||
|
|
||||||
|
method(#primitive) wait.
|
||||||
|
}
|
||||||
|
|
||||||
class SemaphoreHeap(Object)
|
class SemaphoreHeap(Object)
|
||||||
{
|
{
|
||||||
var arr, size.
|
var arr, size.
|
||||||
@ -144,16 +190,16 @@ class SemaphoreHeap(Object)
|
|||||||
|
|
||||||
method insert: aSemaphore
|
method insert: aSemaphore
|
||||||
{
|
{
|
||||||
| index |
|
| index newarr newsize |
|
||||||
|
|
||||||
index := self.size.
|
index := self.size.
|
||||||
(index >= (self.arr size)) ifTrue: [
|
if (index >= (self.arr size))
|
||||||
| newarr newsize |
|
{
|
||||||
newsize := (self.arr size) * 2.
|
newsize := (self.arr size) * 2.
|
||||||
newarr := Array new: newsize.
|
newarr := Array new: newsize.
|
||||||
newarr copy: self.arr.
|
newarr copy: self.arr.
|
||||||
self.arr := newarr.
|
self.arr := newarr.
|
||||||
].
|
}.
|
||||||
|
|
||||||
self.arr at: index put: aSemaphore.
|
self.arr at: index put: aSemaphore.
|
||||||
aSemaphore heapIndex: index.
|
aSemaphore heapIndex: index.
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#define PROC_STATE_SUSPENDED 0
|
#define PROC_STATE_SUSPENDED 0
|
||||||
#define PROC_STATE_TERMINATED -1
|
#define PROC_STATE_TERMINATED -1
|
||||||
|
|
||||||
static const char* proc_state_to_string (int state)
|
static MOO_INLINE const char* proc_state_to_string (int state)
|
||||||
{
|
{
|
||||||
static const char* str[] =
|
static const char* str[] =
|
||||||
{
|
{
|
||||||
@ -45,6 +45,7 @@ static const char* proc_state_to_string (int state)
|
|||||||
|
|
||||||
return str[state + 1];
|
return str[state + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: adjust this process map increment value */
|
/* TODO: adjust this process map increment value */
|
||||||
#define PROC_MAP_INC 64
|
#define PROC_MAP_INC 64
|
||||||
|
|
||||||
@ -753,6 +754,18 @@ static void await_semaphore (moo_t* moo, moo_oop_semaphore_t sem)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void await_semaphore_group (moo_t* moo, moo_oop_semaphore_group_t sem_group)
|
||||||
|
{
|
||||||
|
moo_oop_oop_t proc;
|
||||||
|
|
||||||
|
/* wait for one of semaphores in the group to be signaled */
|
||||||
|
|
||||||
|
/*MOO_CLASSOF (moo, MOO_CLASSOF(sem_group) == moo->_semaphore_group);*/
|
||||||
|
/* TODO: check if a semaphore has been signalled already.. */
|
||||||
|
|
||||||
|
/* if not,, chain all semaphore into the semaphore list... */
|
||||||
|
}
|
||||||
|
|
||||||
static void sift_up_sem_heap (moo_t* moo, moo_ooi_t index)
|
static void sift_up_sem_heap (moo_t* moo, moo_ooi_t index)
|
||||||
{
|
{
|
||||||
if (index > 0)
|
if (index > 0)
|
||||||
@ -2376,6 +2389,24 @@ static moo_pfrc_t pf_semaphore_wait (moo_t* moo, moo_ooi_t nargs)
|
|||||||
return MOO_PF_SUCCESS;
|
return MOO_PF_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static moo_pfrc_t pf_semaphore_group_wait (moo_t* moo, moo_ooi_t nargs)
|
||||||
|
{
|
||||||
|
moo_oop_t rcv;
|
||||||
|
MOO_ASSERT (moo, nargs == 0);
|
||||||
|
|
||||||
|
rcv = MOO_STACK_GETRCV(moo, nargs);
|
||||||
|
if (MOO_CLASSOF(moo,rcv) != moo->_semaphore_group)
|
||||||
|
{
|
||||||
|
MOO_STACK_SETRETTOERROR (moo, nargs, MOO_EMSGRCV);
|
||||||
|
return MOO_PF_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
await_semaphore_group (moo, (moo_oop_semaphore_group_t)rcv);
|
||||||
|
|
||||||
|
MOO_STACK_SETRETTORCV (moo, nargs);
|
||||||
|
return MOO_PF_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static moo_pfrc_t pf_processor_schedule (moo_t* moo, moo_ooi_t nargs)
|
static moo_pfrc_t pf_processor_schedule (moo_t* moo, moo_ooi_t nargs)
|
||||||
{
|
{
|
||||||
moo_oop_t rcv, arg;
|
moo_oop_t rcv, arg;
|
||||||
@ -4097,6 +4128,7 @@ static pf_t pftab[] =
|
|||||||
|
|
||||||
{ "Semaphore_signal", { pf_semaphore_signal, 0, 0 } },
|
{ "Semaphore_signal", { pf_semaphore_signal, 0, 0 } },
|
||||||
{ "Semaphore_wait", { pf_semaphore_wait, 0, 0 } },
|
{ "Semaphore_wait", { pf_semaphore_wait, 0, 0 } },
|
||||||
|
{ "SemaphoreGroup_wait", { pf_semaphore_group_wait, 0, 0 } },
|
||||||
|
|
||||||
{ "SmallInteger_asCharacter", { pf_smooi_as_character, 0, 0 } },
|
{ "SmallInteger_asCharacter", { pf_smooi_as_character, 0, 0 } },
|
||||||
{ "SmallInteger_asError", { pf_smooi_as_error, 0, 0 } },
|
{ "SmallInteger_asError", { pf_smooi_as_error, 0, 0 } },
|
||||||
@ -4475,7 +4507,7 @@ static int start_method (moo_t* moo, moo_oop_method_t method, moo_oow_t nargs)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MOO_DEBUG3 (moo, "Sending primitiveFailed for empty primitive body - %O>>%.*js\n", method->owner, MOO_OBJ_GET_SIZE(method->name), MOO_OBJ_GET_CHAR_SLOT(method->name));
|
MOO_DEBUG3 (moo, "Sending primitiveFailed - %O>>%.*js\n", method->owner, MOO_OBJ_GET_SIZE(method->name), MOO_OBJ_GET_CHAR_SLOT(method->name));
|
||||||
/*
|
/*
|
||||||
* | arg1 | <---- stack_base + 3
|
* | arg1 | <---- stack_base + 3
|
||||||
* | arg0 | <---- stack_base + 2
|
* | arg0 | <---- stack_base + 2
|
||||||
|
378
moo/lib/gc.c
378
moo/lib/gc.c
@ -75,46 +75,275 @@ struct kernel_class_info_t
|
|||||||
{
|
{
|
||||||
moo_oow_t len;
|
moo_oow_t len;
|
||||||
moo_ooch_t name[20];
|
moo_ooch_t name[20];
|
||||||
|
int class_flags;
|
||||||
|
|
||||||
|
int class_spec_named_instvars;
|
||||||
|
int class_spec_flags;
|
||||||
|
int class_spec_indexed_type;
|
||||||
|
|
||||||
moo_oow_t offset;
|
moo_oow_t offset;
|
||||||
};
|
};
|
||||||
typedef struct kernel_class_info_t kernel_class_info_t;
|
typedef struct kernel_class_info_t kernel_class_info_t;
|
||||||
|
|
||||||
static kernel_class_info_t kernel_classes[] =
|
static kernel_class_info_t kernel_classes[] =
|
||||||
{
|
{
|
||||||
{ 4, { 'A','p','e','x' }, MOO_OFFSETOF(moo_t, _apex) },
|
/* --------------------------------------------------------------
|
||||||
{ 15, { 'U','n','d','e','f','i','n','e','d','O','b','j','e','c','t' }, MOO_OFFSETOF(moo_t, _undefined_object) },
|
* Apex - proto-object with 1 class variable.
|
||||||
{ 5, { 'C','l','a','s','s' }, MOO_OFFSETOF(moo_t, _class) },
|
* UndefinedObject - class for the nil object.
|
||||||
{ 6, { 'O','b','j','e','c','t' }, MOO_OFFSETOF(moo_t, _object) },
|
* Object - top of all ordinary objects.
|
||||||
{ 6, { 'S','t','r','i','n','g' }, MOO_OFFSETOF(moo_t, _string) },
|
* String
|
||||||
|
* Symbol
|
||||||
|
* Array
|
||||||
|
* ByteArray
|
||||||
|
* SymbolSet
|
||||||
|
* Character
|
||||||
|
* SmallIntger
|
||||||
|
* -------------------------------------------------------------- */
|
||||||
|
|
||||||
{ 6, { 'S','y','m','b','o','l' }, MOO_OFFSETOF(moo_t, _symbol) },
|
{ 4,
|
||||||
{ 5, { 'A','r','r','a','y' }, MOO_OFFSETOF(moo_t, _array) },
|
{ 'A','p','e','x' },
|
||||||
{ 9, { 'B','y','t','e','A','r','r','a','y' }, MOO_OFFSETOF(moo_t, _byte_array) },
|
0,
|
||||||
{ 9, { 'S','y','m','b','o','l','S','e','t' }, MOO_OFFSETOF(moo_t, _symbol_set) },
|
0,
|
||||||
{ 10, { 'D','i','c','t','i','o','n','a','r','y' }, MOO_OFFSETOF(moo_t, _dictionary) },
|
0,
|
||||||
{ 9, { 'N','a','m','e','s','p','a','c','e' }, MOO_OFFSETOF(moo_t, _namespace) },
|
MOO_OBJ_TYPE_OOP,
|
||||||
{ 14, { 'P','o','o','l','D','i','c','t','i','o','n','a','r','y' }, MOO_OFFSETOF(moo_t, _pool_dictionary) },
|
MOO_OFFSETOF(moo_t, _apex) },
|
||||||
{ 16, { 'M','e','t','h','o','d','D','i','c','t','i','o','n','a','r','y' }, MOO_OFFSETOF(moo_t, _method_dictionary) },
|
|
||||||
{ 14, { 'C','o','m','p','i','l','e','d','M','e','t','h','o','d' }, MOO_OFFSETOF(moo_t, _method) },
|
|
||||||
{ 11, { 'A','s','s','o','c','i','a','t','i','o','n' }, MOO_OFFSETOF(moo_t, _association) },
|
|
||||||
|
|
||||||
{ 13, { 'M','e','t','h','o','d','C','o','n','t','e','x','t' }, MOO_OFFSETOF(moo_t, _method_context) },
|
{ 15,
|
||||||
{ 12, { 'B','l','o','c','k','C','o','n','t','e','x','t' }, MOO_OFFSETOF(moo_t, _block_context) },
|
{ 'U','n','d','e','f','i','n','e','d','O','b','j','e','c','t' },
|
||||||
{ 7, { 'P','r','o','c','e','s','s' }, MOO_OFFSETOF(moo_t, _process) },
|
0,
|
||||||
{ 9, { 'S','e','m','a','p','h','o','r','e' }, MOO_OFFSETOF(moo_t, _semaphore) },
|
0,
|
||||||
{ 16, { 'P','r','o','c','e','s','s','S','c','h','e','d','u','l','e','r' }, MOO_OFFSETOF(moo_t, _process_scheduler) },
|
0,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _undefined_object) },
|
||||||
|
|
||||||
{ 5, { 'E','r','r','o','r' }, MOO_OFFSETOF(moo_t, _error_class) },
|
#define KCI_CLASS 2
|
||||||
{ 4, { 'T','r','u','e' }, MOO_OFFSETOF(moo_t, _true_class) },
|
{ 5,
|
||||||
{ 5, { 'F','a','l','s','e' }, MOO_OFFSETOF(moo_t, _false_class) },
|
{ 'C','l','a','s','s' },
|
||||||
{ 9, { 'C','h','a','r','a','c','t','e','r' }, MOO_OFFSETOF(moo_t, _character) },
|
MOO_CLASS_SELFSPEC_FLAG_LIMITED,
|
||||||
{ 12, { 'S','m','a','l','l','I','n','t','e','g','e','r' }, MOO_OFFSETOF(moo_t, _small_integer) },
|
MOO_CLASS_NAMED_INSTVARS,
|
||||||
|
1,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _class) },
|
||||||
|
|
||||||
{ 20, { 'L','a','r','g','e','P','o','s','i','t','i','v','e','I','n','t','e','g','e','r' }, MOO_OFFSETOF(moo_t, _large_positive_integer) },
|
{ 6,
|
||||||
{ 20, { 'L','a','r','g','e','N','e','g','a','t','i','v','e','I','n','t','e','g','e','r' }, MOO_OFFSETOF(moo_t, _large_negative_integer) },
|
{ 'O','b','j','e','c','t' },
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _object) },
|
||||||
|
|
||||||
{ 12, { 'S','m','a','l','l','P','o','i','n','t','e','r' }, MOO_OFFSETOF(moo_t, _small_pointer) },
|
{ 6,
|
||||||
{ 6, { 'S','y','s','t','e','m' }, MOO_OFFSETOF(moo_t, _system) },
|
{ 'S','t','r','i','n','g' },
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
MOO_CLASS_SPEC_FLAG_INDEXED,
|
||||||
|
MOO_OBJ_TYPE_CHAR,
|
||||||
|
MOO_OFFSETOF(moo_t, _string) },
|
||||||
|
|
||||||
|
{ 6,
|
||||||
|
{ 'S','y','m','b','o','l' },
|
||||||
|
MOO_CLASS_SELFSPEC_FLAG_FINAL | MOO_CLASS_SELFSPEC_FLAG_LIMITED,
|
||||||
|
0,
|
||||||
|
MOO_CLASS_SPEC_FLAG_INDEXED | MOO_CLASS_SPEC_FLAG_IMMUTABLE,
|
||||||
|
MOO_OBJ_TYPE_CHAR,
|
||||||
|
MOO_OFFSETOF(moo_t, _symbol) },
|
||||||
|
|
||||||
|
{ 5,
|
||||||
|
{ 'A','r','r','a','y' },
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
MOO_CLASS_SPEC_FLAG_INDEXED,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _array) },
|
||||||
|
|
||||||
|
{ 9,
|
||||||
|
{ 'B','y','t','e','A','r','r','a','y' },
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
MOO_CLASS_SPEC_FLAG_INDEXED,
|
||||||
|
MOO_OBJ_TYPE_BYTE,
|
||||||
|
MOO_OFFSETOF(moo_t, _byte_array) },
|
||||||
|
|
||||||
|
{ 9,
|
||||||
|
{ 'S','y','m','b','o','l','S','e','t' },
|
||||||
|
0,
|
||||||
|
MOO_DIC_NAMED_INSTVARS,
|
||||||
|
0,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _symbol_set) },
|
||||||
|
|
||||||
|
{ 10,
|
||||||
|
{ 'D','i','c','t','i','o','n','a','r','y' },
|
||||||
|
0,
|
||||||
|
MOO_DIC_NAMED_INSTVARS,
|
||||||
|
0,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _dictionary) },
|
||||||
|
|
||||||
|
{ 9,
|
||||||
|
{ 'N','a','m','e','s','p','a','c','e' },
|
||||||
|
MOO_CLASS_SELFSPEC_FLAG_LIMITED,
|
||||||
|
MOO_NSDIC_NAMED_INSTVARS,
|
||||||
|
0,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _namespace) },
|
||||||
|
|
||||||
|
{ 14,
|
||||||
|
{ 'P','o','o','l','D','i','c','t','i','o','n','a','r','y' },
|
||||||
|
0,
|
||||||
|
MOO_DIC_NAMED_INSTVARS,
|
||||||
|
0,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _pool_dictionary) },
|
||||||
|
|
||||||
|
{ 16,
|
||||||
|
{ 'M','e','t','h','o','d','D','i','c','t','i','o','n','a','r','y' },
|
||||||
|
0,
|
||||||
|
MOO_DIC_NAMED_INSTVARS,
|
||||||
|
0,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _method_dictionary) },
|
||||||
|
|
||||||
|
{ 14,
|
||||||
|
{ 'C','o','m','p','i','l','e','d','M','e','t','h','o','d' },
|
||||||
|
0,
|
||||||
|
MOO_METHOD_NAMED_INSTVARS,
|
||||||
|
MOO_CLASS_SPEC_FLAG_INDEXED,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _method) },
|
||||||
|
|
||||||
|
|
||||||
|
{ 11,
|
||||||
|
{ 'A','s','s','o','c','i','a','t','i','o','n' },
|
||||||
|
0,
|
||||||
|
MOO_ASSOCIATION_NAMED_INSTVARS,
|
||||||
|
0,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _association) },
|
||||||
|
|
||||||
|
{ 13,
|
||||||
|
{ 'M','e','t','h','o','d','C','o','n','t','e','x','t' },
|
||||||
|
0,
|
||||||
|
MOO_CONTEXT_NAMED_INSTVARS,
|
||||||
|
MOO_CLASS_SPEC_FLAG_INDEXED,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _method_context) },
|
||||||
|
|
||||||
|
{ 12,
|
||||||
|
{ 'B','l','o','c','k','C','o','n','t','e','x','t' },
|
||||||
|
0,
|
||||||
|
MOO_CONTEXT_NAMED_INSTVARS,
|
||||||
|
MOO_CLASS_SPEC_FLAG_INDEXED,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _block_context) },
|
||||||
|
|
||||||
|
{ 7,
|
||||||
|
{ 'P','r','o','c','e','s','s' },
|
||||||
|
MOO_CLASS_SELFSPEC_FLAG_FINAL | MOO_CLASS_SELFSPEC_FLAG_LIMITED,
|
||||||
|
MOO_PROCESS_NAMED_INSTVARS,
|
||||||
|
MOO_CLASS_SPEC_FLAG_INDEXED,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _process) },
|
||||||
|
|
||||||
|
{ 9,
|
||||||
|
{ 'S','e','m','a','p','h','o','r','e' },
|
||||||
|
0,
|
||||||
|
MOO_SEMAPHORE_NAMED_INSTVARS,
|
||||||
|
0,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _semaphore) },
|
||||||
|
|
||||||
|
{ 14,
|
||||||
|
{ 'S','e','m','a','p','h','o','r','e','G','r','o','u','p' },
|
||||||
|
0,
|
||||||
|
MOO_SEMAPHORE_GROUP_NAMED_INSTVARS,
|
||||||
|
0,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _semaphore_group) },
|
||||||
|
|
||||||
|
{ 16,
|
||||||
|
{ 'P','r','o','c','e','s','s','S','c','h','e','d','u','l','e','r' },
|
||||||
|
MOO_CLASS_SELFSPEC_FLAG_FINAL | MOO_CLASS_SELFSPEC_FLAG_LIMITED,
|
||||||
|
MOO_PROCESS_SCHEDULER_NAMED_INSTVARS,
|
||||||
|
0,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _process_scheduler) },
|
||||||
|
|
||||||
|
{ 5,
|
||||||
|
{ 'E','r','r','o','r' },
|
||||||
|
MOO_CLASS_SELFSPEC_FLAG_LIMITED,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _error_class) },
|
||||||
|
|
||||||
|
{ 4,
|
||||||
|
{ 'T','r','u','e' },
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _true_class) },
|
||||||
|
|
||||||
|
{ 5,
|
||||||
|
{ 'F','a','l','s','e' },
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _false_class) },
|
||||||
|
|
||||||
|
/* TOOD: what is a proper spec for Character and SmallInteger?
|
||||||
|
* If the fixed part is 0, its instance must be an object of 0 payload fields.
|
||||||
|
* Does this make sense? */
|
||||||
|
{ 9,
|
||||||
|
{ 'C','h','a','r','a','c','t','e','r' },
|
||||||
|
MOO_CLASS_SELFSPEC_FLAG_LIMITED,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _character) },
|
||||||
|
|
||||||
|
{ 12,
|
||||||
|
{ 'S','m','a','l','l','I','n','t','e','g','e','r' },
|
||||||
|
MOO_CLASS_SELFSPEC_FLAG_LIMITED,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _small_integer) },
|
||||||
|
|
||||||
|
{ 20,
|
||||||
|
{ 'L','a','r','g','e','P','o','s','i','t','i','v','e','I','n','t','e','g','e','r' },
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
MOO_CLASS_SPEC_FLAG_INDEXED | MOO_CLASS_SPEC_FLAG_IMMUTABLE,
|
||||||
|
MOO_OBJ_TYPE_LIWORD,
|
||||||
|
MOO_OFFSETOF(moo_t, _large_positive_integer) },
|
||||||
|
|
||||||
|
{ 20,
|
||||||
|
{ 'L','a','r','g','e','N','e','g','a','t','i','v','e','I','n','t','e','g','e','r' },
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
MOO_CLASS_SPEC_FLAG_INDEXED | MOO_CLASS_SPEC_FLAG_IMMUTABLE,
|
||||||
|
MOO_OBJ_TYPE_LIWORD,
|
||||||
|
MOO_OFFSETOF(moo_t, _large_negative_integer) },
|
||||||
|
|
||||||
|
{ 12,
|
||||||
|
{ 'S','m','a','l','l','P','o','i','n','t','e','r' },
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _small_pointer) },
|
||||||
|
|
||||||
|
{ 6,
|
||||||
|
{ 'S','y','s','t','e','m' },
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
MOO_OBJ_TYPE_OOP,
|
||||||
|
MOO_OFFSETOF(moo_t, _system) }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -141,6 +370,8 @@ static moo_oop_class_t alloc_kernel_class (moo_t* moo, int class_flags, moo_oow_
|
|||||||
|
|
||||||
static int ignite_1 (moo_t* moo)
|
static int ignite_1 (moo_t* moo)
|
||||||
{
|
{
|
||||||
|
moo_oow_t i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create fundamental class objects with some fields mis-initialized yet.
|
* Create fundamental class objects with some fields mis-initialized yet.
|
||||||
* Such fields include 'superclass', 'subclasses', 'name', etc.
|
* Such fields include 'superclass', 'subclasses', 'name', etc.
|
||||||
@ -154,85 +385,30 @@ static int ignite_1 (moo_t* moo)
|
|||||||
* The instance of Class can have indexed instance variables
|
* The instance of Class can have indexed instance variables
|
||||||
* which are actually class variables.
|
* which are actually class variables.
|
||||||
* -------------------------------------------------------------- */
|
* -------------------------------------------------------------- */
|
||||||
moo->_class = alloc_kernel_class (moo, MOO_CLASS_SELFSPEC_FLAG_LIMITED, 0, MOO_CLASS_SPEC_MAKE(MOO_CLASS_NAMED_INSTVARS, 1, MOO_OBJ_TYPE_OOP));
|
moo->_class = alloc_kernel_class (
|
||||||
|
moo, kernel_classes[KCI_CLASS].class_flags, 0,
|
||||||
|
MOO_CLASS_SPEC_MAKE (kernel_classes[KCI_CLASS].class_spec_named_instvars,
|
||||||
|
kernel_classes[KCI_CLASS].class_spec_flags,
|
||||||
|
kernel_classes[KCI_CLASS].class_spec_indexed_type));
|
||||||
if (!moo->_class) return -1;
|
if (!moo->_class) return -1;
|
||||||
|
|
||||||
MOO_ASSERT (moo, MOO_OBJ_GET_CLASS(moo->_class) == MOO_NULL);
|
MOO_ASSERT (moo, MOO_OBJ_GET_CLASS(moo->_class) == MOO_NULL);
|
||||||
MOO_OBJ_SET_CLASS (moo->_class, (moo_oop_t)moo->_class);
|
MOO_OBJ_SET_CLASS (moo->_class, (moo_oop_t)moo->_class);
|
||||||
|
|
||||||
/* --------------------------------------------------------------
|
for (i = 0; i < MOO_COUNTOF(kernel_classes); i++)
|
||||||
* Apex - proto-object with 1 class variable.
|
{
|
||||||
* UndefinedObject - class for the nil object.
|
moo_oop_class_t tmp;
|
||||||
* Object - top of all ordinary objects.
|
|
||||||
* String
|
|
||||||
* Symbol
|
|
||||||
* Array
|
|
||||||
* ByteArray
|
|
||||||
* SymbolSet
|
|
||||||
* Character
|
|
||||||
* SmallIntger
|
|
||||||
* -------------------------------------------------------------- */
|
|
||||||
moo->_apex = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(0, 0, MOO_OBJ_TYPE_OOP));
|
|
||||||
moo->_undefined_object = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(0, 0, MOO_OBJ_TYPE_OOP));
|
|
||||||
moo->_object = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(0, 0, MOO_OBJ_TYPE_OOP));
|
|
||||||
moo->_string = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(0, MOO_CLASS_SPEC_FLAG_INDEXED, MOO_OBJ_TYPE_CHAR));
|
|
||||||
|
|
||||||
moo->_symbol = alloc_kernel_class (moo,
|
if (i == KCI_CLASS) continue; /* skip Class as it's created above */
|
||||||
MOO_CLASS_SELFSPEC_FLAG_FINAL | MOO_CLASS_SELFSPEC_FLAG_LIMITED,
|
|
||||||
0, MOO_CLASS_SPEC_MAKE(0, MOO_CLASS_SPEC_FLAG_INDEXED | MOO_CLASS_SPEC_FLAG_IMMUTABLE, MOO_OBJ_TYPE_CHAR));
|
|
||||||
|
|
||||||
moo->_array = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(0, MOO_CLASS_SPEC_FLAG_INDEXED, MOO_OBJ_TYPE_OOP));
|
tmp = alloc_kernel_class (
|
||||||
moo->_byte_array = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(0, MOO_CLASS_SPEC_FLAG_INDEXED, MOO_OBJ_TYPE_BYTE));
|
moo, kernel_classes[i].class_flags, 0,
|
||||||
moo->_symbol_set = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(MOO_DIC_NAMED_INSTVARS, 0, MOO_OBJ_TYPE_OOP));
|
MOO_CLASS_SPEC_MAKE (kernel_classes[i].class_spec_named_instvars,
|
||||||
moo->_dictionary = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(MOO_DIC_NAMED_INSTVARS, 0, MOO_OBJ_TYPE_OOP));
|
kernel_classes[i].class_spec_flags,
|
||||||
moo->_namespace = alloc_kernel_class (moo, MOO_CLASS_SELFSPEC_FLAG_LIMITED, 0, MOO_CLASS_SPEC_MAKE(MOO_NSDIC_NAMED_INSTVARS, 0, MOO_OBJ_TYPE_OOP));
|
kernel_classes[i].class_spec_indexed_type));
|
||||||
moo->_pool_dictionary = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(MOO_DIC_NAMED_INSTVARS, 0, MOO_OBJ_TYPE_OOP));
|
if (!tmp) return -1;
|
||||||
moo->_method_dictionary = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(MOO_DIC_NAMED_INSTVARS, 0, MOO_OBJ_TYPE_OOP));
|
*(moo_oop_class_t*)((moo_uint8_t*)moo + kernel_classes[i].offset) = tmp;
|
||||||
moo->_method = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(MOO_METHOD_NAMED_INSTVARS, MOO_CLASS_SPEC_FLAG_INDEXED, MOO_OBJ_TYPE_OOP));
|
}
|
||||||
moo->_association = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(MOO_ASSOCIATION_NAMED_INSTVARS, 0, MOO_OBJ_TYPE_OOP));
|
|
||||||
|
|
||||||
moo->_method_context = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(MOO_CONTEXT_NAMED_INSTVARS, MOO_CLASS_SPEC_FLAG_INDEXED, MOO_OBJ_TYPE_OOP));
|
|
||||||
moo->_block_context = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(MOO_CONTEXT_NAMED_INSTVARS, MOO_CLASS_SPEC_FLAG_INDEXED, MOO_OBJ_TYPE_OOP));
|
|
||||||
|
|
||||||
moo->_process = alloc_kernel_class (moo,
|
|
||||||
MOO_CLASS_SELFSPEC_FLAG_FINAL | MOO_CLASS_SELFSPEC_FLAG_LIMITED,
|
|
||||||
0, MOO_CLASS_SPEC_MAKE(MOO_PROCESS_NAMED_INSTVARS, MOO_CLASS_SPEC_FLAG_INDEXED, MOO_OBJ_TYPE_OOP));
|
|
||||||
|
|
||||||
moo->_semaphore = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(MOO_SEMAPHORE_NAMED_INSTVARS, 0, MOO_OBJ_TYPE_OOP));
|
|
||||||
moo->_process_scheduler = alloc_kernel_class (moo,
|
|
||||||
MOO_CLASS_SELFSPEC_FLAG_FINAL | MOO_CLASS_SELFSPEC_FLAG_LIMITED,
|
|
||||||
0, MOO_CLASS_SPEC_MAKE(MOO_PROCESS_SCHEDULER_NAMED_INSTVARS, 0, MOO_OBJ_TYPE_OOP));
|
|
||||||
|
|
||||||
moo->_error_class = alloc_kernel_class (moo, MOO_CLASS_SELFSPEC_FLAG_LIMITED, 0, MOO_CLASS_SPEC_MAKE(0, 0, MOO_OBJ_TYPE_OOP));
|
|
||||||
moo->_true_class = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(0, 0, MOO_OBJ_TYPE_OOP));
|
|
||||||
moo->_false_class = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(0, 0, MOO_OBJ_TYPE_OOP));
|
|
||||||
/* TOOD: what is a proper spec for Character and SmallInteger?
|
|
||||||
* If the fixed part is 0, its instance must be an object of 0 payload fields.
|
|
||||||
* Does this make sense? */
|
|
||||||
moo->_character = alloc_kernel_class (moo, MOO_CLASS_SELFSPEC_FLAG_LIMITED, 0, MOO_CLASS_SPEC_MAKE(0, 0, MOO_OBJ_TYPE_OOP));
|
|
||||||
moo->_small_integer = alloc_kernel_class (moo, MOO_CLASS_SELFSPEC_FLAG_LIMITED, 0, MOO_CLASS_SPEC_MAKE(0, 0, MOO_OBJ_TYPE_OOP));
|
|
||||||
moo->_large_positive_integer = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(0, MOO_CLASS_SPEC_FLAG_INDEXED | MOO_CLASS_SPEC_FLAG_IMMUTABLE, MOO_OBJ_TYPE_LIWORD));
|
|
||||||
moo->_large_negative_integer = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(0, MOO_CLASS_SPEC_FLAG_INDEXED | MOO_CLASS_SPEC_FLAG_IMMUTABLE, MOO_OBJ_TYPE_LIWORD));
|
|
||||||
|
|
||||||
moo->_small_pointer = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(0, 0, MOO_OBJ_TYPE_OOP));
|
|
||||||
moo->_system = alloc_kernel_class (moo, 0, 0, MOO_CLASS_SPEC_MAKE(0, 0, MOO_OBJ_TYPE_OOP));
|
|
||||||
|
|
||||||
if (!moo->_apex || !moo->_undefined_object ||
|
|
||||||
!moo->_object || !moo->_string ||
|
|
||||||
|
|
||||||
!moo->_symbol || !moo->_array ||
|
|
||||||
!moo->_byte_array || !moo->_symbol_set || !moo->_dictionary ||
|
|
||||||
|
|
||||||
!moo->_namespace || !moo->_pool_dictionary ||
|
|
||||||
!moo->_method_dictionary || !moo->_method || !moo->_association ||
|
|
||||||
|
|
||||||
!moo->_method_context || !moo->_block_context ||
|
|
||||||
!moo->_process || !moo->_semaphore || !moo->_process_scheduler ||
|
|
||||||
|
|
||||||
!moo->_true_class || !moo->_false_class ||
|
|
||||||
!moo->_character || !moo->_small_integer ||
|
|
||||||
!moo->_large_positive_integer || !moo->_large_negative_integer ||
|
|
||||||
!moo->_small_pointer || !moo->_system) return -1;
|
|
||||||
|
|
||||||
MOO_OBJ_SET_CLASS (moo->_nil, (moo_oop_t)moo->_undefined_object);
|
MOO_OBJ_SET_CLASS (moo->_nil, (moo_oop_t)moo->_undefined_object);
|
||||||
|
|
||||||
|
@ -58,9 +58,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define MOO_APPEND_TO_OOP_LIST(moo, list, node_type, node, _link) do { \
|
#define MOO_APPEND_TO_OOP_LIST(moo, list, node_type, node, _link) do { \
|
||||||
(node)->_link.next = (node_type)(moo)->_nil; \
|
(node)->_link.next = (node_type)(moo)->_nil; \
|
||||||
(node)->_link.prev = (list)->last; \
|
(node)->_link.prev = (list)->last; \
|
||||||
@ -87,8 +84,8 @@
|
|||||||
/*
|
/*
|
||||||
#define MOO_CLEANUP_FROM_OOP_LIST(moo, list, node, _link) do { \
|
#define MOO_CLEANUP_FROM_OOP_LIST(moo, list, node, _link) do { \
|
||||||
MOO_DELETE_FROM_OOP_LIST (moo, list, node, _link); \
|
MOO_DELETE_FROM_OOP_LIST (moo, list, node, _link); \
|
||||||
(node)->link.prev = (node_type)(moo)->_nil; \
|
(node)->_link.prev = (node_type)(moo)->_nil; \
|
||||||
(node)->link.next = (node_type)(moo)->_nil; \
|
(node)->_link.next = (node_type)(moo)->_nil; \
|
||||||
} while(0);
|
} while(0);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -808,6 +808,16 @@ struct moo_semaphore_t
|
|||||||
moo_oop_t io_mask; /* SmallInteger */
|
moo_oop_t io_mask; /* SmallInteger */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define MOO_SEMAPHORE_GROUP_NAMED_INSTVARS 2
|
||||||
|
typedef struct moo_semaphore_group_t moo_semaphore_group_t;
|
||||||
|
typedef struct moo_semaphore_group_t* moo_oop_semaphore_group_t;
|
||||||
|
struct moo_semaphore_group_t
|
||||||
|
{
|
||||||
|
MOO_OBJ_HEADER;
|
||||||
|
moo_oop_t size; /* SmallInteger */
|
||||||
|
moo_oop_oop_t semarr; /* Array of Semaphores */
|
||||||
|
};
|
||||||
|
|
||||||
#define MOO_PROCESS_SCHEDULER_NAMED_INSTVARS 9
|
#define MOO_PROCESS_SCHEDULER_NAMED_INSTVARS 9
|
||||||
typedef struct moo_process_scheduler_t moo_process_scheduler_t;
|
typedef struct moo_process_scheduler_t moo_process_scheduler_t;
|
||||||
typedef struct moo_process_scheduler_t* moo_oop_process_scheduler_t;
|
typedef struct moo_process_scheduler_t* moo_oop_process_scheduler_t;
|
||||||
@ -1123,6 +1133,7 @@ struct moo_t
|
|||||||
moo_oop_class_t _block_context; /* BlockContext */
|
moo_oop_class_t _block_context; /* BlockContext */
|
||||||
moo_oop_class_t _process; /* Process */
|
moo_oop_class_t _process; /* Process */
|
||||||
moo_oop_class_t _semaphore; /* Semaphore */
|
moo_oop_class_t _semaphore; /* Semaphore */
|
||||||
|
moo_oop_class_t _semaphore_group; /* SemaphoreGroup */
|
||||||
moo_oop_class_t _process_scheduler; /* ProcessScheduler */
|
moo_oop_class_t _process_scheduler; /* ProcessScheduler */
|
||||||
|
|
||||||
moo_oop_class_t _error_class; /* Error */
|
moo_oop_class_t _error_class; /* Error */
|
||||||
|
Loading…
Reference in New Issue
Block a user