did some preparatory work to add Process

This commit is contained in:
hyunghwan.chung 2015-10-14 14:01:33 +00:00
parent 6916198253
commit 5a82cdc417
9 changed files with 98 additions and 5 deletions

View File

@ -258,6 +258,11 @@
#dcl owner preamble preamble_data_1 preamble_data_2 ntmprs nargs code source.
}
#class(#pointer) Process(Object)
{
#dcl state.
}
#class FFI(Object)
{

View File

@ -45,6 +45,7 @@ libstix_la_SOURCES = \
obj.c \
sym.c \
dic.c \
proc.c \
ignite.c \
utf8.c \
comp.c \

View File

@ -126,8 +126,8 @@ libstix_la_DEPENDENCIES = $(am__DEPENDENCIES_2)
am_libstix_la_OBJECTS = libstix_la-stix-rbt.lo libstix_la-stix-utl.lo \
libstix_la-stix.lo libstix_la-heap.lo libstix_la-gc.lo \
libstix_la-obj.lo libstix_la-sym.lo libstix_la-dic.lo \
libstix_la-ignite.lo libstix_la-utf8.lo libstix_la-comp.lo \
libstix_la-exec.lo libstix_la-debug.lo
libstix_la-proc.lo libstix_la-ignite.lo libstix_la-utf8.lo \
libstix_la-comp.lo libstix_la-exec.lo libstix_la-debug.lo
libstix_la_OBJECTS = $(am_libstix_la_OBJECTS)
libstix_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
@ -380,6 +380,7 @@ libstix_la_SOURCES = \
obj.c \
sym.c \
dic.c \
proc.c \
ignite.c \
utf8.c \
comp.c \
@ -595,6 +596,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-heap.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-ignite.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-obj.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-proc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-stix-rbt.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-stix-utl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-stix.Plo@am__quote@
@ -687,6 +689,13 @@ libstix_la-dic.lo: dic.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstix_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libstix_la-dic.lo `test -f 'dic.c' || echo '$(srcdir)/'`dic.c
libstix_la-proc.lo: proc.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstix_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libstix_la-proc.lo -MD -MP -MF $(DEPDIR)/libstix_la-proc.Tpo -c -o libstix_la-proc.lo `test -f 'proc.c' || echo '$(srcdir)/'`proc.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libstix_la-proc.Tpo $(DEPDIR)/libstix_la-proc.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='proc.c' object='libstix_la-proc.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstix_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libstix_la-proc.lo `test -f 'proc.c' || echo '$(srcdir)/'`proc.c
libstix_la-ignite.lo: ignite.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstix_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libstix_la-ignite.lo -MD -MP -MF $(DEPDIR)/libstix_la-ignite.Tpo -c -o libstix_la-ignite.lo `test -f 'ignite.c' || echo '$(srcdir)/'`ignite.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libstix_la-ignite.Tpo $(DEPDIR)/libstix_la-ignite.Plo

View File

@ -284,6 +284,7 @@ void stix_gc (stix_t* stix)
stix->_association = stix_moveoop (stix, stix->_association);
stix->_method_context = stix_moveoop (stix, stix->_method_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);

View File

@ -134,6 +134,7 @@ static int ignite_1 (stix_t* stix)
stix->_method_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_CONTEXT_NAMED_INSTVARS, 1, STIX_OBJ_TYPE_OOP));
stix->_process = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(STIX_PROCESS_NAMED_INSTVARS, 1, 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?
@ -151,7 +152,7 @@ static int ignite_1 (stix_t* stix)
!stix->_namespace || !stix->_pool_dictionary ||
!stix->_method_dictionary || !stix->_method || !stix->_association ||
!stix->_method_context || !stix->_block_context ||
!stix->_method_context || !stix->_block_context || !stix->_process ||
!stix->_true_class || !stix->_false_class ||
!stix->_character || !stix->_small_integer) return -1;
@ -223,6 +224,7 @@ 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' } },

41
stix/lib/proc.c Normal file
View File

@ -0,0 +1,41 @@
/*
* $Id$
*
Copyright (c) 2014-2015 Chung, Hyung-Hwan. All rights reserved.
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"
stix_oop_process_t stix_makeproc (stix_t* stix)
{
stix_oop_process_t proc;
proc = (stix_oop_process_t)stix_instantiate (stix, stix->_process, STIX_NULL, stix->option.dfl_procstk_size);
if (!proc) return STIX_NULL;
proc->state = STIX_OOP_FROM_SMINT(0);
STIX_ASSERT (STIX_OBJ_GET_SIZE(proc) == STIX_PROCESS_NAMED_INSTVARS + stix->option.dfl_procstk_size);
return proc;
}

View File

@ -986,6 +986,13 @@ stix_oop_set_t stix_makedic (
stix_oow_t size
);
/* ========================================================================= */
/* proc.c */
/* ========================================================================= */
stix_oop_process_t stix_makeproc (
stix_t* stix
);
/* ========================================================================= */
/* utf8.c */
/* ========================================================================= */

View File

@ -135,6 +135,10 @@ int stix_setoption (stix_t* stix, stix_option_t id, const void* value)
case STIX_SYSDIC_SIZE:
stix->option.dfl_sysdic_size = *(stix_oow_t*)value;
return 0;
case STIX_PROCSTK_SIZE:
stix->option.dfl_procstk_size = *(stix_oow_t*)value;
return 0;
}
stix->errnum = STIX_EINVAL;
@ -151,9 +155,15 @@ int stix_getoption (stix_t* stix, stix_option_t id, void* value)
case STIX_SYMTAB_SIZE:
*(stix_oow_t*)value = stix->option.dfl_symtab_size;
return 0;
case STIX_SYSDIC_SIZE:
*(stix_oow_t*)value = stix->option.dfl_sysdic_size;
return 0;
case STIX_PROCSTK_SIZE:
*(stix_oow_t*)value = stix->option.dfl_procstk_size;
return 0;
};
stix->errnum = STIX_EINVAL;

View File

@ -61,8 +61,9 @@ typedef enum stix_errnum_t stix_errnum_t;
enum stix_option_t
{
STIX_TRAIT,
STIX_SYMTAB_SIZE, /* default system table size */
STIX_SYSDIC_SIZE /* default system dictionary size */
STIX_SYMTAB_SIZE, /* default system table size */
STIX_SYSDIC_SIZE, /* default system dictionary size */
STIX_PROCSTK_SIZE /* default process stack size */
};
typedef enum stix_option_t stix_option_t;
@ -466,6 +467,20 @@ struct stix_context_t
stix_oop_t slot[1]; /* stack */
};
#define STIX_PROCESS_NAMED_INSTVARS 1
typedef struct stix_process_t stix_process_t;
typedef struct stix_process_t* stix_oop_process_t;
struct stix_process_t
{
STIX_OBJ_HEADER;
stix_oop_t state;
/* == variable indexed part == */
stix_oop_t slot[1]; /* process stack */
};
/**
* The STIX_CLASSOF() macro return the class of an object including a numeric
* object encoded into a pointer.
@ -588,6 +603,7 @@ struct stix_t
int trait;
stix_oow_t dfl_symtab_size;
stix_oow_t dfl_sysdic_size;
stix_oow_t dfl_procstk_size;
} option;
stix_vmprim_t vmprim;
@ -627,6 +643,7 @@ struct stix_t
stix_oop_t _method_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 */