started adding byte-code decoder
This commit is contained in:
		| @ -250,7 +250,8 @@ | |||||||
|  |  | ||||||
| #class(#pointer) CompiledMethod(Object) | #class(#pointer) CompiledMethod(Object) | ||||||
| { | { | ||||||
| 	#dcl owner name preamble preamble_data_1 preamble_data_2 ntmprs nargs code source. | 	## #dcl owner name preamble preamble_data_1 preamble_data_2 ntmprs nargs code source. | ||||||
|  | 	#dcl owner name preamble preamble_data_1 preamble_data_2 ntmprs nargs source. | ||||||
|  |  | ||||||
| 	#method preamble | 	#method preamble | ||||||
| 	{ | 	{ | ||||||
|  | |||||||
| @ -40,6 +40,7 @@ libstix_la_SOURCES = \ | |||||||
| 	bigint.c \ | 	bigint.c \ | ||||||
| 	comp.c \ | 	comp.c \ | ||||||
| 	debug.c  \ | 	debug.c  \ | ||||||
|  | 	decode.c \ | ||||||
| 	dic.c \ | 	dic.c \ | ||||||
| 	exec.c \ | 	exec.c \ | ||||||
| 	gc.c \ | 	gc.c \ | ||||||
| @ -82,12 +83,18 @@ LIBADD_MOD_COMMON = -lstix | |||||||
|  |  | ||||||
| pkgmodexecdir = $(libdir) | pkgmodexecdir = $(libdir) | ||||||
|  |  | ||||||
| pkgmodexec_LTLIBRARIES = libstix-snd.la | pkgmodexec_LTLIBRARIES = libstix-snd.la libstix-con.la | ||||||
|  |  | ||||||
| libstix_snd_la_SOURCES = mod-snd.c mod-snd.h | libstix_snd_la_SOURCES = mod-snd.c mod-snd.h | ||||||
| libstix_snd_la_CPPFLAGS = $(CPPFLAGS_MOD_COMMON) | libstix_snd_la_CPPFLAGS = $(CPPFLAGS_MOD_COMMON) | ||||||
| libstix_snd_la_LDFLAGS = $(LDFLAGS_MOD_COMMON) | libstix_snd_la_LDFLAGS = $(LDFLAGS_MOD_COMMON) | ||||||
| libstix_snd_la_LIBADD = $(LIBADD_MOD_COMMON) | libstix_snd_la_LIBADD = $(LIBADD_MOD_COMMON) | ||||||
|  |  | ||||||
|  | libstix_con_la_SOURCES = mod-con.c mod-con.h | ||||||
|  | libstix_con_la_CPPFLAGS = $(CPPFLAGS_MOD_COMMON) | ||||||
|  | libstix_con_la_LDFLAGS = $(LDFLAGS_MOD_COMMON) | ||||||
|  | libstix_con_la_LIBADD = $(LIBADD_MOD_COMMON) | ||||||
|  |  | ||||||
| endif | endif | ||||||
|  |  | ||||||
|  |  | ||||||
|  | |||||||
| @ -133,16 +133,28 @@ am__installdirs = "$(DESTDIR)$(pkglibdir)" \ | |||||||
| 	"$(DESTDIR)$(pkgincludedir)" | 	"$(DESTDIR)$(pkgincludedir)" | ||||||
| LTLIBRARIES = $(pkglib_LTLIBRARIES) $(pkgmodexec_LTLIBRARIES) | LTLIBRARIES = $(pkglib_LTLIBRARIES) $(pkgmodexec_LTLIBRARIES) | ||||||
| am__DEPENDENCIES_1 = | am__DEPENDENCIES_1 = | ||||||
|  | @ENABLE_STATIC_MODULE_FALSE@libstix_con_la_DEPENDENCIES =  \ | ||||||
|  | @ENABLE_STATIC_MODULE_FALSE@	$(am__DEPENDENCIES_1) | ||||||
|  | am__libstix_con_la_SOURCES_DIST = mod-con.c mod-con.h | ||||||
|  | @ENABLE_STATIC_MODULE_FALSE@am_libstix_con_la_OBJECTS =  \ | ||||||
|  | @ENABLE_STATIC_MODULE_FALSE@	libstix_con_la-mod-con.lo | ||||||
|  | libstix_con_la_OBJECTS = $(am_libstix_con_la_OBJECTS) | ||||||
|  | AM_V_lt = $(am__v_lt_@AM_V@) | ||||||
|  | am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) | ||||||
|  | am__v_lt_0 = --silent | ||||||
|  | am__v_lt_1 =  | ||||||
|  | libstix_con_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ | ||||||
|  | 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ | ||||||
|  | 	$(AM_CFLAGS) $(CFLAGS) $(libstix_con_la_LDFLAGS) $(LDFLAGS) -o \ | ||||||
|  | 	$@ | ||||||
|  | @ENABLE_STATIC_MODULE_FALSE@am_libstix_con_la_rpath = -rpath \ | ||||||
|  | @ENABLE_STATIC_MODULE_FALSE@	$(pkgmodexecdir) | ||||||
| @ENABLE_STATIC_MODULE_FALSE@libstix_snd_la_DEPENDENCIES =  \ | @ENABLE_STATIC_MODULE_FALSE@libstix_snd_la_DEPENDENCIES =  \ | ||||||
| @ENABLE_STATIC_MODULE_FALSE@	$(am__DEPENDENCIES_1) | @ENABLE_STATIC_MODULE_FALSE@	$(am__DEPENDENCIES_1) | ||||||
| am__libstix_snd_la_SOURCES_DIST = mod-snd.c mod-snd.h | am__libstix_snd_la_SOURCES_DIST = mod-snd.c mod-snd.h | ||||||
| @ENABLE_STATIC_MODULE_FALSE@am_libstix_snd_la_OBJECTS =  \ | @ENABLE_STATIC_MODULE_FALSE@am_libstix_snd_la_OBJECTS =  \ | ||||||
| @ENABLE_STATIC_MODULE_FALSE@	libstix_snd_la-mod-snd.lo | @ENABLE_STATIC_MODULE_FALSE@	libstix_snd_la-mod-snd.lo | ||||||
| libstix_snd_la_OBJECTS = $(am_libstix_snd_la_OBJECTS) | libstix_snd_la_OBJECTS = $(am_libstix_snd_la_OBJECTS) | ||||||
| AM_V_lt = $(am__v_lt_@AM_V@) |  | ||||||
| am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) |  | ||||||
| am__v_lt_0 = --silent |  | ||||||
| am__v_lt_1 =  |  | ||||||
| libstix_snd_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ | libstix_snd_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ | ||||||
| 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ | 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ | ||||||
| 	$(AM_CFLAGS) $(CFLAGS) $(libstix_snd_la_LDFLAGS) $(LDFLAGS) -o \ | 	$(AM_CFLAGS) $(CFLAGS) $(libstix_snd_la_LDFLAGS) $(LDFLAGS) -o \ | ||||||
| @ -152,11 +164,11 @@ libstix_snd_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ | |||||||
| am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) | am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) | ||||||
| libstix_la_DEPENDENCIES = $(am__DEPENDENCIES_2) | libstix_la_DEPENDENCIES = $(am__DEPENDENCIES_2) | ||||||
| am_libstix_la_OBJECTS = libstix_la-bigint.lo libstix_la-comp.lo \ | am_libstix_la_OBJECTS = libstix_la-bigint.lo libstix_la-comp.lo \ | ||||||
| 	libstix_la-debug.lo libstix_la-dic.lo libstix_la-exec.lo \ | 	libstix_la-debug.lo libstix_la-decode.lo libstix_la-dic.lo \ | ||||||
| 	libstix_la-gc.lo libstix_la-heap.lo libstix_la-ignite.lo \ | 	libstix_la-exec.lo libstix_la-gc.lo libstix_la-heap.lo \ | ||||||
| 	libstix_la-obj.lo libstix_la-proc.lo libstix_la-rbt.lo \ | 	libstix_la-ignite.lo libstix_la-obj.lo libstix_la-proc.lo \ | ||||||
| 	libstix_la-stix.lo libstix_la-sym.lo libstix_la-utf8.lo \ | 	libstix_la-rbt.lo libstix_la-stix.lo libstix_la-sym.lo \ | ||||||
| 	libstix_la-utl.lo | 	libstix_la-utf8.lo libstix_la-utl.lo | ||||||
| libstix_la_OBJECTS = $(am_libstix_la_OBJECTS) | libstix_la_OBJECTS = $(am_libstix_la_OBJECTS) | ||||||
| libstix_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ | libstix_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ | ||||||
| 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ | 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ | ||||||
| @ -202,10 +214,11 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) | |||||||
| am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) | am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) | ||||||
| am__v_CCLD_0 = @echo "  CCLD    " $@; | am__v_CCLD_0 = @echo "  CCLD    " $@; | ||||||
| am__v_CCLD_1 =  | am__v_CCLD_1 =  | ||||||
| SOURCES = $(libstix_snd_la_SOURCES) $(libstix_la_SOURCES) \ | SOURCES = $(libstix_con_la_SOURCES) $(libstix_snd_la_SOURCES) \ | ||||||
| 	$(stix_SOURCES) |  | ||||||
| DIST_SOURCES = $(am__libstix_snd_la_SOURCES_DIST) \ |  | ||||||
| 	$(libstix_la_SOURCES) $(stix_SOURCES) | 	$(libstix_la_SOURCES) $(stix_SOURCES) | ||||||
|  | DIST_SOURCES = $(am__libstix_con_la_SOURCES_DIST) \ | ||||||
|  | 	$(am__libstix_snd_la_SOURCES_DIST) $(libstix_la_SOURCES) \ | ||||||
|  | 	$(stix_SOURCES) | ||||||
| am__can_run_installinfo = \ | am__can_run_installinfo = \ | ||||||
|   case $$AM_UPDATE_INFO_DIR in \ |   case $$AM_UPDATE_INFO_DIR in \ | ||||||
|     n|no|NO) false;; \ |     n|no|NO) false;; \ | ||||||
| @ -422,6 +435,7 @@ libstix_la_SOURCES = \ | |||||||
| 	bigint.c \ | 	bigint.c \ | ||||||
| 	comp.c \ | 	comp.c \ | ||||||
| 	debug.c  \ | 	debug.c  \ | ||||||
|  | 	decode.c \ | ||||||
| 	dic.c \ | 	dic.c \ | ||||||
| 	exec.c \ | 	exec.c \ | ||||||
| 	gc.c \ | 	gc.c \ | ||||||
| @ -457,11 +471,15 @@ stix_LDADD = $(LIBADD_LIB_COMMON) -lstix #-ldyncall_s | |||||||
| @ENABLE_STATIC_MODULE_FALSE@LDFLAGS_MOD_COMMON = $(LDFLAGS_LIB_COMMON) | @ENABLE_STATIC_MODULE_FALSE@LDFLAGS_MOD_COMMON = $(LDFLAGS_LIB_COMMON) | ||||||
| @ENABLE_STATIC_MODULE_FALSE@LIBADD_MOD_COMMON = -lstix | @ENABLE_STATIC_MODULE_FALSE@LIBADD_MOD_COMMON = -lstix | ||||||
| @ENABLE_STATIC_MODULE_FALSE@pkgmodexecdir = $(libdir) | @ENABLE_STATIC_MODULE_FALSE@pkgmodexecdir = $(libdir) | ||||||
| @ENABLE_STATIC_MODULE_FALSE@pkgmodexec_LTLIBRARIES = libstix-snd.la | @ENABLE_STATIC_MODULE_FALSE@pkgmodexec_LTLIBRARIES = libstix-snd.la libstix-con.la | ||||||
| @ENABLE_STATIC_MODULE_FALSE@libstix_snd_la_SOURCES = mod-snd.c mod-snd.h | @ENABLE_STATIC_MODULE_FALSE@libstix_snd_la_SOURCES = mod-snd.c mod-snd.h | ||||||
| @ENABLE_STATIC_MODULE_FALSE@libstix_snd_la_CPPFLAGS = $(CPPFLAGS_MOD_COMMON) | @ENABLE_STATIC_MODULE_FALSE@libstix_snd_la_CPPFLAGS = $(CPPFLAGS_MOD_COMMON) | ||||||
| @ENABLE_STATIC_MODULE_FALSE@libstix_snd_la_LDFLAGS = $(LDFLAGS_MOD_COMMON) | @ENABLE_STATIC_MODULE_FALSE@libstix_snd_la_LDFLAGS = $(LDFLAGS_MOD_COMMON) | ||||||
| @ENABLE_STATIC_MODULE_FALSE@libstix_snd_la_LIBADD = $(LIBADD_MOD_COMMON) | @ENABLE_STATIC_MODULE_FALSE@libstix_snd_la_LIBADD = $(LIBADD_MOD_COMMON) | ||||||
|  | @ENABLE_STATIC_MODULE_FALSE@libstix_con_la_SOURCES = mod-con.c mod-con.h | ||||||
|  | @ENABLE_STATIC_MODULE_FALSE@libstix_con_la_CPPFLAGS = $(CPPFLAGS_MOD_COMMON) | ||||||
|  | @ENABLE_STATIC_MODULE_FALSE@libstix_con_la_LDFLAGS = $(LDFLAGS_MOD_COMMON) | ||||||
|  | @ENABLE_STATIC_MODULE_FALSE@libstix_con_la_LIBADD = $(LIBADD_MOD_COMMON) | ||||||
| all: stix-cfg.h | all: stix-cfg.h | ||||||
| 	$(MAKE) $(AM_MAKEFLAGS) all-am | 	$(MAKE) $(AM_MAKEFLAGS) all-am | ||||||
|  |  | ||||||
| @ -583,6 +601,9 @@ clean-pkgmodexecLTLIBRARIES: | |||||||
| 	  rm -f $${locs}; \ | 	  rm -f $${locs}; \ | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | libstix-con.la: $(libstix_con_la_OBJECTS) $(libstix_con_la_DEPENDENCIES) $(EXTRA_libstix_con_la_DEPENDENCIES)  | ||||||
|  | 	$(AM_V_CCLD)$(libstix_con_la_LINK) $(am_libstix_con_la_rpath) $(libstix_con_la_OBJECTS) $(libstix_con_la_LIBADD) $(LIBS) | ||||||
|  |  | ||||||
| libstix-snd.la: $(libstix_snd_la_OBJECTS) $(libstix_snd_la_DEPENDENCIES) $(EXTRA_libstix_snd_la_DEPENDENCIES)  | libstix-snd.la: $(libstix_snd_la_OBJECTS) $(libstix_snd_la_DEPENDENCIES) $(EXTRA_libstix_snd_la_DEPENDENCIES)  | ||||||
| 	$(AM_V_CCLD)$(libstix_snd_la_LINK) $(am_libstix_snd_la_rpath) $(libstix_snd_la_OBJECTS) $(libstix_snd_la_LIBADD) $(LIBS) | 	$(AM_V_CCLD)$(libstix_snd_la_LINK) $(am_libstix_snd_la_rpath) $(libstix_snd_la_OBJECTS) $(libstix_snd_la_LIBADD) $(LIBS) | ||||||
|  |  | ||||||
| @ -648,9 +669,11 @@ mostlyclean-compile: | |||||||
| distclean-compile: | distclean-compile: | ||||||
| 	-rm -f *.tab.c | 	-rm -f *.tab.c | ||||||
|  |  | ||||||
|  | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_con_la-mod-con.Plo@am__quote@ | ||||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-bigint.Plo@am__quote@ | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-bigint.Plo@am__quote@ | ||||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-comp.Plo@am__quote@ | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-comp.Plo@am__quote@ | ||||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-debug.Plo@am__quote@ | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-debug.Plo@am__quote@ | ||||||
|  | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-decode.Plo@am__quote@ | ||||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-dic.Plo@am__quote@ | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-dic.Plo@am__quote@ | ||||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-exec.Plo@am__quote@ | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-exec.Plo@am__quote@ | ||||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-gc.Plo@am__quote@ | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-gc.Plo@am__quote@ | ||||||
| @ -690,6 +713,13 @@ distclean-compile: | |||||||
| @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||||||
| @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< | @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< | ||||||
|  |  | ||||||
|  | libstix_con_la-mod-con.lo: mod-con.c | ||||||
|  | @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstix_con_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libstix_con_la-mod-con.lo -MD -MP -MF $(DEPDIR)/libstix_con_la-mod-con.Tpo -c -o libstix_con_la-mod-con.lo `test -f 'mod-con.c' || echo '$(srcdir)/'`mod-con.c | ||||||
|  | @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libstix_con_la-mod-con.Tpo $(DEPDIR)/libstix_con_la-mod-con.Plo | ||||||
|  | @AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='mod-con.c' object='libstix_con_la-mod-con.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_con_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libstix_con_la-mod-con.lo `test -f 'mod-con.c' || echo '$(srcdir)/'`mod-con.c | ||||||
|  |  | ||||||
| libstix_snd_la-mod-snd.lo: mod-snd.c | libstix_snd_la-mod-snd.lo: mod-snd.c | ||||||
| @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstix_snd_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libstix_snd_la-mod-snd.lo -MD -MP -MF $(DEPDIR)/libstix_snd_la-mod-snd.Tpo -c -o libstix_snd_la-mod-snd.lo `test -f 'mod-snd.c' || echo '$(srcdir)/'`mod-snd.c | @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstix_snd_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libstix_snd_la-mod-snd.lo -MD -MP -MF $(DEPDIR)/libstix_snd_la-mod-snd.Tpo -c -o libstix_snd_la-mod-snd.lo `test -f 'mod-snd.c' || echo '$(srcdir)/'`mod-snd.c | ||||||
| @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libstix_snd_la-mod-snd.Tpo $(DEPDIR)/libstix_snd_la-mod-snd.Plo | @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libstix_snd_la-mod-snd.Tpo $(DEPDIR)/libstix_snd_la-mod-snd.Plo | ||||||
| @ -718,6 +748,13 @@ libstix_la-debug.lo: debug.c | |||||||
| @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @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-debug.lo `test -f 'debug.c' || echo '$(srcdir)/'`debug.c | @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-debug.lo `test -f 'debug.c' || echo '$(srcdir)/'`debug.c | ||||||
|  |  | ||||||
|  | libstix_la-decode.lo: decode.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-decode.lo -MD -MP -MF $(DEPDIR)/libstix_la-decode.Tpo -c -o libstix_la-decode.lo `test -f 'decode.c' || echo '$(srcdir)/'`decode.c | ||||||
|  | @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libstix_la-decode.Tpo $(DEPDIR)/libstix_la-decode.Plo | ||||||
|  | @AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='decode.c' object='libstix_la-decode.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-decode.lo `test -f 'decode.c' || echo '$(srcdir)/'`decode.c | ||||||
|  |  | ||||||
| libstix_la-dic.lo: dic.c | libstix_la-dic.lo: dic.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-dic.lo -MD -MP -MF $(DEPDIR)/libstix_la-dic.Tpo -c -o libstix_la-dic.lo `test -f 'dic.c' || echo '$(srcdir)/'`dic.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-dic.lo -MD -MP -MF $(DEPDIR)/libstix_la-dic.Tpo -c -o libstix_la-dic.lo `test -f 'dic.c' || echo '$(srcdir)/'`dic.c | ||||||
| @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libstix_la-dic.Tpo $(DEPDIR)/libstix_la-dic.Plo | @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libstix_la-dic.Tpo $(DEPDIR)/libstix_la-dic.Plo | ||||||
|  | |||||||
| @ -159,7 +159,6 @@ typedef enum voca_id_t voca_id_t; | |||||||
| #	define DBGOUT_COMP_3(fmt,a1,a2,a3) | #	define DBGOUT_COMP_3(fmt,a1,a2,a3) | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
| static int compile_block_statement (stix_t* stix); | static int compile_block_statement (stix_t* stix); | ||||||
| static int compile_method_statement (stix_t* stix); | static int compile_method_statement (stix_t* stix); | ||||||
| static int compile_method_expression (stix_t* stix, int pop); | static int compile_method_expression (stix_t* stix, int pop); | ||||||
| @ -1547,13 +1546,13 @@ static const stix_ooch_t* add_io_name (stix_t* stix, const stix_oocs_t* name) | |||||||
|  |  | ||||||
| static int begin_include (stix_t* stix) | static int begin_include (stix_t* stix) | ||||||
| { | { | ||||||
| 	stix_io_arg_t* arg; | 	stix_ioarg_t* arg; | ||||||
| 	const stix_ooch_t* io_name; | 	const stix_ooch_t* io_name; | ||||||
|  |  | ||||||
| 	io_name = add_io_name (stix, &stix->c->tok.name); | 	io_name = add_io_name (stix, &stix->c->tok.name); | ||||||
| 	if (!io_name) return -1; | 	if (!io_name) return -1; | ||||||
|  |  | ||||||
| 	arg = (stix_io_arg_t*) stix_callocmem (stix, STIX_SIZEOF(*arg)); | 	arg = (stix_ioarg_t*) stix_callocmem (stix, STIX_SIZEOF(*arg)); | ||||||
| 	if (!arg) goto oops; | 	if (!arg) goto oops; | ||||||
|  |  | ||||||
| 	arg->name = io_name; | 	arg->name = io_name; | ||||||
| @ -1600,7 +1599,7 @@ oops: | |||||||
| static int end_include (stix_t* stix) | static int end_include (stix_t* stix) | ||||||
| { | { | ||||||
| 	int x; | 	int x; | ||||||
| 	stix_io_arg_t* cur; | 	stix_ioarg_t* cur; | ||||||
|  |  | ||||||
| 	if (stix->c->curinp == &stix->c->arg) return 0; /* no include */ | 	if (stix->c->curinp == &stix->c->arg) return 0; /* no include */ | ||||||
|  |  | ||||||
| @ -2633,7 +2632,7 @@ static int compile_method_primitive (stix_t* stix) | |||||||
| 				while (ptr < end && is_digitchar(*ptr))  | 				while (ptr < end && is_digitchar(*ptr))  | ||||||
| 				{ | 				{ | ||||||
| 					prim_no = prim_no * 10 + (*ptr - '0'); | 					prim_no = prim_no * 10 + (*ptr - '0'); | ||||||
| 					if (!STIX_OOI_IN_PREAMBLE_INDEX_RANGE(prim_no)) | 					if (!STIX_OOI_IN_METHOD_PREAMBLE_INDEX_RANGE(prim_no)) | ||||||
| 					{ | 					{ | ||||||
| 						set_syntax_error (stix, STIX_SYNERR_PRIMNO, &stix->c->tok.loc, &stix->c->tok.name); | 						set_syntax_error (stix, STIX_SYNERR_PRIMNO, &stix->c->tok.loc, &stix->c->tok.name); | ||||||
| 						return -1; | 						return -1; | ||||||
| @ -2658,7 +2657,7 @@ static int compile_method_primitive (stix_t* stix) | |||||||
| 						/* the symbol literal contains an underscore. | 						/* the symbol literal contains an underscore. | ||||||
| 						 * and it is none of the first of the last character */ | 						 * and it is none of the first of the last character */ | ||||||
| 						if (add_symbol_literal(stix, &stix->c->tok.name, &lit_idx) >= 0 && | 						if (add_symbol_literal(stix, &stix->c->tok.name, &lit_idx) >= 0 && | ||||||
| 						    STIX_OOI_IN_PREAMBLE_INDEX_RANGE(lit_idx)) | 						    STIX_OOI_IN_METHOD_PREAMBLE_INDEX_RANGE(lit_idx)) | ||||||
| 						{ | 						{ | ||||||
| 							stix->c->mth.prim_type = 2; /* named primitive */ | 							stix->c->mth.prim_type = 2; /* named primitive */ | ||||||
| 							stix->c->mth.prim_no = lit_idx; | 							stix->c->mth.prim_no = lit_idx; | ||||||
| @ -2669,7 +2668,7 @@ static int compile_method_primitive (stix_t* stix) | |||||||
| 					set_syntax_error (stix, STIX_SYNERR_PRIMNO, &stix->c->tok.loc, &stix->c->tok.name); | 					set_syntax_error (stix, STIX_SYNERR_PRIMNO, &stix->c->tok.loc, &stix->c->tok.name); | ||||||
| 					return -1; | 					return -1; | ||||||
| 				} | 				} | ||||||
| 				else if (!STIX_OOI_IN_PREAMBLE_INDEX_RANGE(prim_no)) | 				else if (!STIX_OOI_IN_METHOD_PREAMBLE_INDEX_RANGE(prim_no)) | ||||||
| 				{ | 				{ | ||||||
| 					set_syntax_error (stix, STIX_SYNERR_PRIMNO, &stix->c->tok.loc, &stix->c->tok.name); | 					set_syntax_error (stix, STIX_SYNERR_PRIMNO, &stix->c->tok.loc, &stix->c->tok.name); | ||||||
| 					return -1; | 					return -1; | ||||||
| @ -4263,7 +4262,7 @@ static int add_compiled_method (stix_t* stix) | |||||||
| 							preamble_index = (preamble_index << 8) | stix->c->mth.code.ptr[i]; | 							preamble_index = (preamble_index << 8) | stix->c->mth.code.ptr[i]; | ||||||
| 						} | 						} | ||||||
|  |  | ||||||
| 						if (!STIX_OOI_IN_PREAMBLE_INDEX_RANGE(preamble_index)) | 						if (!STIX_OOI_IN_METHOD_PREAMBLE_INDEX_RANGE(preamble_index)) | ||||||
| 						{ | 						{ | ||||||
| 							/* the index got out of the range */ | 							/* the index got out of the range */ | ||||||
| 							preamble_code = STIX_METHOD_PREAMBLE_NONE; | 							preamble_code = STIX_METHOD_PREAMBLE_NONE; | ||||||
| @ -4290,7 +4289,7 @@ static int add_compiled_method (stix_t* stix) | |||||||
| 		preamble_index = 0; | 		preamble_index = 0; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	STIX_ASSERT (STIX_OOI_IN_PREAMBLE_INDEX_RANGE(preamble_index)); | 	STIX_ASSERT (STIX_OOI_IN_METHOD_PREAMBLE_INDEX_RANGE(preamble_index)); | ||||||
|  |  | ||||||
| 	mth->owner = stix->c->cls.self_oop; | 	mth->owner = stix->c->cls.self_oop; | ||||||
| 	mth->name = name; | 	mth->name = name; | ||||||
| @ -4311,9 +4310,15 @@ the compiler must collect all source method string collected so far. | |||||||
| need to write code to collect string. | need to write code to collect string. | ||||||
| */ | */ | ||||||
|  |  | ||||||
|  | 	/* TODO: if (decoding is enabled... */ | ||||||
|  | printf (">>>> BYTE CODE.....\n"); | ||||||
|  | 	stix_decode (stix, mth); | ||||||
|  |  | ||||||
|  |  | ||||||
| 	stix_poptmps (stix, tmp_count); tmp_count = 0; | 	stix_poptmps (stix, tmp_count); tmp_count = 0; | ||||||
|  |  | ||||||
| 	if (!stix_putatdic(stix, stix->c->cls.mthdic_oop[stix->c->mth.type], (stix_oop_t)name, (stix_oop_t)mth)) goto oops; | 	if (!stix_putatdic(stix, stix->c->cls.mthdic_oop[stix->c->mth.type], (stix_oop_t)name, (stix_oop_t)mth)) goto oops; | ||||||
|  |  | ||||||
| 	return 0; | 	return 0; | ||||||
|  |  | ||||||
| oops: | oops: | ||||||
| @ -5190,7 +5195,7 @@ static void fini_compiler (stix_t* stix) | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| int stix_compile (stix_t* stix, stix_io_impl_t io) | int stix_compile (stix_t* stix, stix_ioimpl_t io) | ||||||
| { | { | ||||||
| 	int n; | 	int n; | ||||||
|  |  | ||||||
| @ -5259,7 +5264,7 @@ oops: | |||||||
| 	 * closed. close them */ | 	 * closed. close them */ | ||||||
| 	while (stix->c->curinp != &stix->c->arg) | 	while (stix->c->curinp != &stix->c->arg) | ||||||
| 	{ | 	{ | ||||||
| 		stix_io_arg_t* prev; | 		stix_ioarg_t* prev; | ||||||
|  |  | ||||||
| 		/* nothing much to do about a close error */ | 		/* nothing much to do about a close error */ | ||||||
| 		stix->c->impl (stix, STIX_IO_CLOSE, stix->c->curinp); | 		stix->c->impl (stix, STIX_IO_CLOSE, stix->c->curinp); | ||||||
| @ -5279,3 +5284,5 @@ void stix_getsynerr (stix_t* stix, stix_synerr_t* synerr) | |||||||
| 	STIX_ASSERT (stix->c != STIX_NULL); | 	STIX_ASSERT (stix->c != STIX_NULL); | ||||||
| 	if (synerr) *synerr = stix->c->synerr; | 	if (synerr) *synerr = stix->c->synerr; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | |||||||
							
								
								
									
										503
									
								
								stix/lib/decode.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										503
									
								
								stix/lib/decode.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,503 @@ | |||||||
|  | /* | ||||||
|  |  * $Id$ | ||||||
|  |  * | ||||||
|  |     Copyright (c) 2014-2016 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 WAfRRANTIES | ||||||
|  |     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" | ||||||
|  |  | ||||||
|  | #	define DECODE_OUT_0(fmt) printf("\t" fmt "\n") | ||||||
|  | #	define DECODE_OUT_1(fmt,a1) printf("\t" fmt "\n",a1) | ||||||
|  | #	define DECODE_OUT_2(fmt,a1,a2) printf("\t" fmt "\n", a1, a2) | ||||||
|  | #	define DECODE_OUT_3(fmt,a1,a2,a3) printf("\t" fmt "\n", a1, a2, a3) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #define FETCH_BYTE_CODE(stix) (cdptr[ip++]) | ||||||
|  | #define FETCH_BYTE_CODE_TO(stix,v_ooi) (v_ooi = FETCH_BYTE_CODE(stix)) | ||||||
|  | #if (STIX_BCODE_LONG_PARAM_SIZE == 2) | ||||||
|  | #	define FETCH_PARAM_CODE_TO(stix,v_ooi) \ | ||||||
|  | 		do { \ | ||||||
|  | 			v_ooi = FETCH_BYTE_CODE(stix); \ | ||||||
|  | 			v_ooi = (v_ooi << 8) | FETCH_BYTE_CODE(stix); \ | ||||||
|  | 		} while (0) | ||||||
|  | #else | ||||||
|  | #	define FETCH_PARAM_CODE_TO(stix,v_ooi) (v_ooi = FETCH_BYTE_CODE(stix)) | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | /* TODO: check if ip shoots beyond the maximum length in fetching code and parameters */ | ||||||
|  | static int decode (stix_t* stix, stix_oop_method_t mth) | ||||||
|  | { | ||||||
|  | 	stix_oob_t bcode, * cdptr; | ||||||
|  | 	stix_oow_t ip = 0, cdlen; | ||||||
|  | 	stix_ooi_t b1, b2; | ||||||
|  |   | ||||||
|  | 	cdptr = STIX_METHOD_GET_CODE_BYTE(mth); | ||||||
|  | 	cdlen = STIX_METHOD_GET_CODE_SIZE(mth);  | ||||||
|  |  | ||||||
|  | /* TODO: check if ip increases beyon bcode when fetching parameters too */ | ||||||
|  | 	while (ip < cdlen) | ||||||
|  | 	{ | ||||||
|  | 		FETCH_BYTE_CODE_TO(stix, bcode); | ||||||
|  |  | ||||||
|  | 		switch (bcode) | ||||||
|  | 		{ | ||||||
|  | 			case BCODE_PUSH_INSTVAR_X: | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b1); | ||||||
|  | 				goto push_instvar; | ||||||
|  | 			case BCODE_PUSH_INSTVAR_0: | ||||||
|  | 			case BCODE_PUSH_INSTVAR_1: | ||||||
|  | 			case BCODE_PUSH_INSTVAR_2: | ||||||
|  | 			case BCODE_PUSH_INSTVAR_3: | ||||||
|  | 			case BCODE_PUSH_INSTVAR_4: | ||||||
|  | 			case BCODE_PUSH_INSTVAR_5: | ||||||
|  | 			case BCODE_PUSH_INSTVAR_6: | ||||||
|  | 			case BCODE_PUSH_INSTVAR_7: | ||||||
|  | 				b1 = bcode & 0x7; /* low 3 bits */ | ||||||
|  | 			push_instvar: | ||||||
|  | 				DECODE_OUT_1 ("push_instvar %lu", (unsigned long int)b1); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			/* ------------------------------------------------- */ | ||||||
|  |  | ||||||
|  | 			case BCODE_STORE_INTO_INSTVAR_X: | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b1); | ||||||
|  | 				goto store_instvar; | ||||||
|  | 			case BCODE_STORE_INTO_INSTVAR_0: | ||||||
|  | 			case BCODE_STORE_INTO_INSTVAR_1: | ||||||
|  | 			case BCODE_STORE_INTO_INSTVAR_2: | ||||||
|  | 			case BCODE_STORE_INTO_INSTVAR_3: | ||||||
|  | 			case BCODE_STORE_INTO_INSTVAR_4: | ||||||
|  | 			case BCODE_STORE_INTO_INSTVAR_5: | ||||||
|  | 			case BCODE_STORE_INTO_INSTVAR_6: | ||||||
|  | 			case BCODE_STORE_INTO_INSTVAR_7: | ||||||
|  | 				b1 = bcode & 0x7; /* low 3 bits */ | ||||||
|  | 			store_instvar: | ||||||
|  | 				DECODE_OUT_1 ("store_into_instvar %lu", (unsigned long int)b1); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_POP_INTO_INSTVAR_X: | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b1); | ||||||
|  | 				goto pop_into_instvar; | ||||||
|  | 			case BCODE_POP_INTO_INSTVAR_0: | ||||||
|  | 			case BCODE_POP_INTO_INSTVAR_1: | ||||||
|  | 			case BCODE_POP_INTO_INSTVAR_2: | ||||||
|  | 			case BCODE_POP_INTO_INSTVAR_3: | ||||||
|  | 			case BCODE_POP_INTO_INSTVAR_4: | ||||||
|  | 			case BCODE_POP_INTO_INSTVAR_5: | ||||||
|  | 			case BCODE_POP_INTO_INSTVAR_6: | ||||||
|  | 			case BCODE_POP_INTO_INSTVAR_7: | ||||||
|  | 				b1 = bcode & 0x7; /* low 3 bits */ | ||||||
|  | 			pop_into_instvar: | ||||||
|  | 				DECODE_OUT_1 ("pop_into_instvar %lu", (unsigned long int)b1); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			/* ------------------------------------------------- */ | ||||||
|  | 			case BCODE_PUSH_TEMPVAR_X: | ||||||
|  | 			case BCODE_STORE_INTO_TEMPVAR_X: | ||||||
|  | 			case BCODE_POP_INTO_TEMPVAR_X: | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b1); | ||||||
|  | 				goto handle_tempvar; | ||||||
|  |  | ||||||
|  | 			case BCODE_PUSH_TEMPVAR_0: | ||||||
|  | 			case BCODE_PUSH_TEMPVAR_1: | ||||||
|  | 			case BCODE_PUSH_TEMPVAR_2: | ||||||
|  | 			case BCODE_PUSH_TEMPVAR_3: | ||||||
|  | 			case BCODE_PUSH_TEMPVAR_4: | ||||||
|  | 			case BCODE_PUSH_TEMPVAR_5: | ||||||
|  | 			case BCODE_PUSH_TEMPVAR_6: | ||||||
|  | 			case BCODE_PUSH_TEMPVAR_7: | ||||||
|  | 			case BCODE_STORE_INTO_TEMPVAR_0: | ||||||
|  | 			case BCODE_STORE_INTO_TEMPVAR_1: | ||||||
|  | 			case BCODE_STORE_INTO_TEMPVAR_2: | ||||||
|  | 			case BCODE_STORE_INTO_TEMPVAR_3: | ||||||
|  | 			case BCODE_STORE_INTO_TEMPVAR_4: | ||||||
|  | 			case BCODE_STORE_INTO_TEMPVAR_5: | ||||||
|  | 			case BCODE_STORE_INTO_TEMPVAR_6: | ||||||
|  | 			case BCODE_STORE_INTO_TEMPVAR_7: | ||||||
|  | 			case BCODE_POP_INTO_TEMPVAR_0: | ||||||
|  | 			case BCODE_POP_INTO_TEMPVAR_1: | ||||||
|  | 			case BCODE_POP_INTO_TEMPVAR_2: | ||||||
|  | 			case BCODE_POP_INTO_TEMPVAR_3: | ||||||
|  | 			case BCODE_POP_INTO_TEMPVAR_4: | ||||||
|  | 			case BCODE_POP_INTO_TEMPVAR_5: | ||||||
|  | 			case BCODE_POP_INTO_TEMPVAR_6: | ||||||
|  | 			case BCODE_POP_INTO_TEMPVAR_7: | ||||||
|  | 				b1 = bcode & 0x7; /* low 3 bits */ | ||||||
|  | 			handle_tempvar: | ||||||
|  |  | ||||||
|  | 				if ((bcode >> 4) & 1) | ||||||
|  | 				{ | ||||||
|  | 					/* push - bit 4 on */ | ||||||
|  | 					DECODE_OUT_1 ("push_tempvar %d", (int)b1); | ||||||
|  | 				} | ||||||
|  | 				else | ||||||
|  | 				{ | ||||||
|  | 					/* store or pop - bit 5 off */ | ||||||
|  | 					if ((bcode >> 3) & 1) | ||||||
|  | 					{ | ||||||
|  | 						/* pop - bit 3 on */ | ||||||
|  | 						DECODE_OUT_1 ("pop_into_tempvar %d", (int)b1); | ||||||
|  | 					} | ||||||
|  | 					else | ||||||
|  | 					{ | ||||||
|  | 						DECODE_OUT_1 ("store_into_tempvar %d", (int)b1); | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			/* ------------------------------------------------- */ | ||||||
|  | 			case BCODE_PUSH_LITERAL_X: | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b1); | ||||||
|  | 				goto push_literal; | ||||||
|  |  | ||||||
|  | 			case BCODE_PUSH_LITERAL_0: | ||||||
|  | 			case BCODE_PUSH_LITERAL_1: | ||||||
|  | 			case BCODE_PUSH_LITERAL_2: | ||||||
|  | 			case BCODE_PUSH_LITERAL_3: | ||||||
|  | 			case BCODE_PUSH_LITERAL_4: | ||||||
|  | 			case BCODE_PUSH_LITERAL_5: | ||||||
|  | 			case BCODE_PUSH_LITERAL_6: | ||||||
|  | 			case BCODE_PUSH_LITERAL_7: | ||||||
|  | 				b1 = bcode & 0x7; /* low 3 bits */ | ||||||
|  | 			push_literal: | ||||||
|  | 				DECODE_OUT_1 ("push_literal %d", (int)b1); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			/* ------------------------------------------------- */ | ||||||
|  | 			case BCODE_PUSH_OBJECT_X: | ||||||
|  | 			case BCODE_STORE_INTO_OBJECT_X: | ||||||
|  | 			case BCODE_POP_INTO_OBJECT_X: | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b1); | ||||||
|  | 				goto handle_object; | ||||||
|  |  | ||||||
|  | 			case BCODE_PUSH_OBJECT_0: | ||||||
|  | 			case BCODE_PUSH_OBJECT_1: | ||||||
|  | 			case BCODE_PUSH_OBJECT_2: | ||||||
|  | 			case BCODE_PUSH_OBJECT_3: | ||||||
|  | 			case BCODE_STORE_INTO_OBJECT_0: | ||||||
|  | 			case BCODE_STORE_INTO_OBJECT_1: | ||||||
|  | 			case BCODE_STORE_INTO_OBJECT_2: | ||||||
|  | 			case BCODE_STORE_INTO_OBJECT_3: | ||||||
|  | 			case BCODE_POP_INTO_OBJECT_0: | ||||||
|  | 			case BCODE_POP_INTO_OBJECT_1: | ||||||
|  | 			case BCODE_POP_INTO_OBJECT_2: | ||||||
|  | 			case BCODE_POP_INTO_OBJECT_3: | ||||||
|  | 				b1 = bcode & 0x3; /* low 2 bits */ | ||||||
|  | 			handle_object: | ||||||
|  | 				if ((bcode >> 3) & 1) | ||||||
|  | 				{ | ||||||
|  | 					if ((bcode >> 2) & 1) | ||||||
|  | 					{ | ||||||
|  | 						DECODE_OUT_1("pop_into_object %d", (int)b1); | ||||||
|  | 					} | ||||||
|  | 					else | ||||||
|  | 					{ | ||||||
|  | 						DECODE_OUT_1("store_into_object %d", (int)b1); | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 				else | ||||||
|  | 				{ | ||||||
|  | 					DECODE_OUT_1("push_object %d", (int)b1); | ||||||
|  | 				} | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			/* -------------------------------------------------------- */ | ||||||
|  |  | ||||||
|  | 			case BCODE_JUMP_FORWARD_X: | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b1); | ||||||
|  | 				DECODE_OUT_1 ("jump_forward %d", (int)b1); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_JUMP_FORWARD_0: | ||||||
|  | 			case BCODE_JUMP_FORWARD_1: | ||||||
|  | 			case BCODE_JUMP_FORWARD_2: | ||||||
|  | 			case BCODE_JUMP_FORWARD_3: | ||||||
|  | 				DECODE_OUT_1 ("jump_forward %d", (int)(bcode & 0x3)); /* low 2 bits */ | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_JUMP_BACKWARD_X: | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b1); | ||||||
|  | 				DECODE_OUT_1 ("jump_backward %d", (int)b1); | ||||||
|  | 				stix->ip += b1; | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_JUMP_BACKWARD_0: | ||||||
|  | 			case BCODE_JUMP_BACKWARD_1: | ||||||
|  | 			case BCODE_JUMP_BACKWARD_2: | ||||||
|  | 			case BCODE_JUMP_BACKWARD_3: | ||||||
|  | 				DECODE_OUT_1 ("jump_backward %d", (int)(bcode & 0x3)); /* low 2 bits */ | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_JUMP_IF_TRUE_X: | ||||||
|  | 			case BCODE_JUMP_IF_FALSE_X: | ||||||
|  | 			case BCODE_JUMP_IF_TRUE_0: | ||||||
|  | 			case BCODE_JUMP_IF_TRUE_1: | ||||||
|  | 			case BCODE_JUMP_IF_TRUE_2: | ||||||
|  | 			case BCODE_JUMP_IF_TRUE_3: | ||||||
|  | 			case BCODE_JUMP_IF_FALSE_0: | ||||||
|  | 			case BCODE_JUMP_IF_FALSE_1: | ||||||
|  | 			case BCODE_JUMP_IF_FALSE_2: | ||||||
|  | 			case BCODE_JUMP_IF_FALSE_3: | ||||||
|  | printf ("<<<<<<<<<<<<<< JUMP NOT IMPLEMENTED YET >>>>>>>>>>>> \n"); | ||||||
|  | stix->errnum = STIX_ENOIMPL; | ||||||
|  | return -1; | ||||||
|  |  | ||||||
|  | 			case BCODE_JUMP2_FORWARD: | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b1); | ||||||
|  | 				DECODE_OUT_1 ("jump2_forward %d", (int)b1); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_JUMP2_BACKWARD: | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b1); | ||||||
|  | 				DECODE_OUT_1 ("jump2_backward %d", (int)b1); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			/* -------------------------------------------------------- */ | ||||||
|  |  | ||||||
|  | 			case BCODE_PUSH_CTXTEMPVAR_X: | ||||||
|  | 			case BCODE_STORE_INTO_CTXTEMPVAR_X: | ||||||
|  | 			case BCODE_POP_INTO_CTXTEMPVAR_X: | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b1); | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b2); | ||||||
|  | 				goto handle_ctxtempvar; | ||||||
|  | 			case BCODE_PUSH_CTXTEMPVAR_0: | ||||||
|  | 			case BCODE_PUSH_CTXTEMPVAR_1: | ||||||
|  | 			case BCODE_PUSH_CTXTEMPVAR_2: | ||||||
|  | 			case BCODE_PUSH_CTXTEMPVAR_3: | ||||||
|  | 			case BCODE_STORE_INTO_CTXTEMPVAR_0: | ||||||
|  | 			case BCODE_STORE_INTO_CTXTEMPVAR_1: | ||||||
|  | 			case BCODE_STORE_INTO_CTXTEMPVAR_2: | ||||||
|  | 			case BCODE_STORE_INTO_CTXTEMPVAR_3: | ||||||
|  | 			case BCODE_POP_INTO_CTXTEMPVAR_0: | ||||||
|  | 			case BCODE_POP_INTO_CTXTEMPVAR_1: | ||||||
|  | 			case BCODE_POP_INTO_CTXTEMPVAR_2: | ||||||
|  | 			case BCODE_POP_INTO_CTXTEMPVAR_3: | ||||||
|  | 				b1 = bcode & 0x3; /* low 2 bits */ | ||||||
|  | 				FETCH_BYTE_CODE_TO (stix, b2); | ||||||
|  |  | ||||||
|  | 			handle_ctxtempvar: | ||||||
|  | 				if ((bcode >> 3) & 1) | ||||||
|  | 				{ | ||||||
|  | 					/* store or pop */ | ||||||
|  |  | ||||||
|  | 					if ((bcode >> 2) & 1) | ||||||
|  | 					{ | ||||||
|  | 						DECODE_OUT_2 ("pop_into_ctxtempvar %d %d", (int)b1, (int)b2); | ||||||
|  | 					} | ||||||
|  | 					else | ||||||
|  | 					{ | ||||||
|  | 						DECODE_OUT_2 ("store_into_ctxtempvar %d %d", (int)b1, (int)b2); | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 				else | ||||||
|  | 				{ | ||||||
|  | 					/* push */ | ||||||
|  | 					DECODE_OUT_2 ("push_ctxtempvar %d %d", (int)b1, (int)b2); | ||||||
|  | 				} | ||||||
|  |  | ||||||
|  | 				break; | ||||||
|  | 			/* -------------------------------------------------------- */ | ||||||
|  |  | ||||||
|  | 			case BCODE_PUSH_OBJVAR_X: | ||||||
|  | 			case BCODE_STORE_INTO_OBJVAR_X: | ||||||
|  | 			case BCODE_POP_INTO_OBJVAR_X: | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b1); | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b2); | ||||||
|  | 				goto handle_objvar; | ||||||
|  |  | ||||||
|  | 			case BCODE_PUSH_OBJVAR_0: | ||||||
|  | 			case BCODE_PUSH_OBJVAR_1: | ||||||
|  | 			case BCODE_PUSH_OBJVAR_2: | ||||||
|  | 			case BCODE_PUSH_OBJVAR_3: | ||||||
|  | 			case BCODE_STORE_INTO_OBJVAR_0: | ||||||
|  | 			case BCODE_STORE_INTO_OBJVAR_1: | ||||||
|  | 			case BCODE_STORE_INTO_OBJVAR_2: | ||||||
|  | 			case BCODE_STORE_INTO_OBJVAR_3: | ||||||
|  | 			case BCODE_POP_INTO_OBJVAR_0: | ||||||
|  | 			case BCODE_POP_INTO_OBJVAR_1: | ||||||
|  | 			case BCODE_POP_INTO_OBJVAR_2: | ||||||
|  | 			case BCODE_POP_INTO_OBJVAR_3: | ||||||
|  | 				/* b1 -> variable index to the object indicated by b2. | ||||||
|  | 				 * b2 -> object index stored in the literal frame. */ | ||||||
|  | 				b1 = bcode & 0x3; /* low 2 bits */ | ||||||
|  | 				FETCH_BYTE_CODE_TO (stix, b2); | ||||||
|  |  | ||||||
|  | 			handle_objvar: | ||||||
|  | 				if ((bcode >> 3) & 1) | ||||||
|  | 				{ | ||||||
|  | 					/* store or pop */ | ||||||
|  | 					if ((bcode >> 2) & 1) | ||||||
|  | 					{ | ||||||
|  | 						DECODE_OUT_2 ("pop_into_objvar %d %d", (int)b1, (int)b2); | ||||||
|  | 					} | ||||||
|  | 					else | ||||||
|  | 					{ | ||||||
|  | 						DECODE_OUT_2 ("store_into_objvar %d %d", (int)b1, (int)b2); | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 				else | ||||||
|  | 				{ | ||||||
|  | 					DECODE_OUT_2 ("push_objvar %d %d", (int)b1, (int)b2); | ||||||
|  | 				} | ||||||
|  |  | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			/* -------------------------------------------------------- */ | ||||||
|  | 			case BCODE_SEND_MESSAGE_X: | ||||||
|  | 			case BCODE_SEND_MESSAGE_TO_SUPER_X: | ||||||
|  | 				/* b1 -> number of arguments  | ||||||
|  | 				 * b2 -> selector index stored in the literal frame */ | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b1); | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b2); | ||||||
|  | 				goto handle_send_message; | ||||||
|  |  | ||||||
|  | 			case BCODE_SEND_MESSAGE_0: | ||||||
|  | 			case BCODE_SEND_MESSAGE_1: | ||||||
|  | 			case BCODE_SEND_MESSAGE_2: | ||||||
|  | 			case BCODE_SEND_MESSAGE_3: | ||||||
|  | 			case BCODE_SEND_MESSAGE_TO_SUPER_0: | ||||||
|  | 			case BCODE_SEND_MESSAGE_TO_SUPER_1: | ||||||
|  | 			case BCODE_SEND_MESSAGE_TO_SUPER_2: | ||||||
|  | 			case BCODE_SEND_MESSAGE_TO_SUPER_3: | ||||||
|  | 				b1 = bcode & 0x3; /* low 2 bits */ | ||||||
|  | 				FETCH_BYTE_CODE_TO (stix, b2); | ||||||
|  |  | ||||||
|  | 			handle_send_message: | ||||||
|  | 				DECODE_OUT_3 ("send_message%s nargs=%d selector=%d", (((bcode >> 2) & 1)? "_to_super": ""), (int)b1, (int)b2); | ||||||
|  | 				break;  | ||||||
|  |  | ||||||
|  | 			/* -------------------------------------------------------- */ | ||||||
|  |  | ||||||
|  | 			case BCODE_PUSH_RECEIVER: | ||||||
|  | 				DECODE_OUT_0 ("push_receiver"); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_PUSH_NIL: | ||||||
|  | 				DECODE_OUT_0 ("push_nil"); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_PUSH_TRUE: | ||||||
|  | 				DECODE_OUT_0 ("push_true"); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_PUSH_FALSE: | ||||||
|  | 				DECODE_OUT_0 ("push_false"); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_PUSH_CONTEXT: | ||||||
|  | 				DECODE_OUT_0 ("push_context"); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_PUSH_NEGONE: | ||||||
|  | 				DECODE_OUT_0 ("push_negone"); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_PUSH_ZERO: | ||||||
|  | 				DECODE_OUT_0 ("push_zero"); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_PUSH_ONE: | ||||||
|  | 				DECODE_OUT_0 ("push_one"); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_PUSH_TWO: | ||||||
|  | 				DECODE_OUT_0 ("push_two"); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_PUSH_INTLIT: | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b1); | ||||||
|  | 				DECODE_OUT_1 ("push_intlit %d", (int)b1); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_PUSH_NEGINTLIT: | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b1); | ||||||
|  | 				DECODE_OUT_1 ("push_negintlit %d", (int)-b1); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			/* -------------------------------------------------------- */ | ||||||
|  |  | ||||||
|  | 			case BCODE_DUP_STACKTOP: | ||||||
|  | 				DECODE_OUT_0 ("dup_stacktop"); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_POP_STACKTOP: | ||||||
|  | 				DECODE_OUT_0 ("pop_stacktop"); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_RETURN_STACKTOP: | ||||||
|  | 				DECODE_OUT_0 ("return_stacktop"); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_RETURN_RECEIVER: | ||||||
|  | 				DECODE_OUT_0 ("return_receiver"); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_RETURN_FROM_BLOCK: | ||||||
|  | 				DECODE_OUT_0 ("return_from_block"); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_MAKE_BLOCK: | ||||||
|  | 				/* b1 - number of block arguments | ||||||
|  | 				 * b2 - number of block temporaries */ | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b1); | ||||||
|  | 				FETCH_PARAM_CODE_TO (stix, b2); | ||||||
|  |  | ||||||
|  | 				DECODE_OUT_2 ("make_block %d %d", (int)b1, (int)b2); | ||||||
|  |  | ||||||
|  | 				STIX_ASSERT (b1 >= 0); | ||||||
|  | 				STIX_ASSERT (b2 >= b1); | ||||||
|  | 				break; | ||||||
|  | 			 | ||||||
|  |  | ||||||
|  | 			case BCODE_SEND_BLOCK_COPY: | ||||||
|  | 				DECODE_OUT_0 ("send_block_copy"); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			case BCODE_NOOP: | ||||||
|  | 				/* do nothing */ | ||||||
|  | 				DECODE_OUT_0 ("noop"); | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 			default: | ||||||
|  | printf ("UNKNOWN BYTE CODE ENCOUNTERED %x\n", (int)bcode); | ||||||
|  | 				stix->errnum = STIX_EINTERN; | ||||||
|  | 				break; | ||||||
|  |  | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/* print literal frame contents */ | ||||||
|  | 	for (ip = 0; ip < STIX_OBJ_GET_SIZE(mth) - STIX_METHOD_NAMED_INSTVARS; ip++) | ||||||
|  | 	{ | ||||||
|  | 		printf ("  %8lu ", (unsigned long int)ip); | ||||||
|  | 		print_object (stix, mth->slot[ip]); | ||||||
|  | 		printf ("\n"); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return 0; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | int stix_decode (stix_t* stix, stix_oop_method_t mth) | ||||||
|  | { | ||||||
|  | 	return decode (stix, mth); | ||||||
|  | } | ||||||
							
								
								
									
										518
									
								
								stix/lib/exec.c
									
									
									
									
									
								
							
							
						
						
									
										518
									
								
								stix/lib/exec.c
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -98,6 +98,8 @@ struct xtn_t | |||||||
| 	stix_oow_t bchar_len; | 	stix_oow_t bchar_len; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | /* ========================================================================= */ | ||||||
|  |  | ||||||
| static void* sys_alloc (stix_mmgr_t* mmgr, stix_oow_t size) | static void* sys_alloc (stix_mmgr_t* mmgr, stix_oow_t size) | ||||||
| { | { | ||||||
| 	return malloc (size); | 	return malloc (size); | ||||||
| @ -121,8 +123,9 @@ static stix_mmgr_t sys_mmgr = | |||||||
| 	STIX_NULL | 	STIX_NULL | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | /* ========================================================================= */ | ||||||
|  |  | ||||||
| static STIX_INLINE stix_ooi_t open_input (stix_t* stix, stix_io_arg_t* arg) | static STIX_INLINE stix_ooi_t open_input (stix_t* stix, stix_ioarg_t* arg) | ||||||
| { | { | ||||||
| 	if (arg->includer) | 	if (arg->includer) | ||||||
| 	{ | 	{ | ||||||
| @ -165,7 +168,7 @@ static STIX_INLINE stix_ooi_t open_input (stix_t* stix, stix_io_arg_t* arg) | |||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| static STIX_INLINE stix_ooi_t read_input (stix_t* stix, stix_io_arg_t* arg) | static STIX_INLINE stix_ooi_t read_input (stix_t* stix, stix_ioarg_t* arg) | ||||||
| { | { | ||||||
| 	xtn_t* xtn = stix_getxtn(stix); | 	xtn_t* xtn = stix_getxtn(stix); | ||||||
| 	stix_oow_t n, bcslen, ucslen, remlen; | 	stix_oow_t n, bcslen, ucslen, remlen; | ||||||
| @ -198,14 +201,14 @@ static STIX_INLINE stix_ooi_t read_input (stix_t* stix, stix_io_arg_t* arg) | |||||||
| 	return ucslen; | 	return ucslen; | ||||||
| } | } | ||||||
|  |  | ||||||
| static STIX_INLINE stix_ooi_t close_input (stix_t* stix, stix_io_arg_t* arg) | static STIX_INLINE stix_ooi_t close_input (stix_t* stix, stix_ioarg_t* arg) | ||||||
| { | { | ||||||
| 	STIX_ASSERT (arg->handle != STIX_NULL); | 	STIX_ASSERT (arg->handle != STIX_NULL); | ||||||
| 	fclose ((FILE*)arg->handle); | 	fclose ((FILE*)arg->handle); | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| static stix_ooi_t input_handler (stix_t* stix, stix_io_cmd_t cmd, stix_io_arg_t* arg) | static stix_ooi_t input_handler (stix_t* stix, stix_iocmd_t cmd, stix_ioarg_t* arg) | ||||||
| { | { | ||||||
| 	switch (cmd) | 	switch (cmd) | ||||||
| 	{ | 	{ | ||||||
| @ -223,6 +226,7 @@ static stix_ooi_t input_handler (stix_t* stix, stix_io_cmd_t cmd, stix_io_arg_t* | |||||||
| 			return -1; | 			return -1; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | /* ========================================================================= */ | ||||||
|  |  | ||||||
| static void* mod_open (stix_t* stix, const stix_ooch_t* name) | static void* mod_open (stix_t* stix, const stix_ooch_t* name) | ||||||
| { | { | ||||||
| @ -324,6 +328,49 @@ printf ("MOD_GETSYM [%s]\n", &buf[0]); | |||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /* ========================================================================= */ | ||||||
|  |  | ||||||
|  | static void log_write (stix_t* stix, int mask, const stix_ooch_t* msg, stix_oow_t len) | ||||||
|  | { | ||||||
|  | #if defined(_WIN32) | ||||||
|  | #	error NOT IMPLEMENTED  | ||||||
|  | 	 | ||||||
|  | #else | ||||||
|  | 	stix_bch_t buf[10]; | ||||||
|  | 	stix_oow_t ucslen, bcslen, msgidx; | ||||||
|  | 	int n; | ||||||
|  |  | ||||||
|  | 	msgidx = 0; | ||||||
|  |  | ||||||
|  | 	while (1) | ||||||
|  | 	{ | ||||||
|  | 		ucslen = len; | ||||||
|  | 		bcslen = STIX_COUNTOF(buf) - len; | ||||||
|  |  | ||||||
|  | 		n = stix_ucstoutf8 (&msg[msgidx], &ucslen, buf, &bcslen); | ||||||
|  | 		if (n == 0) | ||||||
|  | 		{ | ||||||
|  | 			write (1, buf, bcslen); /*  TODO: write all */ | ||||||
|  | 			break; | ||||||
|  | 		} | ||||||
|  | 		else if (n == -2) | ||||||
|  | 		{ | ||||||
|  | 			STIX_ASSERT (ucslen > 0); /* if this fails, the buffer size must be increased */ | ||||||
|  | 			write (1, buf, bcslen); /* TODO: write all */ | ||||||
|  | 			msgidx += ucslen; | ||||||
|  | 			len -= ucslen; | ||||||
|  | 		} | ||||||
|  | 		else if (n <= -1) | ||||||
|  | 		{ | ||||||
|  | 			/* conversion error */ | ||||||
|  | 			break; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | #endif | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /* ========================================================================= */ | ||||||
|  |  | ||||||
| static char* syntax_error_msg[] =  | static char* syntax_error_msg[] =  | ||||||
| { | { | ||||||
| 	"no error", | 	"no error", | ||||||
| @ -380,12 +427,17 @@ static char* syntax_error_msg[] = | |||||||
| 	"literal expected" | 	"literal expected" | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | /* ========================================================================= */ | ||||||
|  |  | ||||||
| stix_ooch_t str_my_object[] = { 'M', 'y', 'O', 'b','j','e','c','t' }; | stix_ooch_t str_my_object[] = { 'M', 'y', 'O', 'b','j','e','c','t' }; | ||||||
| stix_ooch_t str_main[] = { 'm', 'a', 'i', 'n' }; | stix_ooch_t str_main[] = { 'm', 'a', 'i', 'n' }; | ||||||
|  |  | ||||||
|  |  | ||||||
| stix_t* g_stix = STIX_NULL; | stix_t* g_stix = STIX_NULL; | ||||||
|  |  | ||||||
|  | /* ========================================================================= */ | ||||||
|  |  | ||||||
|  |  | ||||||
| #if defined(__MSDOS__) && defined(_INTELC32_) | #if defined(__MSDOS__) && defined(_INTELC32_) | ||||||
| static void (*prev_timer_intr_handler) (void); | static void (*prev_timer_intr_handler) (void); | ||||||
|  |  | ||||||
| @ -491,6 +543,8 @@ static void cancel_tick (void) | |||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /* ========================================================================= */ | ||||||
|  |  | ||||||
| int main (int argc, char* argv[]) | int main (int argc, char* argv[]) | ||||||
| { | { | ||||||
| 	stix_t* stix; | 	stix_t* stix; | ||||||
| @ -524,6 +578,8 @@ int main (int argc, char* argv[]) | |||||||
| 	vmprim.mod_open = mod_open; | 	vmprim.mod_open = mod_open; | ||||||
| 	vmprim.mod_close = mod_close; | 	vmprim.mod_close = mod_close; | ||||||
| 	vmprim.mod_getsym = mod_getsym; | 	vmprim.mod_getsym = mod_getsym; | ||||||
|  | 	vmprim.log_write = log_write; | ||||||
|  |  | ||||||
|  |  | ||||||
| #if defined(USE_LTDL) | #if defined(USE_LTDL) | ||||||
| 	lt_dlinit (); | 	lt_dlinit (); | ||||||
|  | |||||||
| @ -29,36 +29,17 @@ | |||||||
| #include <stix-utl.h> | #include <stix-utl.h> | ||||||
|  |  | ||||||
| /* ------------------------------------------------------------------------ */ | /* ------------------------------------------------------------------------ */ | ||||||
|  |  | ||||||
| /* TODO: don't use these macros... */ |  | ||||||
| #define ACTIVE_STACK_PUSH(stix,v) \ |  | ||||||
| 	do { \ |  | ||||||
| 		(stix)->sp = (stix)->sp + 1; \ |  | ||||||
| 		(stix)->active_context->slot[(stix)->sp] = v; \ |  | ||||||
| 	} while (0) |  | ||||||
|  |  | ||||||
| #define ACTIVE_STACK_POP(stix) ((stix)->sp = (stix)->sp - 1) |  | ||||||
| #define ACTIVE_STACK_UNPOP(stix) ((stix)->sp = (stix)->sp + 1) |  | ||||||
| #define ACTIVE_STACK_POPS(stix,count) ((stix)->sp = (stix)->sp - (count)) |  | ||||||
|  |  | ||||||
| #define ACTIVE_STACK_GET(stix,v_sp) ((stix)->active_context->slot[v_sp]) |  | ||||||
| #define ACTIVE_STACK_SET(stix,v_sp,v_obj) ((stix)->active_context->slot[v_sp] = v_obj) |  | ||||||
| #define ACTIVE_STACK_GETTOP(stix) ACTIVE_STACK_GET(stix, (stix)->sp) |  | ||||||
| #define ACTIVE_STACK_SETTOP(stix,v_obj) ACTIVE_STACK_SET(stix, (stix)->sp, v_obj) |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| static int prim_open (stix_t* stix, stix_ooi_t nargs) | static int prim_open (stix_t* stix, stix_ooi_t nargs) | ||||||
| { | { | ||||||
| printf ("<<<<<<<<<<<SND OPEN>>>>>>>>>>>>>>>>>>\n"); | printf ("<<<<<<<<<<<SND OPEN>>>>>>>>>>>>>>>>>>\n"); | ||||||
| 	ACTIVE_STACK_POPS (stix, nargs); | 	STIX_STACK_POPS (stix, nargs); | ||||||
| 	return 1; | 	return 1; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int prim_close (stix_t* stix, stix_ooi_t nargs) | static int prim_close (stix_t* stix, stix_ooi_t nargs) | ||||||
| { | { | ||||||
| printf ("<<<<<<<<<<<<<<<<<<<<SND CLOSE>>>>>>>>>>>>>>>>>>>>>>\n"); | printf ("<<<<<<<<<<<<<<<<<<<<SND CLOSE>>>>>>>>>>>>>>>>>>>>>>\n"); | ||||||
| 	ACTIVE_STACK_POPS (stix, nargs); | 	STIX_STACK_POPS (stix, nargs); | ||||||
| 	return 1; | 	return 1; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| /* | /* | ||||||
|  * $Id$ |  * $Id$ | ||||||
|  * |  * | ||||||
|     Copyright (c) 2006-2014 Chung, Hyung-Hwan. All rights reserved. |     Copyright (c) 2006-2016 Chung, Hyung-Hwan. All rights reserved. | ||||||
|  |  | ||||||
|     Redistribution and use in source and binary forms, with or without |     Redistribution and use in source and binary forms, with or without | ||||||
|     modification, are permitted provided that the following conditions |     modification, are permitted provided that the following conditions | ||||||
|  | |||||||
| @ -301,7 +301,7 @@ typedef struct stix_ucs_t stix_ucs_t; | |||||||
| struct stix_bcs_t | struct stix_bcs_t | ||||||
| { | { | ||||||
| 	stix_bch_t* ptr; | 	stix_bch_t* ptr; | ||||||
| 	stix_oow_t len; | 	stix_oow_t  len; | ||||||
| }; | }; | ||||||
| typedef struct stix_bcs_t stix_bcs_t; | typedef struct stix_bcs_t stix_bcs_t; | ||||||
|  |  | ||||||
|  | |||||||
| @ -44,14 +44,6 @@ | |||||||
|  * PUSH_CONTEXT, PUSH_INTLIT, PUSH_INTLIT, SEND_BLOCK_COPY */ |  * PUSH_CONTEXT, PUSH_INTLIT, PUSH_INTLIT, SEND_BLOCK_COPY */ | ||||||
| #define STIX_USE_MAKE_BLOCK | #define STIX_USE_MAKE_BLOCK | ||||||
|  |  | ||||||
| /* define this to allow an pointer(OOP) object to have trailing bytes  |  | ||||||
|  * this is used to embed bytes codes into the back of a compile method |  | ||||||
|  * object instead of putting in in a separate byte array. */ |  | ||||||
| #define STIX_USE_OBJECT_TRAILER |  | ||||||
|  |  | ||||||
| /* define this to use the stack allocated inside process stack */ |  | ||||||
| #define STIX_USE_PROCSTK |  | ||||||
|  |  | ||||||
| /* this is for gc debugging */ | /* this is for gc debugging */ | ||||||
| /*#define STIX_DEBUG_PROCESSOR*/ | /*#define STIX_DEBUG_PROCESSOR*/ | ||||||
| /*#define STIX_DEBUG_GC_001*/ | /*#define STIX_DEBUG_GC_001*/ | ||||||
| @ -244,38 +236,38 @@ | |||||||
| /* SOURCE CODE I/O FOR COMPILER                                              */ | /* SOURCE CODE I/O FOR COMPILER                                              */ | ||||||
| /* ========================================================================= */ | /* ========================================================================= */ | ||||||
|  |  | ||||||
| enum stix_io_cmd_t | enum stix_iocmd_t | ||||||
| { | { | ||||||
| 	STIX_IO_OPEN, | 	STIX_IO_OPEN, | ||||||
| 	STIX_IO_CLOSE, | 	STIX_IO_CLOSE, | ||||||
| 	STIX_IO_READ | 	STIX_IO_READ | ||||||
| }; | }; | ||||||
| typedef enum stix_io_cmd_t stix_io_cmd_t; | typedef enum stix_iocmd_t stix_iocmd_t; | ||||||
|  |  | ||||||
| struct stix_ioloc_t | struct stix_ioloc_t | ||||||
| { | { | ||||||
| 	unsigned long     line; /**< line */ | 	unsigned long      line; /**< line */ | ||||||
| 	unsigned long     colm; /**< column */ | 	unsigned long      colm; /**< column */ | ||||||
| 	const stix_ooch_t* file; /**< file specified in #include */ | 	const stix_ooch_t* file; /**< file specified in #include */ | ||||||
| }; | }; | ||||||
| typedef struct stix_ioloc_t stix_ioloc_t; | typedef struct stix_ioloc_t stix_ioloc_t; | ||||||
|  |  | ||||||
| struct stix_iolxc_t | struct stix_iolxc_t | ||||||
| { | { | ||||||
| 	stix_ooci_t    c; /**< character */ | 	stix_ooci_t   c; /**< character */ | ||||||
| 	stix_ioloc_t  l; /**< location */ | 	stix_ioloc_t  l; /**< location */ | ||||||
| }; | }; | ||||||
| typedef struct stix_iolxc_t stix_iolxc_t; | typedef struct stix_iolxc_t stix_iolxc_t; | ||||||
|  |  | ||||||
| /* | /* | ||||||
| enum stix_io_arg_flag_t | enum stix_ioarg_flag_t | ||||||
| { | { | ||||||
| 	STIX_IO_INCLUDED = (1 << 0) | 	STIX_IO_INCLUDED = (1 << 0) | ||||||
| }; | }; | ||||||
| typedef enum stix_io_arg_flag_t stix_io_arg_flag_t; */ | typedef enum stix_ioarg_flag_t stix_ioarg_flag_t; */ | ||||||
|  |  | ||||||
| typedef struct stix_io_arg_t stix_io_arg_t; | typedef struct stix_ioarg_t stix_ioarg_t; | ||||||
| struct stix_io_arg_t | struct stix_ioarg_t | ||||||
| { | { | ||||||
| 	/**  | 	/**  | ||||||
| 	 * [IN] I/O object name. | 	 * [IN] I/O object name. | ||||||
| @ -285,7 +277,8 @@ struct stix_io_arg_t | |||||||
| 	const stix_ooch_t* name;    | 	const stix_ooch_t* name;    | ||||||
|  |  | ||||||
| 	/**  | 	/**  | ||||||
| 	 * [OUT] I/O handle set by a handler.  | 	 * [OUT] I/O handle set by an open handler.  | ||||||
|  | 	 * [IN] I/O handle referenced in read and close handler. | ||||||
| 	 * The source stream handler can set this field when it opens a stream. | 	 * The source stream handler can set this field when it opens a stream. | ||||||
| 	 * All subsequent operations on the stream see this field as set | 	 * All subsequent operations on the stream see this field as set | ||||||
| 	 * during opening. | 	 * during opening. | ||||||
| @ -301,7 +294,7 @@ struct stix_io_arg_t | |||||||
| 	 * [IN] points to the data of the includer. It is #STIX_NULL for the | 	 * [IN] points to the data of the includer. It is #STIX_NULL for the | ||||||
| 	 * main stream. | 	 * main stream. | ||||||
| 	 */ | 	 */ | ||||||
| 	stix_io_arg_t* includer; | 	stix_ioarg_t* includer; | ||||||
|  |  | ||||||
| 	/*-----------------------------------------------------------------*/ | 	/*-----------------------------------------------------------------*/ | ||||||
| 	/*----------- from here down, internal use only -------------------*/ | 	/*----------- from here down, internal use only -------------------*/ | ||||||
| @ -317,10 +310,10 @@ struct stix_io_arg_t | |||||||
| 	/*-----------------------------------------------------------------*/ | 	/*-----------------------------------------------------------------*/ | ||||||
| }; | }; | ||||||
|  |  | ||||||
| typedef stix_ooi_t (*stix_io_impl_t) ( | typedef stix_ooi_t (*stix_ioimpl_t) ( | ||||||
| 	stix_t*       stix, | 	stix_t*       stix, | ||||||
| 	stix_io_cmd_t  cmd, | 	stix_iocmd_t  cmd, | ||||||
| 	stix_io_arg_t* arg | 	stix_ioarg_t* arg | ||||||
| ); | ); | ||||||
|  |  | ||||||
| struct stix_iotok_t | struct stix_iotok_t | ||||||
| @ -447,7 +440,7 @@ typedef struct stix_code_t stix_code_t; | |||||||
| struct stix_compiler_t | struct stix_compiler_t | ||||||
| { | { | ||||||
| 	/* input handler */ | 	/* input handler */ | ||||||
| 	stix_io_impl_t impl; | 	stix_ioimpl_t impl; | ||||||
|  |  | ||||||
| 	/* information about the last meaningful character read. | 	/* information about the last meaningful character read. | ||||||
| 	 * this is a copy of curinp->lxc if no ungetting is performed. | 	 * this is a copy of curinp->lxc if no ungetting is performed. | ||||||
| @ -461,10 +454,10 @@ struct stix_compiler_t | |||||||
| 	int           nungots; | 	int           nungots; | ||||||
|  |  | ||||||
| 	/* static input data buffer */ | 	/* static input data buffer */ | ||||||
| 	stix_io_arg_t  arg;     | 	stix_ioarg_t  arg;     | ||||||
|  |  | ||||||
| 	/* pointer to the current input data. initially, it points to &arg */ | 	/* pointer to the current input data. initially, it points to &arg */ | ||||||
| 	stix_io_arg_t* curinp; | 	stix_ioarg_t* curinp; | ||||||
|  |  | ||||||
| 	/* the last token read */ | 	/* the last token read */ | ||||||
| 	stix_iotok_t  tok; | 	stix_iotok_t  tok; | ||||||
| @ -1080,6 +1073,35 @@ stix_oow_t stix_utf8touc ( | |||||||
| 	stix_uch_t*       uc | 	stix_uch_t*       uc | ||||||
| ); | ); | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * The stix_ucstoutf8() function converts a unicode character string \a ucs  | ||||||
|  |  * to a UTF8 string and writes it into the buffer pointed to by \a bcs, but | ||||||
|  |  * not more than \a bcslen bytes including the terminating null. | ||||||
|  |  * | ||||||
|  |  * Upon return, \a bcslen is modified to the actual number of bytes written to | ||||||
|  |  * \a bcs excluding the terminating null; \a ucslen is modified to the number of | ||||||
|  |  * wide characters converted. | ||||||
|  |  * | ||||||
|  |  * You may pass #STIX_NULL for \a bcs to dry-run conversion or to get the | ||||||
|  |  * required buffer size for conversion. -2 is never returned in this case. | ||||||
|  |  * | ||||||
|  |  * \return | ||||||
|  |  * - 0 on full conversion, | ||||||
|  |  * - -1 on no or partial conversion for an illegal character encountered, | ||||||
|  |  * - -2 on no or partial conversion for a small buffer. | ||||||
|  |  * | ||||||
|  |  * \code | ||||||
|  |  *   const stix_uch_t ucs[] = { 'H', 'e', 'l', 'l', 'o' }; | ||||||
|  |  *   stix_bch_t bcs[10]; | ||||||
|  |  *   stix_oow_t ucslen = 5; | ||||||
|  |  *   stix_oow_t bcslen = STIX_COUNTOF(bcs); | ||||||
|  |  *   n = stix_ucstoutf8 (ucs, &ucslen, bcs, &bcslen); | ||||||
|  |  *   if (n <= -1) | ||||||
|  |  *   { | ||||||
|  |  *      // conversion error | ||||||
|  |  *   } | ||||||
|  |  * \endcode | ||||||
|  |  */ | ||||||
| int stix_ucstoutf8 ( | int stix_ucstoutf8 ( | ||||||
| 	const stix_uch_t*    ucs, | 	const stix_uch_t*    ucs, | ||||||
| 	stix_oow_t*          ucslen, | 	stix_oow_t*          ucslen, | ||||||
| @ -1261,7 +1283,7 @@ stix_oop_t stix_inttostr ( | |||||||
| /* ========================================================================= */ | /* ========================================================================= */ | ||||||
| STIX_EXPORT int stix_compile ( | STIX_EXPORT int stix_compile ( | ||||||
| 	stix_t*        stix, | 	stix_t*        stix, | ||||||
| 	stix_io_impl_t io | 	stix_ioimpl_t io | ||||||
| ); | ); | ||||||
|  |  | ||||||
| STIX_EXPORT void stix_getsynerr ( | STIX_EXPORT void stix_getsynerr ( | ||||||
|  | |||||||
| @ -252,7 +252,6 @@ int stix_getoption (stix_t* stix, stix_option_t id, void* value) | |||||||
| 	return -1; | 	return -1; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| stix_cb_t* stix_regcb (stix_t* stix, stix_cb_t* tmpl) | stix_cb_t* stix_regcb (stix_t* stix, stix_cb_t* tmpl) | ||||||
| { | { | ||||||
| 	stix_cb_t* actual; | 	stix_cb_t* actual; | ||||||
|  | |||||||
| @ -33,6 +33,13 @@ | |||||||
| /* TODO: move this macro out to the build files.... */ | /* TODO: move this macro out to the build files.... */ | ||||||
| #define STIX_INCLUDE_COMPILER | #define STIX_INCLUDE_COMPILER | ||||||
|  |  | ||||||
|  | /* define this to use the stack allocated inside process stack */ | ||||||
|  | #define STIX_USE_PROCSTK | ||||||
|  |  | ||||||
|  | /* define this to allow an pointer(OOP) object to have trailing bytes  | ||||||
|  |  * this is used to embed bytes codes into the back of a compile method | ||||||
|  |  * object instead of putting in in a separate byte array. */ | ||||||
|  | #define STIX_USE_OBJECT_TRAILER | ||||||
| /* ========================================================================== */ | /* ========================================================================== */ | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @ -454,6 +461,19 @@ struct stix_method_t | |||||||
| 	stix_oop_t       slot[1]; /* it stores literals */ | 	stix_oop_t       slot[1]; /* it stores literals */ | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | #if defined(STIX_USE_OBJECT_TRAILER) | ||||||
|  |  | ||||||
|  | 	/* if m is to be type-cast to stix_oop_method_t, the macro must be | ||||||
|  | 	 * redefined to this: | ||||||
|  | 	 *   (&((stix_oop_method_t)m)>slot[STIX_OBJ_GET_SIZE(m) + 1 - STIX_METHOD_NAMED_INSTVARS]) | ||||||
|  | 	 */ | ||||||
|  | #	define STIX_METHOD_GET_CODE_BYTE(m) ((stix_oob_t*)&((stix_oop_oop_t)m)->slot[STIX_OBJ_GET_SIZE(m) + 1]) | ||||||
|  | #	define STIX_METHOD_GET_CODE_SIZE(m) ((stix_oow_t)((stix_oop_oop_t)m)->slot[STIX_OBJ_GET_SIZE(m)]) | ||||||
|  | #else | ||||||
|  | #	define STIX_METHOD_GET_CODE_BYTE(m) ((m)->code->slot) | ||||||
|  | #	define STIX_METHOD_GET_CODE_SIZE(m) STIX_OBJ_GET_SIZE((m)->code) | ||||||
|  | #endif | ||||||
|  |  | ||||||
| /* The preamble field is composed of a 8-bit code and a 16-bit | /* The preamble field is composed of a 8-bit code and a 16-bit | ||||||
|  * index.  |  * index.  | ||||||
|  * |  * | ||||||
| @ -489,7 +509,7 @@ struct stix_method_t | |||||||
| /* the index is an 16-bit unsigned integer. */ | /* the index is an 16-bit unsigned integer. */ | ||||||
| #define STIX_METHOD_PREAMBLE_INDEX_MIN 0x0000 | #define STIX_METHOD_PREAMBLE_INDEX_MIN 0x0000 | ||||||
| #define STIX_METHOD_PREAMBLE_INDEX_MAX 0xFFFF | #define STIX_METHOD_PREAMBLE_INDEX_MAX 0xFFFF | ||||||
| #define STIX_OOI_IN_PREAMBLE_INDEX_RANGE(num) ((num) >= STIX_METHOD_PREAMBLE_INDEX_MIN && (num) <= STIX_METHOD_PREAMBLE_INDEX_MAX) | #define STIX_OOI_IN_METHOD_PREAMBLE_INDEX_RANGE(num) ((num) >= STIX_METHOD_PREAMBLE_INDEX_MIN && (num) <= STIX_METHOD_PREAMBLE_INDEX_MAX) | ||||||
|  |  | ||||||
| #define STIX_CONTEXT_NAMED_INSTVARS 8 | #define STIX_CONTEXT_NAMED_INSTVARS 8 | ||||||
| typedef struct stix_context_t stix_context_t; | typedef struct stix_context_t stix_context_t; | ||||||
| @ -637,15 +657,18 @@ typedef struct stix_t stix_t; | |||||||
|  * ========================================================================= */ |  * ========================================================================= */ | ||||||
| #define STIX_MOD_NAME_LEN_MAX 120 | #define STIX_MOD_NAME_LEN_MAX 120 | ||||||
|  |  | ||||||
| typedef void* (*stix_mod_open_t) (stix_t* stix, const stix_uch_t* name); | typedef void* (*stix_mod_open_t) (stix_t* stix, const stix_ooch_t* name); | ||||||
| typedef void (*stix_mod_close_t) (stix_t* stix, void* handle); | typedef void (*stix_mod_close_t) (stix_t* stix, void* handle); | ||||||
| typedef void* (*stix_mod_getsym_t) (stix_t* stix, void* handle, const stix_uch_t* name); | typedef void* (*stix_mod_getsym_t) (stix_t* stix, void* handle, const stix_ooch_t* name); | ||||||
|  |  | ||||||
|  | typedef void (*stix_log_write_t) (stix_t* stix, int mask, const stix_ooch_t* msg, stix_oow_t len); | ||||||
|  |  | ||||||
| struct stix_vmprim_t | struct stix_vmprim_t | ||||||
| { | { | ||||||
| 	stix_mod_open_t mod_open; | 	stix_mod_open_t mod_open; | ||||||
| 	stix_mod_close_t mod_close; | 	stix_mod_close_t mod_close; | ||||||
| 	stix_mod_getsym_t mod_getsym; | 	stix_mod_getsym_t mod_getsym; | ||||||
|  | 	stix_log_write_t log_write; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| typedef struct stix_vmprim_t stix_vmprim_t; | typedef struct stix_vmprim_t stix_vmprim_t; | ||||||
| @ -654,18 +677,18 @@ typedef struct stix_vmprim_t stix_vmprim_t; | |||||||
|  * IO MANIPULATION |  * IO MANIPULATION | ||||||
|  * ========================================================================= */ |  * ========================================================================= */ | ||||||
|  |  | ||||||
| /* TODO: MOVE stix_io_impl_t HERE */ | /* TODO: MOVE stix_ioimpl_t HERE */ | ||||||
|  |  | ||||||
| /* ========================================================================= | /* ========================================================================= | ||||||
|  * CALLBACK MANIPULATION |  * CALLBACK MANIPULATION | ||||||
|  * ========================================================================= */ |  * ========================================================================= */ | ||||||
| typedef void (*stix_cb_impl_t) (stix_t* stix); | typedef void (*stix_cbimpl_t) (stix_t* stix); | ||||||
|  |  | ||||||
| typedef struct stix_cb_t stix_cb_t; | typedef struct stix_cb_t stix_cb_t; | ||||||
| struct stix_cb_t | struct stix_cb_t | ||||||
| { | { | ||||||
| 	stix_cb_impl_t gc; | 	stix_cbimpl_t gc; | ||||||
| 	stix_cb_impl_t fini; | 	stix_cbimpl_t fini; | ||||||
|  |  | ||||||
| 	/* private below */ | 	/* private below */ | ||||||
| 	stix_cb_t*     prev; | 	stix_cb_t*     prev; | ||||||
| @ -821,6 +844,37 @@ struct stix_t | |||||||
| #endif | #endif | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #if defined(STIX_USE_PROCSTK) | ||||||
|  | /* TODO: stack bound check when pushing */ | ||||||
|  | 	#define STIX_STACK_PUSH(stix,v) \ | ||||||
|  | 		do { \ | ||||||
|  | 			(stix)->sp = (stix)->sp + 1; \ | ||||||
|  | 			(stix)->processor->active->slot[(stix)->sp] = v; \ | ||||||
|  | 		} while (0) | ||||||
|  |  | ||||||
|  | 	#define STIX_STACK_GET(stix,v_sp) ((stix)->processor->active->slot[v_sp]) | ||||||
|  | 	#define STIX_STACK_SET(stix,v_sp,v_obj) ((stix)->processor->active->slot[v_sp] = v_obj) | ||||||
|  |  | ||||||
|  | #else | ||||||
|  | 	#define STIX_STACK_PUSH(stix,v) \ | ||||||
|  | 		do { \ | ||||||
|  | 			(stix)->sp = (stix)->sp + 1; \ | ||||||
|  | 			(stix)->active_context->slot[(stix)->sp] = v; \ | ||||||
|  | 		} while (0) | ||||||
|  |  | ||||||
|  | 	#define STIX_STACK_GET(stix,v_sp) ((stix)->active_context->slot[v_sp]) | ||||||
|  | 	#define STIX_STACK_SET(stix,v_sp,v_obj) ((stix)->active_context->slot[v_sp] = v_obj) | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #define STIX_STACK_GETTOP(stix) STIX_STACK_GET(stix, (stix)->sp) | ||||||
|  | #define STIX_STACK_SETTOP(stix,v_obj) STIX_STACK_SET(stix, (stix)->sp, v_obj) | ||||||
|  |  | ||||||
|  | #define STIX_STACK_POP(stix) ((stix)->sp = (stix)->sp - 1) | ||||||
|  | #define STIX_STACK_POPS(stix,count) ((stix)->sp = (stix)->sp - (count)) | ||||||
|  | #define STIX_STACK_ISEMPTY(stix) ((stix)->sp <= -1) | ||||||
|  |  | ||||||
| #if defined(__cplusplus) | #if defined(__cplusplus) | ||||||
| extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
| @ -978,6 +1032,10 @@ STIX_EXPORT void stix_poptmps ( | |||||||
| 	stix_oow_t  count | 	stix_oow_t  count | ||||||
| ); | ); | ||||||
|  |  | ||||||
|  | STIX_EXPORT int stix_decode ( | ||||||
|  | 	stix_t*           stix, | ||||||
|  | 	stix_oop_method_t mth | ||||||
|  | ); | ||||||
|  |  | ||||||
| /* Memory allocation/deallocation functions using stix's MMGR */ | /* Memory allocation/deallocation functions using stix's MMGR */ | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user