2015-05-03 17:10:30 +00:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
2016-02-12 16:23:26 +00:00
|
|
|
Copyright (c) 2014-2016 Chung, Hyung-Hwan. All rights reserved.
|
2015-05-03 17:10:30 +00:00
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
|
|
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stix-prv.h"
|
|
|
|
|
2015-05-07 15:58:04 +00:00
|
|
|
/*
|
|
|
|
* Stix .....................
|
|
|
|
* ^ ^ ^ : .......
|
|
|
|
* | | | v v :
|
|
|
|
* | | +------------------- Class .....
|
|
|
|
* | | ^ ^
|
|
|
|
* | +-------- NilObject ......: :
|
|
|
|
* | ^........ nil :
|
|
|
|
* Object ...........................:
|
|
|
|
* ^
|
|
|
|
* |
|
|
|
|
*
|
|
|
|
* The class hierarchy is roughly as follows:
|
|
|
|
*
|
|
|
|
* Stix
|
|
|
|
* Class
|
|
|
|
* NilObject
|
|
|
|
* Object
|
|
|
|
* Collection
|
|
|
|
* IndexedCollection
|
|
|
|
* FixedSizedCollection
|
|
|
|
* Array
|
|
|
|
* ByteArray
|
|
|
|
* String
|
|
|
|
* Symbol
|
|
|
|
* Set
|
|
|
|
* Dictionary
|
|
|
|
* SystemDictionary
|
|
|
|
* SymbolSet
|
|
|
|
* Magnitude
|
|
|
|
* Association
|
|
|
|
* Character
|
|
|
|
* Number
|
|
|
|
* Integer
|
|
|
|
* SmallInteger
|
|
|
|
* LargeInteger
|
2015-10-29 15:24:46 +00:00
|
|
|
* LargePositiveInteger
|
|
|
|
* LargeNegativeInteger
|
2015-05-07 15:58:04 +00:00
|
|
|
*
|
|
|
|
* Stix has no instance variables.
|
|
|
|
* Stix has 1 class variable: Sysdic
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static stix_oop_t alloc_kernel_class (stix_t* stix, stix_oow_t indexed, stix_oow_t spec)
|
|
|
|
{
|
|
|
|
stix_oop_class_t c;
|
|
|
|
|
|
|
|
c = (stix_oop_class_t)stix_allocoopobj (stix, STIX_CLASS_NAMED_INSTVARS + indexed);
|
|
|
|
if (!c) return STIX_NULL;
|
|
|
|
|
|
|
|
STIX_OBJ_SET_FLAGS_KERNEL (c, 1);
|
|
|
|
STIX_OBJ_SET_CLASS (c, stix->_class);
|
2015-11-12 06:57:35 +00:00
|
|
|
c->spec = STIX_SMOOI_TO_OOP(spec);
|
|
|
|
c->selfspec = STIX_SMOOI_TO_OOP(STIX_CLASS_SELFSPEC_MAKE(indexed, 0));
|
2015-05-07 15:58:04 +00:00
|
|
|
|
|
|
|
return (stix_oop_t)c;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ignite_1 (stix_t* stix)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Create fundamental class objects with some fields mis-initialized yet.
|
|
|
|
* Such fields include 'superclass', 'subclasses', 'name', etc.
|
|
|
|
*/
|
|
|
|
STIX_ASSERT (stix->_nil != STIX_NULL);
|
|
|
|
STIX_ASSERT (STIX_OBJ_GET_CLASS(stix->_nil) == STIX_NULL);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------
|
|
|
|
* Class
|
|
|
|
* The instance of Class can have indexed instance variables
|
|
|
|
* which are actually class variables.
|
|
|
|
* -------------------------------------------------------------- */
|
2015-05-26 16:31:47 +00:00
|
|
|
stix->_class = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_CLASS_NAMED_INSTVARS, 1, STIX_OBJ_TYPE_OOP));
|
2015-05-07 15:58:04 +00:00
|
|
|
if (!stix->_class) return -1;
|
|
|
|
|
|
|
|
STIX_ASSERT (STIX_OBJ_GET_CLASS(stix->_class) == STIX_NULL);
|
|
|
|
STIX_OBJ_SET_CLASS (stix->_class, stix->_class);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------
|
2015-07-14 13:35:18 +00:00
|
|
|
* Apex - proto-object with 1 class variable.
|
|
|
|
* UndefinedObject - class for the nil object.
|
|
|
|
* Object - top of all ordinary objects.
|
2015-05-26 16:31:47 +00:00
|
|
|
* String
|
2015-05-07 15:58:04 +00:00
|
|
|
* Symbol
|
|
|
|
* Array
|
2015-05-31 16:44:56 +00:00
|
|
|
* ByteArray
|
2015-05-07 15:58:04 +00:00
|
|
|
* SymbolSet
|
|
|
|
* Character
|
|
|
|
* SmallIntger
|
|
|
|
* -------------------------------------------------------------- */
|
2015-07-14 13:35:18 +00:00
|
|
|
stix->_apex = alloc_kernel_class (stix, 1, STIX_CLASS_SPEC_MAKE(0, 0, STIX_OBJ_TYPE_OOP));
|
|
|
|
stix->_undefined_object = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 0, STIX_OBJ_TYPE_OOP));
|
2015-05-07 15:58:04 +00:00
|
|
|
stix->_object = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 0, STIX_OBJ_TYPE_OOP));
|
2015-05-26 16:31:47 +00:00
|
|
|
stix->_string = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 1, STIX_OBJ_TYPE_CHAR));
|
2015-06-21 16:22:50 +00:00
|
|
|
|
2015-05-07 15:58:04 +00:00
|
|
|
stix->_symbol = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 1, STIX_OBJ_TYPE_CHAR));
|
2015-06-21 16:22:50 +00:00
|
|
|
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));
|
2015-05-07 15:58:04 +00:00
|
|
|
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));
|
2015-06-21 16:22:50 +00:00
|
|
|
|
2015-07-10 14:06:07 +00:00
|
|
|
stix->_namespace = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_SET_NAMED_INSTVARS, 0, STIX_OBJ_TYPE_OOP));
|
2015-07-14 13:35:18 +00:00
|
|
|
stix->_pool_dictionary = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_SET_NAMED_INSTVARS, 0, STIX_OBJ_TYPE_OOP));
|
2015-05-28 16:51:37 +00:00
|
|
|
stix->_method_dictionary = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_SET_NAMED_INSTVARS, 0, STIX_OBJ_TYPE_OOP));
|
2015-05-31 16:44:56 +00:00
|
|
|
stix->_method = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_METHOD_NAMED_INSTVARS, 1, STIX_OBJ_TYPE_OOP));
|
2015-05-07 15:58:04 +00:00
|
|
|
stix->_association = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_ASSOCIATION_NAMED_INSTVARS, 0, STIX_OBJ_TYPE_OOP));
|
2015-06-21 16:22:50 +00:00
|
|
|
|
2015-07-14 13:35:18 +00:00
|
|
|
stix->_method_context = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_CONTEXT_NAMED_INSTVARS, 1, STIX_OBJ_TYPE_OOP));
|
2015-07-10 14:06:07 +00:00
|
|
|
stix->_block_context = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_CONTEXT_NAMED_INSTVARS, 1, STIX_OBJ_TYPE_OOP));
|
2015-10-14 14:01:33 +00:00
|
|
|
stix->_process = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_PROCESS_NAMED_INSTVARS, 1, STIX_OBJ_TYPE_OOP));
|
2016-02-18 17:49:56 +00:00
|
|
|
stix->_semaphore = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_SEMAPHORE_NAMED_INSTVARS, 0, STIX_OBJ_TYPE_OOP));
|
2015-10-15 14:40:08 +00:00
|
|
|
stix->_process_scheduler = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_PROCESS_SCHEDULER_NAMED_INSTVARS, 0, STIX_OBJ_TYPE_OOP));
|
2015-05-11 16:08:09 +00:00
|
|
|
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));
|
2015-05-07 15:58:04 +00:00
|
|
|
/* 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? */
|
|
|
|
stix->_character = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 0, STIX_OBJ_TYPE_OOP));
|
|
|
|
stix->_small_integer = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 0, STIX_OBJ_TYPE_OOP));
|
2015-11-17 14:13:59 +00:00
|
|
|
stix->_large_positive_integer = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 1, STIX_OBJ_TYPE_LIWORD));
|
|
|
|
stix->_large_negative_integer = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 1, STIX_OBJ_TYPE_LIWORD));
|
2015-05-07 15:58:04 +00:00
|
|
|
|
2015-07-14 13:35:18 +00:00
|
|
|
if (!stix->_apex || !stix->_undefined_object ||
|
2015-06-21 16:22:50 +00:00
|
|
|
!stix->_object || !stix->_string ||
|
|
|
|
|
|
|
|
!stix->_symbol || !stix->_array ||
|
2015-07-10 14:06:07 +00:00
|
|
|
!stix->_byte_array || !stix->_symbol_set || !stix->_system_dictionary ||
|
2015-06-21 16:22:50 +00:00
|
|
|
|
2015-07-14 13:35:18 +00:00
|
|
|
!stix->_namespace || !stix->_pool_dictionary ||
|
|
|
|
!stix->_method_dictionary || !stix->_method || !stix->_association ||
|
|
|
|
|
2015-10-15 14:40:08 +00:00
|
|
|
!stix->_method_context || !stix->_block_context ||
|
2016-02-18 17:49:56 +00:00
|
|
|
!stix->_process || !stix->_semaphore || !stix->_process_scheduler ||
|
2015-10-15 14:40:08 +00:00
|
|
|
|
2015-07-14 13:35:18 +00:00
|
|
|
!stix->_true_class || !stix->_false_class ||
|
2015-10-29 15:24:46 +00:00
|
|
|
!stix->_character || !stix->_small_integer ||
|
|
|
|
!stix->_large_positive_integer || !stix->_large_negative_integer) return -1;
|
2015-06-21 16:22:50 +00:00
|
|
|
|
2015-07-14 13:35:18 +00:00
|
|
|
STIX_OBJ_SET_CLASS (stix->_nil, stix->_undefined_object);
|
2015-05-07 15:58:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ignite_2 (stix_t* stix)
|
|
|
|
{
|
2015-05-28 16:51:37 +00:00
|
|
|
stix_oop_t tmp;
|
2015-05-07 15:58:04 +00:00
|
|
|
|
2015-05-11 16:08:09 +00:00
|
|
|
/* Create 'true' and 'false objects */
|
|
|
|
stix->_true = stix_instantiate (stix, stix->_true_class, STIX_NULL, 0);
|
|
|
|
stix->_false = stix_instantiate (stix, stix->_false_class, STIX_NULL, 0);
|
|
|
|
if (!stix->_true || !stix->_false) return -1;
|
|
|
|
|
2015-05-07 15:58:04 +00:00
|
|
|
/* Create the symbol table */
|
2015-05-28 16:51:37 +00:00
|
|
|
tmp = stix_instantiate (stix, stix->_symbol_set, STIX_NULL, 0);
|
|
|
|
if (!tmp) return -1;
|
|
|
|
stix->symtab = (stix_oop_set_t)tmp;
|
2015-05-07 15:58:04 +00:00
|
|
|
|
2015-11-12 06:57:35 +00:00
|
|
|
stix->symtab->tally = STIX_SMOOI_TO_OOP(0);
|
2015-05-08 14:29:35 +00:00
|
|
|
/* It's important to assign the result of stix_instantiate() to a temporary
|
|
|
|
* variable first and then assign it to stix->symtab->bucket.
|
|
|
|
* The pointer 'stix->symtab; can change in stix_instantiate() and the
|
|
|
|
* target address of assignment may get set before stix_instantiate()
|
|
|
|
* is called. */
|
2015-05-28 16:51:37 +00:00
|
|
|
tmp = stix_instantiate (stix, stix->_array, STIX_NULL, stix->option.dfl_symtab_size);
|
|
|
|
if (!tmp) return -1;
|
|
|
|
stix->symtab->bucket = (stix_oop_oop_t)tmp;
|
2015-05-07 15:58:04 +00:00
|
|
|
|
|
|
|
/* Create the system dictionary */
|
2015-06-04 18:34:37 +00:00
|
|
|
tmp = (stix_oop_t)stix_makedic (stix, stix->_system_dictionary, stix->option.dfl_sysdic_size);
|
2015-05-28 16:51:37 +00:00
|
|
|
if (!tmp) return -1;
|
|
|
|
stix->sysdic = (stix_oop_set_t)tmp;
|
2015-05-07 15:58:04 +00:00
|
|
|
|
2016-02-12 16:23:26 +00:00
|
|
|
/* Create a nil process used to simplify nil check in GC.
|
|
|
|
* only accessible by VM. not exported via the global dictionary. */
|
|
|
|
tmp = (stix_oop_t)stix_instantiate (stix, stix->_process, STIX_NULL, 0);
|
|
|
|
if (!tmp) return -1;
|
|
|
|
stix->nil_process = (stix_oop_process_t)tmp;
|
|
|
|
stix->nil_process->sp = STIX_SMOOI_TO_OOP(-1);
|
|
|
|
|
2015-10-19 06:16:43 +00:00
|
|
|
/* Create a process scheduler */
|
2015-10-15 14:40:08 +00:00
|
|
|
tmp = (stix_oop_t)stix_instantiate (stix, stix->_process_scheduler, STIX_NULL, 0);
|
|
|
|
if (!tmp) return -1;
|
2015-10-22 02:47:25 +00:00
|
|
|
stix->processor = (stix_oop_process_scheduler_t)tmp;
|
2015-11-12 06:57:35 +00:00
|
|
|
stix->processor->tally = STIX_SMOOI_TO_OOP(0);
|
2016-02-12 16:23:26 +00:00
|
|
|
stix->processor->active = stix->nil_process;
|
2015-10-15 14:40:08 +00:00
|
|
|
|
2016-02-19 15:52:56 +00:00
|
|
|
/* Initialize a runnbale process list */
|
|
|
|
tmp = (stix_oop_t)stix_instantiate (stix, stix->_process, STIX_NULL, 0);
|
|
|
|
if (!tmp) return -1;
|
|
|
|
stix->processor->runnable = (stix_oop_process_t)tmp;
|
|
|
|
stix->processor->runnable->sp = STIX_SMOOI_TO_OOP(-1);
|
|
|
|
LIST_INIT (p_, stix->processor->runnable);
|
|
|
|
|
2015-05-07 15:58:04 +00:00
|
|
|
/* Export the system dictionary via the first class variable of the Stix class */
|
2015-07-14 13:35:18 +00:00
|
|
|
((stix_oop_class_t)stix->_apex)->slot[0] = (stix_oop_t)stix->sysdic;
|
2015-05-07 15:58:04 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-05-11 16:08:09 +00:00
|
|
|
static int ignite_3 (stix_t* stix)
|
|
|
|
{
|
|
|
|
/* Register kernel classes manually created so far to the system dictionary */
|
2015-05-07 15:58:04 +00:00
|
|
|
|
2015-05-11 16:08:09 +00:00
|
|
|
static struct symbol_name_t
|
|
|
|
{
|
|
|
|
stix_oow_t len;
|
2015-10-29 15:24:46 +00:00
|
|
|
stix_ooch_t str[20];
|
2015-05-11 16:08:09 +00:00
|
|
|
} symnames[] = {
|
2015-07-14 13:35:18 +00:00
|
|
|
{ 4, { 'A','p','e','x' } },
|
|
|
|
{ 15, { 'U','n','d','e','f','i','n','e','d','O','b','j','e','c','t' } },
|
2015-05-11 16:08:09 +00:00
|
|
|
{ 5, { 'C','l','a','s','s' } },
|
2015-05-26 16:31:47 +00:00
|
|
|
{ 6, { 'O','b','j','e','c','t' } },
|
|
|
|
{ 6, { 'S','t','r','i','n','g' } },
|
2015-06-04 18:34:37 +00:00
|
|
|
|
2015-05-11 16:08:09 +00:00
|
|
|
{ 6, { 'S','y','m','b','o','l' } },
|
|
|
|
{ 5, { 'A','r','r','a','y' } },
|
2015-05-31 18:43:37 +00:00
|
|
|
{ 9, { 'B','y','t','e','A','r','r','a','y' } },
|
2015-05-11 16:08:09 +00:00
|
|
|
{ 9, { 'S','y','m','b','o','l','S','e','t' } },
|
|
|
|
{ 16, { 'S','y','s','t','e','m','D','i','c','t','i','o','n','a','r','y' } },
|
2015-06-04 18:34:37 +00:00
|
|
|
|
2015-07-10 14:06:07 +00:00
|
|
|
{ 9, { 'N','a','m','e','s','p','a','c','e' } },
|
2015-07-14 13:35:18 +00:00
|
|
|
{ 14, { 'P','o','o','l','D','i','c','t','i','o','n','a','r','y' } },
|
2015-05-28 16:51:37 +00:00
|
|
|
{ 16, { 'M','e','t','h','o','d','D','i','c','t','i','o','n','a','r','y' } },
|
2015-05-31 18:43:37 +00:00
|
|
|
{ 14, { 'C','o','m','p','i','l','e','d','M','e','t','h','o','d' } },
|
2015-05-11 16:08:09 +00:00
|
|
|
{ 11, { 'A','s','s','o','c','i','a','t','i','o','n' } },
|
2015-06-04 18:34:37 +00:00
|
|
|
|
2015-07-14 13:35:18 +00:00
|
|
|
{ 13, { 'M','e','t','h','o','d','C','o','n','t','e','x','t' } },
|
2015-07-10 14:06:07 +00:00
|
|
|
{ 12, { 'B','l','o','c','k','C','o','n','t','e','x','t' } },
|
2015-10-14 14:01:33 +00:00
|
|
|
{ 7, { 'P','r','o','c','e','s','s' } },
|
2016-02-18 17:49:56 +00:00
|
|
|
{ 9, { 'S','e','m','a','p','h','o','r','e' } },
|
2015-10-15 14:40:08 +00:00
|
|
|
{ 16, { 'P','r','o','c','e','s','s','S','c','h','e','d','u','l','e','r' } },
|
2015-05-11 16:08:09 +00:00
|
|
|
{ 4, { 'T','r','u','e' } },
|
|
|
|
{ 5, { 'F','a','l','s','e' } },
|
|
|
|
{ 9, { 'C','h','a','r','a','c','t','e','r' } },
|
2015-10-28 14:58:58 +00:00
|
|
|
{ 12, { 'S','m','a','l','l','I','n','t','e','g','e','r' } },
|
2015-10-29 15:24:46 +00:00
|
|
|
{ 20, { 'L','a','r','g','e','P','o','s','i','t','i','v','e','I','n','t','e','g','e','r' } },
|
|
|
|
{ 20, { 'L','a','r','g','e','N','e','g','a','t','i','v','e','I','n','t','e','g','e','r' } }
|
2015-05-11 16:08:09 +00:00
|
|
|
};
|
|
|
|
|
2015-10-28 14:58:58 +00:00
|
|
|
static stix_ooch_t str_stix[] = { 'S','t','i','x' };
|
|
|
|
static stix_ooch_t str_processor[] = { 'P', 'r', 'o', 'c', 'e', 's', 's', 'o', 'r' };
|
2015-07-12 17:14:21 +00:00
|
|
|
|
2015-05-11 16:08:09 +00:00
|
|
|
stix_oow_t i;
|
|
|
|
stix_oop_t sym;
|
|
|
|
stix_oop_t* stix_ptr;
|
|
|
|
|
2015-07-14 13:35:18 +00:00
|
|
|
stix_ptr = &stix->_apex;
|
|
|
|
/* [NOTE]
|
|
|
|
* The loop here repies on the proper order of fields in stix_t.
|
|
|
|
* Be sure to keep in sync the order of items in symnames and
|
|
|
|
* the releated fields of stix_t */
|
2015-05-11 16:08:09 +00:00
|
|
|
for (i = 0; i < STIX_COUNTOF(symnames); i++)
|
|
|
|
{
|
|
|
|
sym = stix_makesymbol (stix, symnames[i].str, symnames[i].len);
|
|
|
|
if (!sym) return -1;
|
2015-05-07 15:58:04 +00:00
|
|
|
|
2015-07-12 17:14:21 +00:00
|
|
|
if (!stix_putatsysdic(stix, sym, *stix_ptr)) return -1;
|
2015-05-11 16:08:09 +00:00
|
|
|
stix_ptr++;
|
|
|
|
}
|
2015-05-07 15:58:04 +00:00
|
|
|
|
2015-10-15 14:40:08 +00:00
|
|
|
/* Make the system dictionary available as the global name 'Stix' */
|
2015-07-14 13:35:18 +00:00
|
|
|
sym = stix_makesymbol (stix, str_stix, 4);
|
2015-07-12 17:14:21 +00:00
|
|
|
if (!sym) return -1;
|
|
|
|
if (!stix_putatsysdic(stix, sym, (stix_oop_t)stix->sysdic)) return -1;
|
|
|
|
|
2015-10-22 02:47:25 +00:00
|
|
|
/* Make the process scheduler avaialble as the global name 'Processor' */
|
|
|
|
sym = stix_makesymbol (stix, str_processor, 9);
|
2015-10-15 14:40:08 +00:00
|
|
|
if (!sym) return -1;
|
2015-10-22 02:47:25 +00:00
|
|
|
if (!stix_putatsysdic(stix, sym, (stix_oop_t)stix->processor)) return -1;
|
2015-10-15 14:40:08 +00:00
|
|
|
|
2015-05-11 16:08:09 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2015-05-07 15:58:04 +00:00
|
|
|
|
2015-05-03 17:10:30 +00:00
|
|
|
int stix_ignite (stix_t* stix)
|
|
|
|
{
|
|
|
|
STIX_ASSERT (stix->_nil == STIX_NULL);
|
|
|
|
|
|
|
|
stix->_nil = stix_allocbytes (stix, STIX_SIZEOF(stix_obj_t));
|
|
|
|
if (!stix->_nil) return -1;
|
|
|
|
|
2015-12-27 18:02:59 +00:00
|
|
|
stix->_nil->_flags = STIX_OBJ_MAKE_FLAGS (STIX_OBJ_TYPE_OOP, STIX_SIZEOF(stix_oop_t), 0, 1, 0, 0, 0);
|
2015-05-07 15:58:04 +00:00
|
|
|
stix->_nil->_size = 0;
|
2015-05-03 17:10:30 +00:00
|
|
|
|
2015-05-11 16:08:09 +00:00
|
|
|
if (ignite_1(stix) <= -1 || ignite_2(stix) <= -1 || ignite_3(stix)) return -1;
|
2015-05-03 17:10:30 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|