diff --git a/qse/cmd/Makefile.am b/qse/cmd/Makefile.am index a9d359ca..fc102a6c 100644 --- a/qse/cmd/Makefile.am +++ b/qse/cmd/Makefile.am @@ -1,2 +1,2 @@ -SUBDIRS = awk cut sed scm +SUBDIRS = awk cut sed stx DIST_SUBDIRS = $(SUBDIRS) diff --git a/qse/cmd/Makefile.in b/qse/cmd/Makefile.in index 3e680825..8abaf818 100644 --- a/qse/cmd/Makefile.in +++ b/qse/cmd/Makefile.in @@ -225,7 +225,7 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -SUBDIRS = awk cut sed scm +SUBDIRS = awk cut sed stx DIST_SUBDIRS = $(SUBDIRS) all: all-recursive diff --git a/qse/cmd/stx/Makefile.am b/qse/cmd/stx/Makefile.am new file mode 100644 index 00000000..3bfec365 --- /dev/null +++ b/qse/cmd/stx/Makefile.am @@ -0,0 +1,13 @@ +AUTOMAKE_OPTIONS = nostdinc + +AM_CPPFLAGS = \ + -I$(top_builddir)/include \ + -I$(top_srcdir)/include \ + -I$(includedir) + +bin_PROGRAMS = qsestx + +qsestx_SOURCES = stx.c +qsestx_LDFLAGS = -L../../lib/stx -L$(libdir) +qsestx_LDADD = -lqsestx $(LIBM) + diff --git a/qse/cmd/stx/Makefile.in b/qse/cmd/stx/Makefile.in index 2d18d282..42f00f8e 100644 --- a/qse/cmd/stx/Makefile.in +++ b/qse/cmd/stx/Makefile.in @@ -1,19 +1,543 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +bin_PROGRAMS = qsestx$(EXEEXT) +subdir = cmd/stx +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/qse/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +PROGRAMS = $(bin_PROGRAMS) +am_qsestx_OBJECTS = stx.$(OBJEXT) +qsestx_OBJECTS = $(am_qsestx_OBJECTS) +am__DEPENDENCIES_1 = +qsestx_DEPENDENCIES = $(am__DEPENDENCIES_1) +qsestx_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(qsestx_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = +depcomp = $(SHELL) $(top_srcdir)/ac/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(qsestx_SOURCES) +DIST_SOURCES = $(qsestx_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUILD_MODE = @BUILD_MODE@ CC = @CC@ -CFLAGS = @CFLAGS@ -I@abs_top_builddir@ -LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/xp/bas -L@abs_top_builddir@/xp/stx -LIBS = @LIBS@ -lxpstx -lxpbas +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CHAR_MODE = @CHAR_MODE@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +HAVE_CXX = @HAVE_CXX@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBM = @LIBM@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +QSE_PROJECT_AUTHOR = @QSE_PROJECT_AUTHOR@ +QSE_PROJECT_URL = @QSE_PROJECT_URL@ +QSE_SIZEOF_CHAR = @QSE_SIZEOF_CHAR@ +QSE_SIZEOF_DOUBLE = @QSE_SIZEOF_DOUBLE@ +QSE_SIZEOF_FLOAT = @QSE_SIZEOF_FLOAT@ +QSE_SIZEOF_INT = @QSE_SIZEOF_INT@ +QSE_SIZEOF_LONG = @QSE_SIZEOF_LONG@ +QSE_SIZEOF_LONG_DOUBLE = @QSE_SIZEOF_LONG_DOUBLE@ +QSE_SIZEOF_LONG_LONG = @QSE_SIZEOF_LONG_LONG@ +QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ +QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ +QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +RANLIB = @RANLIB@ +RM = @RM@ +RMDIR = @RMDIR@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TRUE = @TRUE@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = nostdinc +AM_CPPFLAGS = \ + -I$(top_builddir)/include \ + -I$(top_srcdir)/include \ + -I$(includedir) -all: stx parser +qsestx_SOURCES = stx.c +qsestx_LDFLAGS = -L../../lib/stx -L$(libdir) +qsestx_LDADD = -lqsestx $(LIBM) +all: all-am -stx: stx.o - $(CC) $(LDFLAGS) -o $@.x stx.o $(LIBS) +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign cmd/stx/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign cmd/stx/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; -parser: parser.o - $(CC) $(LDFLAGS) -o $@.x parser.o $(LIBS) +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -clean: - rm -rf *.x *.o +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +qsestx$(EXEEXT): $(qsestx_OBJECTS) $(qsestx_DEPENDENCIES) + @rm -f qsestx$(EXEEXT) + $(qsestx_LINK) $(qsestx_OBJECTS) $(qsestx_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stx.Po@am__quote@ -.SUFFIXES: .c .o .c.o: - $(CC) $(CFLAGS) -c $< +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-binPROGRAMS + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/qse/cmd/stx/stx.c b/qse/cmd/stx/stx.c index 276d1c28..fb2bc16e 100644 --- a/qse/cmd/stx/stx.c +++ b/qse/cmd/stx/stx.c @@ -1,113 +1,110 @@ -#include +#include +#include +#include -#ifdef _DOS - #include - #define xp_printf printf -#else - #include - #include +#if 0 +#include +#include +#include +#include +#include +#include #endif -#include -#include -#include -#include -#include -#include - -void print_symbol_names (xp_stx_t* stx, xp_word_t sym, void* unused) +#if 0 +void print_symbol_names (qse_stx_t* stx, qse_word_t sym, void* unused) { - xp_printf (XP_TEXT("%lu [%s]\n"), (unsigned long)sym, XP_STX_DATA(stx,sym)); + qse_printf (QSE_T("%lu [%s]\n"), (unsigned long)sym, QSE_STX_DATA(stx,sym)); } -void print_symbol_names_2 (xp_stx_t* stx, xp_word_t idx, void* unused) +void print_symbol_names_2 (qse_stx_t* stx, qse_word_t idx, void* unused) { - xp_word_t key = XP_STX_WORD_AT(stx,idx,XP_STX_ASSOCIATION_KEY); - xp_word_t value = XP_STX_WORD_AT(stx,idx,XP_STX_ASSOCIATION_VALUE); - xp_printf (XP_TEXT("%lu [%s] %lu\n"), - (unsigned long)key, XP_STX_DATA(stx,key), (unsigned long)value); + qse_word_t key = QSE_STX_WORD_AT(stx,idx,QSE_STX_ASSOCIATION_KEY); + qse_word_t value = QSE_STX_WORD_AT(stx,idx,QSE_STX_ASSOCIATION_VALUE); + qse_printf (QSE_T("%lu [%s] %lu\n"), + (unsigned long)key, QSE_STX_DATA(stx,key), (unsigned long)value); } -void print_superclasses (xp_stx_t* stx, const xp_char_t* name) +void print_superclasses (qse_stx_t* stx, const qse_char_t* name) { - xp_word_t n; - xp_stx_class_t* obj; + qse_word_t n; + qse_stx_class_t* obj; - n = xp_stx_lookup_class (stx, name); - xp_printf (XP_TEXT("Class hierarchy for the class '%s'\n"), name); + n = qse_stx_lookup_class (stx, name); + qse_printf (QSE_T("Class hierarchy for the class '%s'\n"), name); while (n != stx->nil) { - obj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx,n); - xp_printf (XP_TEXT("%lu, %s\n"), + obj = (qse_stx_class_t*)QSE_STX_WORD_OBJECT(stx,n); + qse_printf (QSE_T("%lu, %s\n"), (unsigned long)obj->name, - XP_STX_DATA(stx, obj->name)); + QSE_STX_DATA(stx, obj->name)); n = obj->superclass; } } -void print_metaclass_superclasses (xp_stx_t* stx, const xp_char_t* name) +void print_metaclass_superclasses (qse_stx_t* stx, const qse_char_t* name) { - xp_word_t n, x; - xp_stx_metaclass_t* obj; - xp_stx_class_t* xobj; + qse_word_t n, x; + qse_stx_metaclass_t* obj; + qse_stx_class_t* xobj; - n = xp_stx_lookup_class (stx, name); - n = XP_STX_CLASS(stx,n); - xp_printf (XP_TEXT("Class hierarchy for the metaclass '%s class'\n"), name); + n = qse_stx_lookup_class (stx, name); + n = QSE_STX_CLASS(stx,n); + qse_printf (QSE_T("Class hierarchy for the metaclass '%s class'\n"), name); while (n != stx->nil) { /*if (n == stx->class_class) break; */ - if (XP_STX_CLASS(stx,n) != stx->class_metaclass) break; + if (QSE_STX_CLASS(stx,n) != stx->class_metaclass) break; - obj = (xp_stx_metaclass_t*)XP_STX_WORD_OBJECT(stx,n); + obj = (qse_stx_metaclass_t*)QSE_STX_WORD_OBJECT(stx,n); x = obj->instance_class; - xobj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx,x); - xp_printf (XP_TEXT("%lu, %s class\n"), + xobj = (qse_stx_class_t*)QSE_STX_WORD_OBJECT(stx,x); + qse_printf (QSE_T("%lu, %s class\n"), (unsigned long)xobj->name, - XP_STX_DATA(stx, xobj->name)); + QSE_STX_DATA(stx, xobj->name)); n = obj->superclass; } while (n != stx->nil) { - xobj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx,n); - xp_printf (XP_TEXT("%lu, %s\n"), + xobj = (qse_stx_class_t*)QSE_STX_WORD_OBJECT(stx,n); + qse_printf (QSE_T("%lu, %s\n"), (unsigned long)xobj->name, - XP_STX_DATA(stx, xobj->name)); + QSE_STX_DATA(stx, xobj->name)); n = xobj->superclass; } } -void print_class_name (xp_stx_t* stx, xp_word_t class, int tabs) +void print_class_name (qse_stx_t* stx, qse_word_t class, int tabs) { - xp_stx_class_t* xobj; - xobj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx,class); + qse_stx_class_t* xobj; + xobj = (qse_stx_class_t*)QSE_STX_WORD_OBJECT(stx,class); - while (tabs-- > 0) xp_printf (XP_TEXT(" ")); + while (tabs-- > 0) qse_printf (QSE_T(" ")); - xp_printf (XP_TEXT("%s [%lu]\n"), - XP_STX_DATA(stx, xobj->name), + qse_printf (QSE_T("%s [%lu]\n"), + QSE_STX_DATA(stx, xobj->name), (unsigned long)class); } -void print_metaclass_name (xp_stx_t* stx, xp_word_t class, int tabs) +void print_metaclass_name (qse_stx_t* stx, qse_word_t class, int tabs) { - xp_stx_metaclass_t* obj; - xp_stx_class_t* xobj; + qse_stx_metaclass_t* obj; + qse_stx_class_t* xobj; - obj = (xp_stx_metaclass_t*)XP_STX_WORD_OBJECT(stx,class); - xobj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx,obj->instance_class); + obj = (qse_stx_metaclass_t*)QSE_STX_WORD_OBJECT(stx,class); + xobj = (qse_stx_class_t*)QSE_STX_WORD_OBJECT(stx,obj->instance_class); - while (tabs-- > 0) xp_printf (XP_TEXT(" ")); + while (tabs-- > 0) qse_printf (QSE_T(" ")); - xp_printf (XP_TEXT("%s class [%lu]\n"), - XP_STX_DATA(stx, xobj->name), + qse_printf (QSE_T("%s class [%lu]\n"), + QSE_STX_DATA(stx, xobj->name), (unsigned long)class); } -void print_subclass_names (xp_stx_t* stx, xp_word_t class, int tabs) +void print_subclass_names (qse_stx_t* stx, qse_word_t class, int tabs) { - xp_stx_class_t* obj; + qse_stx_class_t* obj; - obj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx,class); + obj = (qse_stx_class_t*)QSE_STX_WORD_OBJECT(stx,class); if (obj->header.class == stx->class_metaclass) { print_metaclass_name (stx, class, tabs); } @@ -116,122 +113,143 @@ void print_subclass_names (xp_stx_t* stx, xp_word_t class, int tabs) } if (obj->subclasses != stx->nil) { - xp_word_t count = XP_STX_SIZE(stx, obj->subclasses); + qse_word_t count = QSE_STX_SIZE(stx, obj->subclasses); while (count-- > 0) { print_subclass_names (stx, - XP_STX_WORD_AT(stx,obj->subclasses,count), tabs + 1); + QSE_STX_WORD_AT(stx,obj->subclasses,count), tabs + 1); } } } -void print_subclasses (xp_stx_t* stx, const xp_char_t* name) +void print_subclasses (qse_stx_t* stx, const qse_char_t* name) { - xp_word_t class; - class = xp_stx_lookup_class (stx, name); - xp_printf (XP_TEXT("== NORMAL == \n")); + qse_word_t class; + class = qse_stx_lookup_class (stx, name); + qse_printf (QSE_T("== NORMAL == \n")); print_subclass_names (stx, class, 0); - xp_printf (XP_TEXT("== META == \n")); - print_subclass_names (stx, XP_STX_CLASS(stx,class), 0); + qse_printf (QSE_T("== META == \n")); + print_subclass_names (stx, QSE_STX_CLASS(stx,class), 0); } -int xp_main (int argc, xp_char_t* argv[]) +static int stx_main (int argc, qse_char_t* argv[]) { - xp_stx_t stx; - //xp_word_t i; + qse_stx_t stx; + //qse_word_t i; #ifndef _DOS - if (xp_setlocale () == -1) { + if (qse_setlocale () == -1) { printf ("cannot set locale\n"); return -1; } #endif if (argc != 2) { /* TODO: argument processing */ - xp_printf (XP_TEXT("Usage: %s [-f imageFile] MainClass\n"), argv[0]); + qse_printf (QSE_T("Usage: %s [-f imageFile] MainClass\n"), argv[0]); return -1; } - if (xp_stx_open (&stx, 10000) == XP_NULL) { - xp_printf (XP_TEXT("cannot open stx\n")); + if (qse_stx_open (&stx, 10000) == QSE_NULL) { + qse_printf (QSE_T("cannot open stx\n")); return -1; } - if (xp_stx_bootstrap(&stx) == -1) { - xp_stx_close (&stx); - xp_printf (XP_TEXT("cannot bootstrap\n")); + if (qse_stx_bootstrap(&stx) == -1) { + qse_stx_close (&stx); + qse_printf (QSE_T("cannot bootstrap\n")); return -1; } - xp_printf (XP_TEXT("stx.nil %lu\n"), (unsigned long)stx.nil); - xp_printf (XP_TEXT("stx.true %lu\n"), (unsigned long)stx.true); - xp_printf (XP_TEXT("stx.false %lu\n"), (unsigned long)stx.false); - xp_printf (XP_TEXT("-------------\n")); + qse_printf (QSE_T("stx.nil %lu\n"), (unsigned long)stx.nil); + qse_printf (QSE_T("stx.true %lu\n"), (unsigned long)stx.true); + qse_printf (QSE_T("stx.false %lu\n"), (unsigned long)stx.false); + qse_printf (QSE_T("-------------\n")); - xp_printf (XP_TEXT(">> SYMBOL_TABLE (%u/%u symbols/slots) <<\n"), + qse_printf (QSE_T(">> SYMBOL_TABLE (%u/%u symbols/slots) <<\n"), (unsigned int)stx.symtab.size, (unsigned int)stx.symtab.capacity); - xp_stx_traverse_symbol_table (&stx, print_symbol_names, XP_NULL); - xp_printf (XP_TEXT("-------------\n")); + qse_stx_traverse_symbol_table (&stx, print_symbol_names, QSE_NULL); + qse_printf (QSE_T("-------------\n")); - xp_stx_dict_traverse (&stx, stx.smalltalk, print_symbol_names_2, XP_NULL); - xp_printf (XP_TEXT("-------------\n")); + qse_stx_dict_traverse (&stx, stx.smalltalk, print_symbol_names_2, QSE_NULL); + qse_printf (QSE_T("-------------\n")); - print_superclasses (&stx, XP_TEXT("Array")); - xp_printf (XP_TEXT("-------------\n")); - print_metaclass_superclasses (&stx, XP_TEXT("Array")); - xp_printf (XP_TEXT("-------------\n")); - print_superclasses (&stx, XP_TEXT("False")); - xp_printf (XP_TEXT("-------------\n")); - print_metaclass_superclasses (&stx, XP_TEXT("False")); - xp_printf (XP_TEXT("-------------\n")); - print_superclasses (&stx, XP_TEXT("Metaclass")); - xp_printf (XP_TEXT("-------------\n")); - print_metaclass_superclasses (&stx, XP_TEXT("Metaclass")); - xp_printf (XP_TEXT("-------------\n")); - print_superclasses (&stx, XP_TEXT("Class")); - xp_printf (XP_TEXT("-------------\n")); - print_metaclass_superclasses (&stx, XP_TEXT("Class")); - xp_printf (XP_TEXT("-------------\n")); + print_superclasses (&stx, QSE_T("Array")); + qse_printf (QSE_T("-------------\n")); + print_metaclass_superclasses (&stx, QSE_T("Array")); + qse_printf (QSE_T("-------------\n")); + print_superclasses (&stx, QSE_T("False")); + qse_printf (QSE_T("-------------\n")); + print_metaclass_superclasses (&stx, QSE_T("False")); + qse_printf (QSE_T("-------------\n")); + print_superclasses (&stx, QSE_T("Metaclass")); + qse_printf (QSE_T("-------------\n")); + print_metaclass_superclasses (&stx, QSE_T("Metaclass")); + qse_printf (QSE_T("-------------\n")); + print_superclasses (&stx, QSE_T("Class")); + qse_printf (QSE_T("-------------\n")); + print_metaclass_superclasses (&stx, QSE_T("Class")); + qse_printf (QSE_T("-------------\n")); - print_subclasses (&stx, XP_TEXT("Object")); - xp_printf (XP_TEXT("-------------\n")); + print_subclasses (&stx, QSE_T("Object")); + qse_printf (QSE_T("-------------\n")); #if 0 { - xp_word_t method_name; - xp_word_t main_class; - xp_word_t method, context; + qse_word_t method_name; + qse_word_t main_class; + qse_word_t method, context; - method_name = xp_stx_new_symbol (&stx,XP_TEXT("main")); + method_name = qse_stx_new_symbol (&stx,QSE_T("main")); - main_class = xp_stx_lookup_class (&stx,argv[1]); + main_class = qse_stx_lookup_class (&stx,argv[1]); if (main_class == stx.nil) { - xp_printf (XP_TEXT("non-existent class: %s\n"), argv[1]); + qse_printf (QSE_T("non-existent class: %s\n"), argv[1]); return -1; } /* - method = xp_stx_alloc_byte_object (&stx,100); - XP_STX_CLASS(&stx,method) = stx.class_method; + method = qse_stx_alloc_byte_object (&stx,100); + QSE_STX_CLASS(&stx,method) = stx.class_method; */ - method = xp_stx_instantiate (&stx, XP_TEXT("Method")); + method = qse_stx_instantiate (&stx, QSE_T("Method")); - XP_STX_BYTEAT(&stx,method,0) = PUSH_OBJECT; - XP_STX_BYTEAT(&stx,method,1) = main_class; - XP_STX_BYTEAT(&stx,method,2) = SEND_UNARY_MESSAGE; - XP_STX_BYTEAT(&stx,method,3) = method_name; - XP_STX_BYTEAT(&stx,method,4) = HALT; + QSE_STX_BYTEAT(&stx,method,0) = PUSH_OBJECT; + QSE_STX_BYTEAT(&stx,method,1) = main_class; + QSE_STX_BYTEAT(&stx,method,2) = SEND_UNARY_MESSAGE; + QSE_STX_BYTEAT(&stx,method,3) = method_name; + QSE_STX_BYTEAT(&stx,method,4) = HALT; /* - context = xp_stx_new_context (&stx, method, stx.nil, stx.nil); + context = qse_stx_new_context (&stx, method, stx.nil, stx.nil); */ - context = xp_stx_instantiate (&stx, XP_TEXT("Context")); - xp_stx_run_context (&stx, context); + context = qse_stx_instantiate (&stx, QSE_T("Context")); + qse_stx_run_context (&stx, context); } #endif - xp_stx_close (&stx); - xp_printf (XP_TEXT("== End of program ==\n")); + qse_stx_close (&stx); + qse_printf (QSE_T("== End of program ==\n")); + return 0; +} +#endif + +static int stx_main (int argc, qse_char_t* argv[]) +{ + qse_stx_t* stx; + + stx = qse_stx_open (QSE_NULL, 0, 1000); + if (stx == QSE_NULL) + { + qse_printf (QSE_T("Cannot open stx\n")); + return -1; + } + + qse_stx_close (stx); return 0; } +int qse_main (int argc, qse_achar_t* argv[]) +{ + return qse_runmain (argc, argv, stx_main); +} + diff --git a/qse/configure b/qse/configure index bd45d3cf..b673e3b4 100755 --- a/qse/configure +++ b/qse/configure @@ -16680,7 +16680,7 @@ QSE_PROJECT_AUTHOR="${PACKAGE_BUGREPORT}" QSE_PROJECT_URL="${PACKAGE_URL}" -ac_config_files="$ac_config_files Makefile README include/Makefile include/qse/Makefile include/qse/cmn/Makefile include/qse/awk/Makefile include/qse/cut/Makefile include/qse/sed/Makefile include/qse/scm/Makefile include/qse/http/Makefile lib/Makefile lib/cmn/Makefile lib/awk/Makefile lib/cut/Makefile lib/sed/Makefile lib/scm/Makefile lib/http/Makefile cmd/Makefile cmd/awk/Makefile cmd/cut/Makefile cmd/sed/Makefile cmd/scm/Makefile samples/Makefile samples/cmn/Makefile samples/awk/Makefile samples/cut/Makefile samples/sed/Makefile samples/http/Makefile regress/Makefile regress/awk/Makefile regress/sed/Makefile doc/Makefile doc/page/Makefile doc/Doxyfile" +ac_config_files="$ac_config_files Makefile README include/Makefile include/qse/Makefile include/qse/cmn/Makefile include/qse/awk/Makefile include/qse/cut/Makefile include/qse/sed/Makefile include/qse/stx/Makefile lib/Makefile lib/cmn/Makefile lib/awk/Makefile lib/cut/Makefile lib/sed/Makefile lib/stx/Makefile cmd/Makefile cmd/awk/Makefile cmd/cut/Makefile cmd/sed/Makefile cmd/stx/Makefile samples/Makefile samples/cmn/Makefile samples/awk/Makefile samples/cut/Makefile samples/sed/Makefile regress/Makefile regress/awk/Makefile regress/sed/Makefile doc/Makefile doc/page/Makefile doc/Doxyfile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -17779,26 +17779,23 @@ do "include/qse/awk/Makefile") CONFIG_FILES="$CONFIG_FILES include/qse/awk/Makefile" ;; "include/qse/cut/Makefile") CONFIG_FILES="$CONFIG_FILES include/qse/cut/Makefile" ;; "include/qse/sed/Makefile") CONFIG_FILES="$CONFIG_FILES include/qse/sed/Makefile" ;; - "include/qse/scm/Makefile") CONFIG_FILES="$CONFIG_FILES include/qse/scm/Makefile" ;; - "include/qse/http/Makefile") CONFIG_FILES="$CONFIG_FILES include/qse/http/Makefile" ;; + "include/qse/stx/Makefile") CONFIG_FILES="$CONFIG_FILES include/qse/stx/Makefile" ;; "lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;; "lib/cmn/Makefile") CONFIG_FILES="$CONFIG_FILES lib/cmn/Makefile" ;; "lib/awk/Makefile") CONFIG_FILES="$CONFIG_FILES lib/awk/Makefile" ;; "lib/cut/Makefile") CONFIG_FILES="$CONFIG_FILES lib/cut/Makefile" ;; "lib/sed/Makefile") CONFIG_FILES="$CONFIG_FILES lib/sed/Makefile" ;; - "lib/scm/Makefile") CONFIG_FILES="$CONFIG_FILES lib/scm/Makefile" ;; - "lib/http/Makefile") CONFIG_FILES="$CONFIG_FILES lib/http/Makefile" ;; + "lib/stx/Makefile") CONFIG_FILES="$CONFIG_FILES lib/stx/Makefile" ;; "cmd/Makefile") CONFIG_FILES="$CONFIG_FILES cmd/Makefile" ;; "cmd/awk/Makefile") CONFIG_FILES="$CONFIG_FILES cmd/awk/Makefile" ;; "cmd/cut/Makefile") CONFIG_FILES="$CONFIG_FILES cmd/cut/Makefile" ;; "cmd/sed/Makefile") CONFIG_FILES="$CONFIG_FILES cmd/sed/Makefile" ;; - "cmd/scm/Makefile") CONFIG_FILES="$CONFIG_FILES cmd/scm/Makefile" ;; + "cmd/stx/Makefile") CONFIG_FILES="$CONFIG_FILES cmd/stx/Makefile" ;; "samples/Makefile") CONFIG_FILES="$CONFIG_FILES samples/Makefile" ;; "samples/cmn/Makefile") CONFIG_FILES="$CONFIG_FILES samples/cmn/Makefile" ;; "samples/awk/Makefile") CONFIG_FILES="$CONFIG_FILES samples/awk/Makefile" ;; "samples/cut/Makefile") CONFIG_FILES="$CONFIG_FILES samples/cut/Makefile" ;; "samples/sed/Makefile") CONFIG_FILES="$CONFIG_FILES samples/sed/Makefile" ;; - "samples/http/Makefile") CONFIG_FILES="$CONFIG_FILES samples/http/Makefile" ;; "regress/Makefile") CONFIG_FILES="$CONFIG_FILES regress/Makefile" ;; "regress/awk/Makefile") CONFIG_FILES="$CONFIG_FILES regress/awk/Makefile" ;; "regress/sed/Makefile") CONFIG_FILES="$CONFIG_FILES regress/sed/Makefile" ;; diff --git a/qse/configure.ac b/qse/configure.ac index efb9504e..58a51660 100644 --- a/qse/configure.ac +++ b/qse/configure.ac @@ -235,26 +235,23 @@ AC_CONFIG_FILES([ include/qse/awk/Makefile include/qse/cut/Makefile include/qse/sed/Makefile - include/qse/scm/Makefile - include/qse/http/Makefile + include/qse/stx/Makefile lib/Makefile lib/cmn/Makefile lib/awk/Makefile lib/cut/Makefile lib/sed/Makefile - lib/scm/Makefile - lib/http/Makefile + lib/stx/Makefile cmd/Makefile cmd/awk/Makefile cmd/cut/Makefile cmd/sed/Makefile - cmd/scm/Makefile + cmd/stx/Makefile samples/Makefile samples/cmn/Makefile samples/awk/Makefile samples/cut/Makefile samples/sed/Makefile - samples/http/Makefile regress/Makefile regress/awk/Makefile regress/sed/Makefile diff --git a/qse/doc/page/awk.doc b/qse/doc/page/awk.doc index c8a85e88..ab71f1cd 100644 --- a/qse/doc/page/awk.doc +++ b/qse/doc/page/awk.doc @@ -31,7 +31,7 @@ The code example below demonstrates the steps in C. It executes the one liner BEGIN { print "hello, world" }. @code -/* cc -o hello hello.c -lqsecmn -lqseawk */ +/* cc -o hello hello.c -lqseawk -lqsecmn -lm */ #include #include @@ -80,7 +80,7 @@ Things can get simpler when you use C++ API. Note that the C++ API supports just a single runtime context for each interpreter. @code -/* c++ -o hello hello.cpp -lqsecmn -lqseawk -lqseawkxx */ +/* c++ -o hello hello.cpp -lqseawkxx -lqseawk -lqsecmnxx -lqsecmn -lm */ #include #include diff --git a/qse/include/qse/stx/Makefile.am b/qse/include/qse/stx/Makefile.am new file mode 100644 index 00000000..49a8a01f --- /dev/null +++ b/qse/include/qse/stx/Makefile.am @@ -0,0 +1,2 @@ +pkgincludedir= $(includedir)/qse/stx +pkginclude_HEADERS = stx.h diff --git a/qse/include/qse/stx/Makefile.in b/qse/include/qse/stx/Makefile.in new file mode 100644 index 00000000..493433ff --- /dev/null +++ b/qse/include/qse/stx/Makefile.in @@ -0,0 +1,475 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = include/qse/stx +DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/qse/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +SOURCES = +DIST_SOURCES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__installdirs = "$(DESTDIR)$(pkgincludedir)" +HEADERS = $(pkginclude_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +pkgincludedir = $(includedir)/qse/stx +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUILD_MODE = @BUILD_MODE@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CHAR_MODE = @CHAR_MODE@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +HAVE_CXX = @HAVE_CXX@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBM = @LIBM@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +QSE_PROJECT_AUTHOR = @QSE_PROJECT_AUTHOR@ +QSE_PROJECT_URL = @QSE_PROJECT_URL@ +QSE_SIZEOF_CHAR = @QSE_SIZEOF_CHAR@ +QSE_SIZEOF_DOUBLE = @QSE_SIZEOF_DOUBLE@ +QSE_SIZEOF_FLOAT = @QSE_SIZEOF_FLOAT@ +QSE_SIZEOF_INT = @QSE_SIZEOF_INT@ +QSE_SIZEOF_LONG = @QSE_SIZEOF_LONG@ +QSE_SIZEOF_LONG_DOUBLE = @QSE_SIZEOF_LONG_DOUBLE@ +QSE_SIZEOF_LONG_LONG = @QSE_SIZEOF_LONG_LONG@ +QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ +QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ +QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +RANLIB = @RANLIB@ +RM = @RM@ +RMDIR = @RMDIR@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TRUE = @TRUE@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +pkginclude_HEADERS = stx.h +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/qse/stx/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign include/qse/stx/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-pkgincludeHEADERS: $(pkginclude_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" + @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(pkgincludedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(pkgincludedir)" || exit $$?; \ + done + +uninstall-pkgincludeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + test -n "$$files" || exit 0; \ + echo " ( cd '$(DESTDIR)$(pkgincludedir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(pkgincludedir)" && rm -f $$files + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(pkgincludedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-pkgincludeHEADERS + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-pkgincludeHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool ctags distclean distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-pkgincludeHEADERS install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-pkgincludeHEADERS + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/qse/include/qse/stx/stx.h b/qse/include/qse/stx/stx.h new file mode 100644 index 00000000..752d8278 --- /dev/null +++ b/qse/include/qse/stx/stx.h @@ -0,0 +1,215 @@ +/* + * $Id$ + * + Copyright 2006-2011 Chung, Hyung-Hwan. + This file is part of QSE. + + QSE is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. + + QSE is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with QSE. If not, see . + */ + +#ifndef _QSE_STX_STX_H_ +#define _QSE_STX_STX_H_ + +#include +#include + +/** @file + * The file provides interface to a stx interpreter. + */ + +typedef struct qse_stx_t qse_stx_t; + +/** + * The qse_stx_loc_t defines a structure to store location information. + */ +struct qse_stx_loc_t +{ + const qse_char_t* file; /**< file */ + qse_size_t line; /**< line */ + qse_size_t colm; /**< column */ +}; +typedef struct qse_stx_loc_t qse_stx_loc_t; + +/** + * The qse_stx_io_cmd_t type defines I/O commands. + */ +enum qse_stx_io_cmd_t +{ + QSE_STX_IO_OPEN = 0, + QSE_STX_IO_CLOSE = 1, + QSE_STX_IO_READ = 2, + QSE_STX_IO_WRITE = 3 +}; +typedef enum qse_stx_io_cmd_t qse_stx_io_cmd_t; + +/** + * The qse_stx_io_arg_t type defines a data structure for an I/O handler. + */ +struct qse_stx_io_arg_t +{ + void* handle; + const qse_char_t* path; +}; +typedef struct qse_stx_io_arg_t qse_stx_io_arg_t; + +/** + * The qse_stx_io_fun_t type defines an I/O handler function. + */ +typedef qse_ssize_t (*qse_stx_io_fun_t) ( + qse_stx_t* stx, + qse_stx_io_cmd_t cmd, + qse_stx_io_arg_t* arg, + qse_char_t* data, + qse_size_t count +); + +/** + * The qse_stx_io_t type defines a I/O handler set. + */ +struct qse_stx_io_t +{ + qse_stx_io_fun_t in; + qse_stx_io_fun_t out; +}; +typedef struct qse_stx_io_t qse_stx_io_t; + +/** + * The qse_stx_errnum_t type defines error numbers. + */ +enum qse_stx_errnum_t +{ + QSE_STX_ENOERR, + QSE_STX_ENOMEM, + QSE_STX_EINTERN, + + QSE_STX_EEXIT, + QSE_STX_EEND, + + QSE_STX_EIO, + QSE_STX_EENDSTR, + QSE_STX_ESHARP, + QSE_STX_EDOT, + QSE_STX_ELPAREN, + QSE_STX_ERPAREN, + QSE_STX_ELSTDEEP, + + QSE_STX_EVARBAD, + QSE_STX_EARGBAD, + QSE_STX_EARGFEW, + QSE_STX_EARGMANY, + QSE_STX_EUNDEFFN, + QSE_STX_EBADFN, + QSE_STX_EDUPFML, + QSE_STX_EBADSYM, + QSE_STX_EUNDEFSYM, + QSE_STX_EEMPBDY, + QSE_STX_EVALBAD, + QSE_STX_EDIVBY0 +}; +typedef enum qse_stx_errnum_t qse_stx_errnum_t; + +typedef const qse_char_t* (*qse_stx_errstr_t) ( + qse_stx_t* stx, /**< stx */ + qse_stx_errnum_t num /**< error number */ +); + +#ifdef __cplusplus +extern "C" { +#endif + +QSE_DEFINE_COMMON_FUNCTIONS (stx) + +qse_stx_t* qse_stx_open ( + qse_mmgr_t* mmgr, + qse_size_t xtnsize, + qse_size_t memcapa +); + +void qse_stx_close ( + qse_stx_t* stx /**< stx */ +); + +qse_stx_errstr_t qse_stx_geterrstr ( + qse_stx_t* stx /**< stx */ +); + +void qse_stx_seterrstr ( + qse_stx_t* stx, /**< stx */ + qse_stx_errstr_t errstr /**< an error string getter */ +); + +qse_stx_errnum_t qse_stx_geterrnum ( + qse_stx_t* stx /**< stx */ +); + +const qse_stx_loc_t* qse_stx_geterrloc ( + qse_stx_t* stx /**< stx */ +); + +const qse_char_t* qse_stx_geterrmsg ( + qse_stx_t* stx /**< stx */ +); + +void qse_stx_geterror ( + qse_stx_t* stx, /**< stx */ + qse_stx_errnum_t* errnum, /**< error number */ + const qse_char_t** errmsg, /**< error message */ + qse_stx_loc_t* errloc /**< error location */ +); + +void qse_stx_seterrnum ( + qse_stx_t* stx, /**< stx */ + qse_stx_errnum_t errnum, /**< error number */ + const qse_cstr_t* errarg /**< argument for formatting error message */ +); + +void qse_stx_seterrmsg ( + qse_stx_t* stx, /**< stx */ + qse_stx_errnum_t errnum, /**< error number */ + const qse_char_t* errmsg, /**< error message */ + const qse_stx_loc_t* errloc /**< error location */ +); + +void qse_stx_seterror ( + qse_stx_t* stx, /**< stx */ + qse_stx_errnum_t errnum, /**< error number */ + const qse_cstr_t* errarg, /**< array of arguments for formatting + * an error message */ + const qse_stx_loc_t* errloc /**< error location */ +); + +/** + * The qse_stx_attachio() function attaches I/O handlers. + * Upon attachment, it opens input and output streams by calling + * the I/O handlers with the #QSE_STX_IO_OPEN command. + */ +int qse_stx_attachio ( + qse_stx_t* stx, /**< stx */ + qse_stx_io_t* io /**< I/O handler set */ +); + +/** + * The qse_stx_detachio() function detaches I/O handlers. + * It closes the streams for both input and output by calling the I/O handlers + * with the #QSE_STX_IO_CLOSE command. + */ +void qse_stx_detachio ( + qse_stx_t* stx /**< stx */ +); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/qse/include/qse/types.h b/qse/include/qse/types.h index c55d1123..1999fc9c 100644 --- a/qse/include/qse/types.h +++ b/qse/include/qse/types.h @@ -1,5 +1,5 @@ /* - * $Id: types.h 474 2011-05-23 16:52:37Z hyunghwan.chung $ + * $Id: types.h 487 2011-06-04 16:22:20Z hyunghwan.chung $ * Copyright 2006-2011 Chung, Hyung-Hwan. This file is part of QSE. @@ -78,30 +78,37 @@ typedef enum qse_tri_t qse_tri_t; typedef long qse_int_t; typedef unsigned long qse_uint_t; #define QSE_SIZEOF_INT_T QSE_SIZEOF_LONG + #define QSE_SIZEOF_UINT_T QSE_SIZEOF_LONG #elif defined(__SPU__) && (QSE_SIZEOF_VOID_P == QSE_SIZEOF_LONG) typedef long qse_int_t; typedef unsigned long qse_uint_t; #define QSE_SIZEOF_INT_T QSE_SIZEOF_LONG + #define QSE_SIZEOF_UINT_T QSE_SIZEOF_LONG #elif QSE_SIZEOF_VOID_P == QSE_SIZEOF_INT typedef int qse_int_t; typedef unsigned int qse_uint_t; #define QSE_SIZEOF_INT_T QSE_SIZEOF_INT + #define QSE_SIZEOF_UINT_T QSE_SIZEOF_INT #elif QSE_SIZEOF_VOID_P == QSE_SIZEOF_LONG typedef long qse_int_t; typedef unsigned long qse_uint_t; #define QSE_SIZEOF_INT_T QSE_SIZEOF_LONG + #define QSE_SIZEOF_UINT_T QSE_SIZEOF_LONG #elif QSE_SIZEOF_VOID_P == QSE_SIZEOF_LONG_LONG typedef long long qse_int_t; typedef unsigned long long qse_uint_t; #define QSE_SIZEOF_INT_T QSE_SIZEOF_LONG_LONG + #define QSE_SIZEOF_UINT_T QSE_SIZEOF_LONG_LONG #elif QSE_SIZEOF_VOID_P == QSE_SIZEOF___INT32 typedef __int32 qse_int_t; typedef unsigned __int32 qse_uint_t; #define QSE_SIZEOF_INT_T QSE_SIZEOF___INT32 + #define QSE_SIZEOF_UINT_T QSE_SIZEOF___INT32 #elif QSE_SIZEOF_VOID_P == QSE_SIZEOF___INT64 typedef __int64 qse_int_t; typedef unsigned __int64 qse_uint_t; #define QSE_SIZEOF_INT_T QSE_SIZEOF___INT64 + #define QSE_SIZEOF_UINT_T QSE_SIZEOF___INT64 #else # error unsupported pointer size #endif @@ -116,18 +123,22 @@ typedef enum qse_tri_t qse_tri_t; typedef long qse_long_t; typedef unsigned long qse_ulong_t; #define QSE_SIZEOF_LONG_T QSE_SIZEOF_LONG + #define QSE_SIZEOF_ULONG_T QSE_SIZEOF_LONG #elif QSE_SIZEOF_LONG_LONG > 0 typedef long long qse_long_t; typedef unsigned long long qse_ulong_t; #define QSE_SIZEOF_LONG_T QSE_SIZEOF_LONG_LONG + #define QSE_SIZEOF_ULONG_T QSE_SIZEOF_LONG_LONG #elif QSE_SIZEOF___INT64 > 0 typedef __int64 qse_long_t; typedef unsigned __int64 qse_ulong_t; #define QSE_SIZEOF_LONG_T QSE_SIZEOF___INT64 + #define QSE_SIZEOF_ULONG_T QSE_SIZEOF___INT64 #else typedef long qse_long_t; typedef unsigned long qse_ulong_t; #define QSE_SIZEOF_LONG_T QSE_SIZEOF_LONG + #define QSE_SIZEOF_ULONG_T QSE_SIZEOF_LONG #endif /** @typedef qse_int8_t @@ -278,7 +289,7 @@ typedef qse_uint8_t qse_byte_t; # define QSE_SIZEOF_SIZE_T __SIZEOF_SIZE_T__ #else typedef qse_uint_t qse_size_t; -# define QSE_SIZEOF_SIZE_T QSE_SIZEOF_INT_T +# define QSE_SIZEOF_SIZE_T QSE_SIZEOF_UINT_T #endif /** @@ -286,23 +297,27 @@ typedef qse_uint8_t qse_byte_t; * to hold a pointer value. */ typedef qse_int_t qse_ssize_t; +# define QSE_SIZEOF_SSIZE_T QSE_SIZEOF_INT_T /** * The qse_word_t type redefines qse_uint_t. */ typedef qse_uint_t qse_word_t; +#define QSE_SIZEOF_WORD_T QSE_SIZEOF_UINT_T /** * The qse_uintptr_t redefines qse_uint_t to indicate that you are dealing * with a pointer. */ typedef qse_uint_t qse_uintptr_t; +#define QSE_SIZEOF_UINTPTR_T QSE_SIZEOF_UINT_T /** * The qse_untptr_t redefines qse_int_t to indicate that you are dealing * with a pointer. */ typedef qse_int_t qse_intptr_t; +#define QSE_SIZEOF_INTPTR_T QSE_SIZEOF_INT_T /** @typedef qse_real_t * The qse_real_t type defines the largest floating-pointer number type @@ -325,6 +340,7 @@ typedef qse_int_t qse_intptr_t; * The qse_mchar_t type defines a multi-byte character type. */ typedef char qse_mchar_t; + /** * The qse_mcint_t defines a type that can hold a qse_mchar_t value and * #QSE_MCHAR_EOF. diff --git a/qse/lib/Makefile.am b/qse/lib/Makefile.am index 093be080..d0ce9da9 100644 --- a/qse/lib/Makefile.am +++ b/qse/lib/Makefile.am @@ -1,2 +1,2 @@ -SUBDIRS = cmn sed awk cut scm http +SUBDIRS = cmn sed awk cut stx DIST_SUBDIRS = $(SUBDIRS) diff --git a/qse/lib/Makefile.in b/qse/lib/Makefile.in index 9486cc04..5682a57c 100644 --- a/qse/lib/Makefile.in +++ b/qse/lib/Makefile.in @@ -225,7 +225,7 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -SUBDIRS = cmn sed awk cut scm http +SUBDIRS = cmn sed awk cut stx DIST_SUBDIRS = $(SUBDIRS) all: all-recursive diff --git a/qse/lib/stx/Makefile.am b/qse/lib/stx/Makefile.am new file mode 100644 index 00000000..a073fb56 --- /dev/null +++ b/qse/lib/stx/Makefile.am @@ -0,0 +1,13 @@ + +AUTOMAKE_OPTIONS = nostdinc + +AM_CPPFLAGS = \ + -I$(top_builddir)/include \ + -I$(top_srcdir)/include \ + -I$(includedir) + +lib_LTLIBRARIES = libqsestx.la + +libqsestx_la_SOURCES = stx.c err.c mem.c obj.c sym.c boot.c misc.c +libqsestx_la_LDFLAGS = -L../cmn -L$(libdir) -version-info 1:0:0 -no-undefined +libqsestx_la_LIBADD = -lqsecmn diff --git a/qse/lib/stx/Makefile.in b/qse/lib/stx/Makefile.in index 8cbcd661..ea1d4c9b 100644 --- a/qse/lib/stx/Makefile.in +++ b/qse/lib/stx/Makefile.in @@ -1,117 +1,558 @@ -# -# $Id: makefile.in,v 1.4 2007/09/11 13:42:54 bacon Exp $ -# +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ -NAME = qsestx +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. -TOP_BUILDDIR = @abs_top_builddir@ -TOP_INSTALLDIR = @prefix@/ase +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. -CC = @CC@ -CXX = @CXX@ +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = lib/stx +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/qse/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__installdirs = "$(DESTDIR)$(libdir)" +LTLIBRARIES = $(lib_LTLIBRARIES) +libqsestx_la_DEPENDENCIES = +am_libqsestx_la_OBJECTS = stx.lo err.lo mem.lo obj.lo sym.lo boot.lo \ + misc.lo +libqsestx_la_OBJECTS = $(am_libqsestx_la_OBJECTS) +libqsestx_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libqsestx_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = +depcomp = $(SHELL) $(top_srcdir)/ac/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libqsestx_la_SOURCES) +DIST_SOURCES = $(libqsestx_la_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ AR = @AR@ -RANLIB = @RANLIB@ -CFLAGS = @CFLAGS@ -I@abs_top_builddir@/.. -CXXFLAGS = @CXXFLAGS@ -I@abs_top_builddir@/.. +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUILD_MODE = @BUILD_MODE@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CHAR_MODE = @CHAR_MODE@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +HAVE_CXX = @HAVE_CXX@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBM = @LIBM@ +LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ -MODE = @BUILDMODE@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +QSE_PROJECT_AUTHOR = @QSE_PROJECT_AUTHOR@ +QSE_PROJECT_URL = @QSE_PROJECT_URL@ +QSE_SIZEOF_CHAR = @QSE_SIZEOF_CHAR@ +QSE_SIZEOF_DOUBLE = @QSE_SIZEOF_DOUBLE@ +QSE_SIZEOF_FLOAT = @QSE_SIZEOF_FLOAT@ +QSE_SIZEOF_INT = @QSE_SIZEOF_INT@ +QSE_SIZEOF_LONG = @QSE_SIZEOF_LONG@ +QSE_SIZEOF_LONG_DOUBLE = @QSE_SIZEOF_LONG_DOUBLE@ +QSE_SIZEOF_LONG_LONG = @QSE_SIZEOF_LONG_LONG@ +QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ +QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ +QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +RANLIB = @RANLIB@ +RM = @RM@ +RMDIR = @RMDIR@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TRUE = @TRUE@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = nostdinc +AM_CPPFLAGS = \ + -I$(top_builddir)/include \ + -I$(top_srcdir)/include \ + -I$(includedir) -JAVAC = @JAVAC@ -JAR = @JAR@ -CFLAGS_JNI = @CFLAGS_JNI@ -JNI = @JNI@ +lib_LTLIBRARIES = libqsestx.la +libqsestx_la_SOURCES = stx.c err.c mem.c obj.c sym.c boot.c misc.c +libqsestx_la_LDFLAGS = -L../cmn -L$(libdir) -version-info 1:0:0 -no-undefined +libqsestx_la_LIBADD = -lqsecmn +all: all-am -LIBTOOL_COMPILE = ../libtool --mode=compile -LIBTOOL_LINK = ../libtool --mode=link +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/stx/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign lib/stx/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; -OUT_DIR = ../$(MODE)/lib -OUT_FILE_LIB = $(OUT_DIR)/lib$(NAME).a -OUT_FILE_JNI = $(OUT_DIR)/lib$(NAME)_jni.la -OUT_FILE_LIB_CXX = $(OUT_DIR)/lib$(NAME)++.a -OUT_FILE_JAR = $(OUT_DIR)/$(NAME).jar +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -TMP_DIR = $(MODE) -TMP_DIR_CXX = $(TMP_DIR)/cxx +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } -OBJ_FILES_LIB = \ - $(TMP_DIR)/stx.o \ - $(TMP_DIR)/memory.o \ - $(TMP_DIR)/object.o \ - $(TMP_DIR)/symbol.o \ - $(TMP_DIR)/class.o \ - $(TMP_DIR)/array.o \ - $(TMP_DIR)/dict.o \ - $(TMP_DIR)/misc.o \ - $(TMP_DIR)/context.o \ - $(TMP_DIR)/name.o \ - $(TMP_DIR)/token.o \ - $(TMP_DIR)/parser.o \ - $(TMP_DIR)/bootstrp.o \ - $(TMP_DIR)/bytecode.o \ - $(TMP_DIR)/interp.o +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done -OBJ_FILES_SO = $(OBJ_FILES_LIB:.o=.lo) +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libqsestx.la: $(libqsestx_la_OBJECTS) $(libqsestx_la_DEPENDENCIES) + $(libqsestx_la_LINK) -rpath $(libdir) $(libqsestx_la_OBJECTS) $(libqsestx_la_LIBADD) $(LIBS) -lib: build +mostlyclean-compile: + -rm -f *.$(OBJEXT) -build: $(OUT_FILE_LIB) +distclean-compile: + -rm -f *.tab.c -$(OUT_FILE_LIB): $(TMP_DIR) $(OUT_DIR) $(OBJ_FILES_LIB) - $(AR) cr $(OUT_FILE_LIB) $(OBJ_FILES_LIB) - if [ ! -z "$(RANLIB)" ]; then $(RANLIB) $(OUT_FILE_LIB); fi +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boot.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/err.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mem.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/obj.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stx.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sym.Plo@am__quote@ -$(TMP_DIR)/stx.o: stx.c - $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c stx.c +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< -$(TMP_DIR)/memory.o: memory.c - $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c memory.c +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` -$(TMP_DIR)/object.o: object.c - $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c object.c +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< -$(TMP_DIR)/symbol.o: symbol.c - $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c symbol.c +mostlyclean-libtool: + -rm -f *.lo -$(TMP_DIR)/class.o: class.c - $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c class.c +clean-libtool: + -rm -rf .libs _libs -$(TMP_DIR)/array.o: array.c - $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c array.c +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS -$(TMP_DIR)/dict.o: dict.c - $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c dict.c +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique -$(TMP_DIR)/misc.o: misc.c - $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c misc.c +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" -$(TMP_DIR)/context.o: context.c - $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c context.c +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -$(TMP_DIR)/name.o: name.c - $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c name.c +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: + for dir in "$(DESTDIR)$(libdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am -$(TMP_DIR)/token.o: token.c - $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c token.c +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -$(TMP_DIR)/parser.o: parser.c - $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c parser.c +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: -$(TMP_DIR)/bootstrp.o: bootstrp.c - $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c bootstrp.c +clean-generic: -$(TMP_DIR)/bytecode.o: bytecode.c - $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c bytecode.c +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -$(TMP_DIR)/interp.o: interp.c - $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c interp.c +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am -$(OUT_DIR): - mkdir -p $(OUT_DIR) +clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ + mostlyclean-am -$(TMP_DIR): - mkdir -p $(TMP_DIR) +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags -clean: - rm -rf $(OUT_FILE_LIB) $(OBJ_FILES_LIB) +dvi: dvi-am +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-libLTLIBRARIES + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-libLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libLTLIBRARIES clean-libtool ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am \ + install-libLTLIBRARIES install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-libLTLIBRARIES + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/qse/lib/stx/boot.c b/qse/lib/stx/boot.c new file mode 100644 index 00000000..0447fed3 --- /dev/null +++ b/qse/lib/stx/boot.c @@ -0,0 +1,735 @@ +/* + * $Id$ + */ + +#include "stx.h" +#include "mem.h" +#include "sym.h" +#include "class.h" + +#if 0 +static void __create_builtin_classes (qse_stx_t* stx); +static qse_word_t __make_classvar_dict ( + qse_stx_t* stx, qse_word_t class, const qse_char_t* names); +static void __filein_kernel (qse_stx_t* stx); + +static qse_word_t __count_names (const qse_char_t* str); +static void __set_names ( + qse_stx_t* stx, qse_word_t* array, const qse_char_t* str); + +static qse_word_t __count_subclasses (const qse_char_t* str); +static void __set_subclasses ( + qse_stx_t* stx, qse_word_t* array, const qse_char_t* str); +static void __set_metaclass_subclasses ( + qse_stx_t* stx, qse_word_t* array, const qse_char_t* str); + +struct class_info_t +{ + const qse_char_t* name; + const qse_char_t* superclass; + const qse_char_t* instance_variables; + const qse_char_t* class_variables; + const qse_char_t* pool_dictionaries; + const int spec; +}; + +typedef struct class_info_t class_info_t; + +static class_info_t class_info[] = +{ + { + QSE_T("Object"), + QSE_NULL, + QSE_NULL, + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + }, + { + QSE_T("UndefinedObject"), + QSE_T("Object"), + QSE_NULL, + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + }, + { + QSE_T("Behavior"), + QSE_T("Object"), + QSE_T("spec methods superclass"), + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + }, + { + QSE_T("Class"), + QSE_T("Behavior"), + QSE_T("name variables classVariables poolDictionaries"), + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + }, + { + QSE_T("Metaclass"), + QSE_T("Behavior"), + QSE_T("instanceClass"), + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + }, + { + QSE_T("Block"), + QSE_T("Object"), + QSE_T("context argCount argLoc bytePointer"), + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + }, + { + QSE_T("Boolean"), + QSE_T("Object"), + QSE_NULL, + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + }, + { + QSE_T("True"), + QSE_T("Boolean"), + QSE_NULL, + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + }, + { + QSE_T("False"), + QSE_T("Boolean"), + QSE_NULL, + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + }, + { + QSE_T("Context"), + QSE_T("Object"), + QSE_T("stack stackTop receiver pc method"), + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + }, + { + QSE_T("Method"), + QSE_T("Object"), + QSE_T("text selector bytecodes tmpCount argCount"), + QSE_NULL, + QSE_NULL, + SPEC_VARIABLE_WORD + }, + { + QSE_T("Magnitude"), + QSE_T("Object"), + QSE_NULL, + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + }, + { + QSE_T("Association"), + QSE_T("Magnitude"), + QSE_T("key value"), + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + }, + { + QSE_T("Character"), + QSE_T("Magnitude"), + QSE_T("value"), + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + }, + { + QSE_T("Number"), + QSE_T("Magnitude"), + QSE_NULL, + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + }, + { + QSE_T("Integer"), + QSE_T("Number"), + QSE_NULL, + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + }, + { + QSE_T("SmallInteger"), + QSE_T("Integer"), + QSE_NULL, + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + }, + { + QSE_T("LargeInteger"), + QSE_T("Integer"), + QSE_NULL, + QSE_NULL, + QSE_NULL, + SPEC_VARIABLE_BYTE + }, + { + QSE_T("Collection"), + QSE_T("Magnitude"), + QSE_NULL, + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + }, + { + QSE_T("IndexedCollection"), + QSE_T("Collection"), + QSE_NULL, + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + }, + { + QSE_T("Array"), + QSE_T("IndexedCollection"), + QSE_NULL, + QSE_NULL, + QSE_NULL, + SPEC_VARIABLE_WORD + }, + { + QSE_T("ByteArray"), + QSE_T("IndexedCollection"), + QSE_NULL, + QSE_NULL, + QSE_NULL, + SPEC_VARIABLE_BYTE + }, + { + QSE_T("Dictionary"), + QSE_T("IndexedCollection"), + QSE_T("tally"), + QSE_NULL, + QSE_NULL, + SPEC_VARIABLE_WORD + }, + { + QSE_T("SystemDictionary"), + QSE_T("Dictionary"), + QSE_NULL, + QSE_NULL, + QSE_NULL, + SPEC_VARIABLE_WORD + }, + { + QSE_T("PoolDictionary"), + QSE_T("Dictionary"), + QSE_NULL, + QSE_NULL, + QSE_NULL, + SPEC_VARIABLE_WORD + }, + { + QSE_T("String"), + QSE_T("IndexedCollection"), + QSE_NULL, + QSE_NULL, + QSE_NULL, + SPEC_VARIABLE_CHAR + }, + { + QSE_T("Symbol"), + QSE_T("String"), + QSE_NULL, + QSE_NULL, + QSE_NULL, + SPEC_VARIABLE_CHAR + }, + { + QSE_T("Link"), + QSE_T("Object"), + QSE_T("link"), + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + }, + { + QSE_NULL, + QSE_NULL, + QSE_NULL, + QSE_NULL, + QSE_NULL, + SPEC_FIXED_WORD + } +}; + +qse_word_t QSE_INLINE __new_string (qse_stx_t* stx, const qse_char_t* str) +{ + qse_word_t x; + + QSE_ASSERT (stx->class_string != stx->nil); + x = qse_stx_alloc_char_object (stx, str); + QSE_STX_CLASS(stx,x) = stx->class_string; + + return x; +} + +static void __create_builtin_classes (qse_stx_t* stx) +{ + class_info_t* p; + qse_word_t class, superclass, array; + qse_stx_class_t* class_obj, * superclass_obj; + qse_word_t metaclass; + qse_stx_metaclass_t* metaclass_obj; + qse_word_t n, nfields; + + QSE_ASSERT (stx->class_array != stx->nil); + + for (p = class_info; p->name != QSE_NULL; p++) + { + class = qse_stx_lookup_class(stx, p->name); + if (class == stx->nil) + { + class = qse_stx_newclass (stx, p->name); + } + + QSE_ASSERT (class != stx->nil); + class_obj = (qse_stx_class_t*)QSE_STX_OBJPTR(stx, class); + class_obj->superclass = (p->superclass == QSE_NULL)? + stx->nil: qse_stx_lookup_class(stx,p->superclass); + + nfields = 0; + if (p->superclass != QSE_NULL) { + qse_word_t meta; + qse_stx_metaclass_t* meta_obj; + + superclass = qse_stx_lookup_class(stx,p->superclass); + QSE_ASSERT (superclass != stx->nil); + + meta = class_obj->header.class; + meta_obj = (qse_stx_metaclass_t*)QSE_STX_OBJPTR(stx,meta); + meta_obj->superclass = QSE_STX_CLASS(stx,superclass); + meta_obj->instance_class = class; + + while (superclass != stx->nil) { + superclass_obj = (qse_stx_class_t*) + QSE_STX_OBJPTR(stx,superclass); + nfields += + QSE_STX_FROMSMALLINT(superclass_obj->spec) >> + QSE_STX_SPEC_INDEXABLE_BITS; + superclass = superclass_obj->superclass; + } + + } + + if (p->instance_variables != QSE_NULL) { + nfields += __count_names (p->instance_variables); + class_obj->variables = + __new_string (stx, p->instance_variables); + } + + QSE_ASSERT (nfields <= 0 || (nfields > 0 && + (p->spec == SPEC_FIXED_WORD || + p->spec == SPEC_VARIABLE_WORD))); + + class_obj->spec = MAKE_SPEC (nfields, p->spec); + } + + for (p = class_info; p->name != QSE_NULL; p++) + { + class = qse_stx_lookup_class(stx, p->name); + QSE_ASSERT (class != stx->nil); + + class_obj = (qse_stx_class_t*)QSE_STX_OBJPTR(stx, class); + + if (p->class_variables != QSE_NULL) + { + class_obj->class_variables = + __make_classvar_dict(stx, class, p->class_variables); + } + + /* + TODO: + if (p->pool_dictionaries != QSE_NULL) { + class_obj->pool_dictionaries = + __make_pool_dictionary(stx, class, p->pool_dictionaries); + } + */ + } + + /* fill subclasses */ + for (p = class_info; p->name != QSE_NULL; p++) + { + n = __count_subclasses (p->name); + array = qse_stx_new_array (stx, n); + __set_subclasses (stx, QSE_STX_DATA(stx,array), p->name); + + class = qse_stx_lookup_class(stx, p->name); + QSE_ASSERT (class != stx->nil); + class_obj = (qse_stx_class_t*)QSE_STX_OBJPTR(stx, class); + class_obj->subclasses = array; + } + + /* fill subclasses for metaclasses */ + for (p = class_info; p->name != QSE_NULL; p++) + { + n = __count_subclasses (p->name); + array = qse_stx_new_array (stx, n); + __set_metaclass_subclasses (stx, QSE_STX_DATA(stx,array), p->name); + + class = qse_stx_lookup_class(stx, p->name); + QSE_ASSERT (class != stx->nil); + metaclass = QSE_STX_CLASS(stx,class); + metaclass_obj = (qse_stx_metaclass_t*)QSE_STX_OBJPTR(stx, metaclass); + metaclass_obj->subclasses = array; + } +} + +static qse_word_t __count_names (const qse_char_t* str) +{ + qse_word_t n = 0; + const qse_char_t* p = str; + + do { + while (*p == QSE_T(' ') || + *p == QSE_T('\t')) p++; + if (*p == QSE_T('\0')) break; + + n++; + while (*p != QSE_T(' ') && + *p != QSE_T('\t') && + *p != QSE_T('\0')) p++; + } while (1); + + return n; +} + +static void __set_names ( + qse_stx_t* stx, qse_word_t* array, const qse_char_t* str) +{ + qse_word_t n = 0; + const qse_char_t* p = str; + const qse_char_t* name; + + do { + while (*p == QSE_T(' ') || + *p == QSE_T('\t')) p++; + if (*p == QSE_T('\0')) break; + + name = p; + while (*p != QSE_T(' ') && + *p != QSE_T('\t') && + *p != QSE_T('\0')) p++; + + array[n++] = qse_stx_new_symbolx (stx, name, p - name); + } while (1); +} + +static qse_word_t __count_subclasses (const qse_char_t* str) +{ + class_info_t* p; + qse_word_t n = 0; + + for (p = class_info; p->name != QSE_NULL; p++) { + if (p->superclass == QSE_NULL) continue; + if (qse_strcmp (str, p->superclass) == 0) n++; + } + + return n; +} + +static void __set_subclasses ( + qse_stx_t* stx, qse_word_t* array, const qse_char_t* str) +{ + class_info_t* p; + qse_word_t n = 0, class; + + for (p = class_info; p->name != QSE_NULL; p++) { + if (p->superclass == QSE_NULL) continue; + if (qse_strcmp (str, p->superclass) != 0) continue; + class = qse_stx_lookup_class (stx, p->name); + QSE_ASSERT (class != stx->nil); + array[n++] = class; + } +} + +static void __set_metaclass_subclasses ( + qse_stx_t* stx, qse_word_t* array, const qse_char_t* str) +{ + class_info_t* p; + qse_word_t n = 0, class; + + for (p = class_info; p->name != QSE_NULL; p++) { + if (p->superclass == QSE_NULL) continue; + if (qse_strcmp (str, p->superclass) != 0) continue; + class = qse_stx_lookup_class (stx, p->name); + QSE_ASSERT (class != stx->nil); + array[n++] = QSE_STX_CLASS(stx,class); + } +} + +static qse_word_t __make_classvar_dict ( + qse_stx_t* stx, qse_word_t class, const qse_char_t* names) +{ + qse_word_t dict, symbol; + const qse_char_t* p = names; + const qse_char_t* name; + + dict = qse_stx_instantiate ( + stx, stx->class_system_dictionary, + QSE_NULL, QSE_NULL, __count_names(names)); + + do { + while (*p == QSE_T(' ') || + *p == QSE_T('\t')) p++; + if (*p == QSE_T('\0')) break; + + name = p; + while (*p != QSE_T(' ') && + *p != QSE_T('\t') && + *p != QSE_T('\0')) p++; + + symbol = qse_stx_new_symbolx (stx, name, p - name); + qse_stx_dict_put (stx, dict, symbol, stx->nil); + } while (1); + + return dict; +} + +static void __filein_kernel (qse_stx_t* stx) +{ + class_info_t* p; + + for (p = class_info; p->name != QSE_NULL; p++) { + /* TODO: */ + } +} +#endif + +static int sketch_nil (qse_stx_t* stx) +{ + qse_stx_objidx_t idx; + qse_word_t ref; + qse_stx_wordobjptr_t ptr; + + /* nil contains no member fields. allocate space for + * an object header */ + idx = qse_stx_allocmem (stx, QSE_SIZEOF(qse_stx_objhdr_t)); + if (idx == QSE_STX_OBJIDX_INVALID) return -1; + + ref = IDXTOREF(stx,idx); + ptr = (qse_stx_wordobjptr_t)PTRBYIDX(stx,idx); + + /* store the nil reference first */ + stx->ref.nil = ref; + + /* nil is a word object containing no member fields. + * initialize it accordingly */ + ptr->h._type = QSE_STX_WORDOBJ; + ptr->h._mark = 0; + ptr->h._refcnt = 0; + ptr->h._size = 0; + ptr->h._class = stx->ref.nil; /* the class is yet to be set */ + ptr->h._backref = ref; + + return 0; +} + +#define ALLOC_WORDOBJ_TO(stx,var,nflds,nvflds) QSE_BLOCK (\ + var = qse_stx_allocwordobj ((stx), QSE_NULL, (nflds), QSE_NULL, nvflds); \ + if ((var) == (stx)->ref.nil) return -1; \ +) + +static int sketch_key_objects (qse_stx_t* stx) +{ + qse_word_t class_SymbolMeta; + qse_word_t class_MetaclassMeta; + qse_word_t class_AssociationMeta; + qse_word_t symbol_Symbol; + qse_word_t symbol_Metaclass; + qse_word_t symbol_Association; + + /* allocate true and false. the class pointer is not correct yet */ + ALLOC_WORDOBJ_TO (stx, stx->ref.true, 0, 0); + ALLOC_WORDOBJ_TO (stx, stx->ref.false, 0, 0); + + /* create a symbol table partially initialized */ +/* TODO: initial symbol table size */ + ALLOC_WORDOBJ_TO (stx, stx->ref.symtab, 1, 256); + /* set tally to 0. */ + WORDAT(stx,stx->ref.symtab,0) = INTTOREF(stx,0); + + /* global system dictionary */ +/* TODO: initial dictionary size */ + ALLOC_WORDOBJ_TO (stx, stx->ref.sysdic, 1, 256); + /* set tally to 0 */ + WORDAT(stx,stx->ref.sysdic,0) = INTTOREF(stx,0); + + /* Symbol */ + ALLOC_WORDOBJ_TO (stx, stx->ref.class_symbol, QSE_STX_CLASS_NFLDS, 0); + /* Metaclass */ + ALLOC_WORDOBJ_TO (stx, stx->ref.class_metaclass, QSE_STX_CLASS_NFLDS, 0); + /* Association */ + ALLOC_WORDOBJ_TO (stx, stx->ref.class_association, QSE_STX_CLASS_NFLDS, 0); + +qse_printf (QSE_T("%d\n"), (int)qse_stx_newsymbol (stx, stx->ref.symtab, QSE_T("abcdefg"))); +qse_printf (QSE_T("%d\n"), (int)qse_stx_newsymbol (stx, stx->ref.symtab, QSE_T("abcdefx"))); +qse_printf (QSE_T("%d\n"), (int)qse_stx_newsymbol (stx, stx->ref.symtab, QSE_T("abcdefy"))); +qse_printf (QSE_T("%d\n"), (int)qse_stx_newsymbol (stx, stx->ref.symtab, QSE_T("abcdefg"))); +qse_printf (QSE_T("%d\n"), (int)qse_stx_newsymbol (stx, stx->ref.symtab, QSE_T("abcdefc"))); + + /* Metaclass is a class so it has the same structure + * as a normal class. "Metaclass class" is an instance of + * Metaclass. */ + + /* Symbol class */ + ALLOC_WORDOBJ_TO (stx, class_SymbolMeta, QSE_STX_METACLASS_NFLDS, 0); + /* Metaclass class */ + ALLOC_WORDOBJ_TO (stx, class_MetaclassMeta, QSE_STX_METACLASS_NFLDS, 0); + /* Association class */ + ALLOC_WORDOBJ_TO (stx, class_AssociationMeta, QSE_STX_METACLASS_NFLDS, 0); + + /* (Symbol class) setClass: Metaclass */ + QSE_STX_OBJCLASS(stx,class_SymbolMeta) = stx->ref.class_metaclass; + /* (Metaclass class) setClass: Metaclass */ + QSE_STX_OBJCLASS(stx,class_MetaclassMeta) = stx->ref.class_metaclass; + /* (Association class) setClass: Metaclass */ + QSE_STX_OBJCLASS(stx,class_AssociationMeta) = stx->ref.class_metaclass; + + /* Symbol setClass: (Symbol class) */ + QSE_STX_OBJCLASS(stx,stx->ref.class_symbol) = class_SymbolMeta; + /* Metaclass setClass: (Metaclass class) */ + QSE_STX_OBJCLASS(stx,stx->ref.class_metaclass) = class_MetaclassMeta; + /* Association setClass: (Association class) */ + QSE_STX_OBJCLASS(stx,stx->ref.class_association) = class_AssociationMeta; + + /* (Symbol class) setSpec: CLASS_SIZE */ + WORDAT(stx,class_SymbolMeta,QSE_STX_CLASS_SPEC) = + INTTOREF (stx, MAKE_SPEC(QSE_STX_CLASS_NFLDS,SPEC_FIXED_WORD)); + /* (Metaclass class) setSpec: CLASS_SIZE */ + WORDAT(stx,class_MetaclassMeta,QSE_STX_CLASS_SPEC) = + INTTOREF (stx, MAKE_SPEC(QSE_STX_CLASS_NFLDS,SPEC_FIXED_WORD)); + /* (Association class) setSpec: CLASS_SIZE */ + WORDAT(stx,class_AssociationMeta,QSE_STX_CLASS_SPEC) = + INTTOREF (stx, MAKE_SPEC(QSE_STX_CLASS_NFLDS,SPEC_FIXED_WORD)); + + /* specs for class_metaclass, class_association, + * class_symbol are set later in __create_builtin_classes */ + + /* #Symbol */ + symbol_Symbol = qse_stx_newsymbol ( + stx, stx->ref.symtab, QSE_T("Symbol")); + /* #Metaclass */ + symbol_Metaclass = qse_stx_newsymbol ( + stx, stx->ref.symtab, QSE_T("Metaclass")); + /* #Association */ + symbol_Association = qse_stx_newsymbol ( + stx, stx->ref.symtab, QSE_T("Association")); + + /* Symbol setName: #Symbol */ + WORDAT(stx,stx->ref.class_symbol,QSE_STX_CLASS_NAME) = symbol_Symbol; + /* Metaclass setName: #Metaclass */ + WORDAT(stx,stx->ref.class_metaclass,QSE_STX_CLASS_NAME) = symbol_Metaclass; + /* Association setName: #Association */ + WORDAT(stx,stx->ref.class_association,QSE_STX_CLASS_NAME) = symbol_Association; + +#if 0 + /* register class names into the system dictionary */ + qse_stx_dict_put (stx, + stx->sysdic, symbol_Symbol, stx->class_symbol); + qse_stx_dict_put (stx, + stx->sysdic, symbol_Metaclass, stx->class_metaclass); + qse_stx_dict_put (stx, + stx->sysdic, symbol_Association, stx->class_association); +#endif + + return 0; +} + + +int qse_stx_boot (qse_stx_t* stx) +{ + qse_word_t symbol_Smalltalk; + qse_word_t object_meta; + + /* create a partially initialized nil object for bootstrapping */ + if (sketch_nil (stx) <= -1) goto oops; + + /* continue intializing other key objects */ + if (sketch_key_objects (stx) <= -1) goto oops; + + return 0; + +#if 0 + __create_bootstrapping_objects (stx); + + /* object, class, and array are precreated for easier instantiation + * of builtin classes */ + stx->class_object = qse_stx_newclass (stx, QSE_T("Object")); + stx->class_class = qse_stx_newclass (stx, QSE_T("Class")); + stx->class_array = qse_stx_newclass (stx, QSE_T("Array")); + stx->class_bytearray = qse_stx_newclass (stx, QSE_T("ByteArray")); + stx->class_string = qse_stx_newclass (stx, QSE_T("String")); + stx->class_character = qse_stx_newclass (stx, QSE_T("Character")); + stx->class_context = qse_stx_newclass (stx, QSE_T("Context")); + stx->class_system_dictionary = + qse_stx_newclass (stx, QSE_T("SystemDictionary")); + stx->class_method = + qse_stx_newclass (stx, QSE_T("Method")); + stx->class_smallinteger = + qse_stx_newclass (stx, QSE_T("SmallInteger")); + + __create_builtin_classes (stx); + + /* (Object class) setSuperclass: Class */ + object_meta = QSE_STX_CLASS(stx,stx->class_object); + QSE_STX_WORD_AT(stx,object_meta,QSE_STX_METACLASS_SUPERCLASS) = stx->class_class; + /* instance class for Object is set here as it is not + * set in __create_builtin_classes */ + QSE_STX_WORD_AT(stx,object_meta,QSE_STX_METACLASS_INSTANCE_CLASS) = stx->class_object; + + /* for some fun here */ + { + qse_word_t array; + array = qse_stx_new_array (stx, 1); + QSE_STX_WORD_AT(stx,array,0) = object_meta; + QSE_STX_WORD_AT(stx,stx->class_class,QSE_STX_CLASS_SUBCLASSES) = array; + } + + /* more initialization */ + QSE_STX_CLASS(stx,stx->sysdic) = stx->class_system_dictionary; + + symbol_Smalltalk = qse_stx_new_symbol (stx, QSE_T("Smalltalk")); + qse_stx_dict_put (stx, stx->sysdic, symbol_Smalltalk, stx->sysdic); + + /* create #nil, #true, #false */ + qse_stx_new_symbol (stx, QSE_T("nil")); + qse_stx_new_symbol (stx, QSE_T("true")); + qse_stx_new_symbol (stx, QSE_T("false")); + + /* nil setClass: UndefinedObject */ + QSE_STX_CLASS(stx,stx->nil) = + qse_stx_lookup_class(stx, QSE_T("UndefinedObject")); + /* true setClass: True */ + QSE_STX_CLASS(stx,stx->true) = + qse_stx_lookup_class (stx, QSE_T("True")); + /* fales setClass: False */ + QSE_STX_CLASS(stx,stx->false) = + qse_stx_lookup_class (stx, QSE_T("False")); + + __filein_kernel (stx); + return 0; +#endif + +oops: + return -1; +} + diff --git a/qse/lib/stx/boot.h b/qse/lib/stx/boot.h new file mode 100644 index 00000000..dd3475f6 --- /dev/null +++ b/qse/lib/stx/boot.h @@ -0,0 +1,20 @@ +/* + * $Id: symbol.h 118 2008-03-03 11:21:33Z baconevi $ + */ + +#ifndef _QSE_LIB_STX_BOOT_H_ +#define _QSE_LIB_STX_BOOT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +int qse_stx_boot ( + qse_stx_t* stx +); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/qse/lib/stx/bootstrp.c b/qse/lib/stx/bootstrp.c index 682eb5a3..8f83ff12 100644 --- a/qse/lib/stx/bootstrp.c +++ b/qse/lib/stx/bootstrp.c @@ -359,13 +359,17 @@ static void __create_bootstrapping_objects (qse_stx_t* stx) qse_word_t symbol_Association; /* allocate three keyword objects */ - stx->nil = qse_stx_alloc_word_object (stx, QSE_NULL, 0, QSE_NULL, 0); - stx->true = qse_stx_alloc_word_object (stx, QSE_NULL, 0, QSE_NULL, 0); - stx->false = qse_stx_alloc_word_object (stx, QSE_NULL, 0, QSE_NULL, 0); + stx->ref.nil = qse_stx_alloc_word_object (stx, QSE_NULL, 0, QSE_NULL, 0); + stx->ref.true = qse_stx_alloc_word_object (stx, QSE_NULL, 0, QSE_NULL, 0); + stx->ref.false = qse_stx_alloc_word_object (stx, QSE_NULL, 0, QSE_NULL, 0); - qse_assert (stx->nil == QSE_STX_NIL); - qse_assert (stx->true == QSE_STX_TRUE); - qse_assert (stx->false == QSE_STX_FALSE); + QSE_ASSERT (stx->ref.nil == QSE_STX_NIL); + QSE_ASSERT (stx->ref.true == QSE_STX_TRUE); + QSE_ASSERT (stx->ref.false == QSE_STX_FALSE); + + stx->symtab = qse_stx_alloc_word_object ( + stx, QSE_NULL, 1, QSE_NULL, 256); + QSE_STX_WORDAT(stx,stx->symtab,QSE_STX_SYMSET_TALLY) = QSE_STX_INTTOREF(0); /* system dictionary */ /* TODO: dictionary size */ @@ -466,7 +470,7 @@ static void __create_builtin_classes (qse_stx_t* stx) } qse_assert (class != stx->nil); - class_obj = (qse_stx_class_t*)QSE_STX_OBJECT(stx, class); + class_obj = (qse_stx_class_t*)QSE_STX_OBJPTR(stx, class); class_obj->superclass = (p->superclass == QSE_NULL)? stx->nil: qse_stx_lookup_class(stx,p->superclass); @@ -479,15 +483,15 @@ static void __create_builtin_classes (qse_stx_t* stx) qse_assert (superclass != stx->nil); meta = class_obj->header.class; - meta_obj = (qse_stx_metaclass_t*)QSE_STX_OBJECT(stx,meta); + meta_obj = (qse_stx_metaclass_t*)QSE_STX_OBJPTR(stx,meta); meta_obj->superclass = QSE_STX_CLASS(stx,superclass); meta_obj->instance_class = class; while (superclass != stx->nil) { superclass_obj = (qse_stx_class_t*) - QSE_STX_OBJECT(stx,superclass); + QSE_STX_OBJPTR(stx,superclass); nfields += - QSE_STX_FROM_SMALLINT(superclass_obj->spec) >> + QSE_STX_FROMSMALLINT(superclass_obj->spec) >> QSE_STX_SPEC_INDEXABLE_BITS; superclass = superclass_obj->superclass; } @@ -512,7 +516,7 @@ static void __create_builtin_classes (qse_stx_t* stx) class = qse_stx_lookup_class(stx, p->name); qse_assert (class != stx->nil); - class_obj = (qse_stx_class_t*)QSE_STX_OBJECT(stx, class); + class_obj = (qse_stx_class_t*)QSE_STX_OBJPTR(stx, class); if (p->class_variables != QSE_NULL) { class_obj->class_variables = @@ -536,7 +540,7 @@ static void __create_builtin_classes (qse_stx_t* stx) class = qse_stx_lookup_class(stx, p->name); qse_assert (class != stx->nil); - class_obj = (qse_stx_class_t*)QSE_STX_OBJECT(stx, class); + class_obj = (qse_stx_class_t*)QSE_STX_OBJPTR(stx, class); class_obj->subclasses = array; } @@ -549,7 +553,7 @@ static void __create_builtin_classes (qse_stx_t* stx) class = qse_stx_lookup_class(stx, p->name); qse_assert (class != stx->nil); metaclass = QSE_STX_CLASS(stx,class); - metaclass_obj = (qse_stx_metaclass_t*)QSE_STX_OBJECT(stx, metaclass); + metaclass_obj = (qse_stx_metaclass_t*)QSE_STX_OBJPTR(stx, metaclass); metaclass_obj->subclasses = array; } } diff --git a/qse/lib/stx/bytecode.c b/qse/lib/stx/bytecode.c index 87c034f7..bd7c5961 100644 --- a/qse/lib/stx/bytecode.c +++ b/qse/lib/stx/bytecode.c @@ -14,7 +14,7 @@ int qse_stx_decode (qse_stx_t* stx, qse_word_t class) { qse_stx_class_t* class_obj; - class_obj = (qse_stx_class_t*)QSE_STX_OBJECT(stx, class); + class_obj = (qse_stx_class_t*)QSE_STX_OBJPTR(stx, class); if (class_obj->methods == stx->nil) return 0; /* TODO */ @@ -25,8 +25,8 @@ int qse_stx_decode (qse_stx_t* stx, qse_word_t class) #include static void __dump_object (qse_stx_t* stx, qse_word_t obj) { - if (QSE_STX_IS_SMALLINT(obj)) { - qse_printf (QSE_T("%d"), QSE_STX_FROM_SMALLINT(obj)); + if (QSE_STX_ISSMALLINT(obj)) { + qse_printf (QSE_T("%d"), QSE_STX_FROMSMALLINT(obj)); } else if (QSE_STX_CLASS(stx,obj) == stx->class_character) { qse_printf (QSE_T("$%c"), QSE_STX_WORD_AT(stx,obj,0)); @@ -37,13 +37,13 @@ static void __dump_object (qse_stx_t* stx, qse_word_t obj) else if (QSE_STX_CLASS(stx,obj) == stx->class_symbol) { qse_printf (QSE_T("#%s"), QSE_STX_DATA(stx,obj)); } - else if (QSE_STX_IS_CHAR_OBJECT(stx, obj)) { + else if (QSE_STX_ISCHAROBJECT(stx, obj)) { qse_printf (QSE_T("unknow char object [%s]"), QSE_STX_DATA(stx,obj)); } - else if (QSE_STX_IS_BYTE_OBJECT(stx, obj)) { + else if (QSE_STX_ISBYTEOBJECT(stx, obj)) { qse_printf (QSE_T("unknown byte object"), QSE_STX_DATA(stx,obj)); } - else if (QSE_STX_IS_WORD_OBJECT(stx, obj)) { + else if (QSE_STX_ISWORDOBJECT(stx, obj)) { qse_printf (QSE_T("unknown word object"), QSE_STX_DATA(stx,obj)); } else { @@ -66,22 +66,22 @@ static void __decode1 (qse_stx_t* stx, qse_word_t idx, void* data) class_obj = (qse_stx_class_t*)data; qse_printf (QSE_T("* Method: %s\n"), QSE_STX_DATA(stx, key)); - method_obj = (qse_stx_method_t*)QSE_STX_OBJECT(stx, value); + method_obj = (qse_stx_method_t*)QSE_STX_OBJPTR(stx, value); literals = method_obj->literals; /* literal_count = QSE_STX_SIZE(stx, value) - - (QSE_STX_FROM_SMALLINT(class_obj->spec) >> QSE_STX_SPEC_INDEXABLE_BITS); + (QSE_STX_FROMSMALLINT(class_obj->spec) >> QSE_STX_SPEC_INDEXABLE_BITS); */ method_class = QSE_STX_CLASS(stx,value); - method_class_obj = QSE_STX_OBJECT(stx, method_class); + method_class_obj = QSE_STX_OBJPTR(stx, method_class); literal_count = QSE_STX_SIZE(stx,value) - - (QSE_STX_FROM_SMALLINT(method_class_obj->spec) >> QSE_STX_SPEC_INDEXABLE_BITS); + (QSE_STX_FROMSMALLINT(method_class_obj->spec) >> QSE_STX_SPEC_INDEXABLE_BITS); qse_printf (QSE_T("* Literal Count: %d, Temporary Count: %d, Argument Count: %d\n"), literal_count, - QSE_STX_FROM_SMALLINT(method_obj->tmpcount), - QSE_STX_FROM_SMALLINT(method_obj->argcount)); + QSE_STX_FROMSMALLINT(method_obj->tmpcount), + QSE_STX_FROMSMALLINT(method_obj->argcount)); for (i = 0; i < literal_count; i++) { qse_printf (QSE_T("%d. ["), i); __dump_object (stx, literals[i]); diff --git a/qse/lib/stx/class.c b/qse/lib/stx/class.c index 9dc39a2a..f92d752c 100644 --- a/qse/lib/stx/class.c +++ b/qse/lib/stx/class.c @@ -8,7 +8,7 @@ #include #include -qse_word_t qse_stx_new_class (qse_stx_t* stx, const qse_char_t* name) +qse_word_t qse_stx_newclass (qse_stx_t* stx, const qse_char_t* name) { qse_word_t meta, class; qse_word_t class_name; @@ -37,7 +37,8 @@ qse_word_t qse_stx_lookup_class (qse_stx_t* stx, const qse_char_t* name) qse_word_t assoc, meta, value; assoc = qse_stx_dict_lookup (stx, stx->smalltalk, name); - if (assoc == stx->nil) { + if (assoc == stx->nil) + { return stx->nil; } @@ -56,7 +57,7 @@ int qse_stx_get_instance_variable_index ( qse_stx_class_t* class_obj; qse_stx_char_object_t* string; - class_obj = (qse_stx_class_t*)QSE_STX_OBJECT(stx, class_index); + class_obj = (qse_stx_class_t*)QSE_STX_OBJPTR(stx, class_index); qse_assert (class_obj != QSE_NULL); if (class_obj->superclass != stx->nil) { @@ -93,7 +94,7 @@ qse_word_t qse_stx_lookup_class_variable ( { qse_stx_class_t* class_obj; - class_obj = (qse_stx_class_t*)QSE_STX_OBJECT(stx, class_index); + class_obj = (qse_stx_class_t*)QSE_STX_OBJPTR(stx, class_index); qse_assert (class_obj != QSE_NULL); if (class_obj->superclass != stx->nil) { @@ -118,7 +119,7 @@ qse_word_t qse_stx_lookup_method (qse_stx_t* stx, { qse_stx_class_t* class_obj; - class_obj = (qse_stx_class_t*)QSE_STX_OBJECT(stx, class_index); + class_obj = (qse_stx_class_t*)QSE_STX_OBJPTR(stx, class_index); qse_assert (class_obj != QSE_NULL); #if 0 @@ -141,7 +142,7 @@ qse_word_t qse_stx_lookup_method (qse_stx_t* stx, #endif while (class_index != stx->nil) { - class_obj = (qse_stx_class_t*)QSE_STX_OBJECT(stx, class_index); + class_obj = (qse_stx_class_t*)QSE_STX_OBJPTR(stx, class_index); qse_assert (class_obj != QSE_NULL); qse_assert ( diff --git a/qse/lib/stx/class.h b/qse/lib/stx/class.h index 9c3716e2..b4b4c5b8 100644 --- a/qse/lib/stx/class.h +++ b/qse/lib/stx/class.h @@ -8,7 +8,7 @@ #include /* definitions for common objects */ -#define QSE_STX_CLASS_SIZE 8 +#define QSE_STX_CLASS_NFLDS 8 #define QSE_STX_CLASS_SPEC 0 #define QSE_STX_CLASS_METHODS 1 #define QSE_STX_CLASS_SUPERCLASS 2 @@ -18,19 +18,23 @@ #define QSE_STX_CLASS_CLASS_VARIABLES 6 #define QSE_STX_CLASS_POOL_DICTIONARIES 7 -#define QSE_STX_METACLASS_SIZE 5 +#define QSE_STX_METACLASS_NFLDS 5 #define QSE_STX_METACLASS_SPEC 0 #define QSE_STX_METACLASS_METHODS 1 #define QSE_STX_METACLASS_SUPERCLASS 2 #define QSE_STX_METACLASS_SUBCLASSES 3 #define QSE_STX_METACLASS_INSTANCE_CLASS 4 -#define QSE_STX_SPEC_INDEXABLE_BITS 2 -#define QSE_STX_SPEC_INDEXABLE_MASK 3 -#define QSE_STX_SPEC_NOT_INDEXABLE 0 -#define QSE_STX_SPEC_WORD_INDEXABLE 1 -#define QSE_STX_SPEC_BYTE_INDEXABLE 2 -#define QSE_STX_SPEC_CHAR_INDEXABLE 3 +#define SPEC_VARIABLE_BITS 2 +#define SPEC_VARIABLE_MASK 0x03 + +#define SPEC_FIXED_WORD 0x00 +#define SPEC_VARIABLE_WORD 0x01 +#define SPEC_VARIABLE_BYTE 0x02 +#define SPEC_VARIABLE_CHAR 0x03 + +#define MAKE_SPEC(nflds,variable) \ + (((nflds) << SPEC_VARIABLE_BITS) | (variable)) struct qse_stx_class_t { @@ -63,6 +67,7 @@ extern "C" { #endif qse_word_t qse_stx_new_class (qse_stx_t* stx, const qse_char_t* name); + qse_word_t qse_stx_lookup_class (qse_stx_t* stx, const qse_char_t* name); int qse_stx_get_instance_variable_index ( diff --git a/qse/lib/stx/context.c b/qse/lib/stx/context.c index df1e270d..d0164480 100644 --- a/qse/lib/stx/context.c +++ b/qse/lib/stx/context.c @@ -15,7 +15,7 @@ qse_word_t qse_stx_new_context (qse_stx_t* stx, context = qse_stx_alloc_word_object( stx, QSE_NULL, QSE_STX_CONTEXT_SIZE, QSE_NULL, 0); - obj = (qse_stx_context_t*)QSE_STX_OBJECT(stx,context); + obj = (qse_stx_context_t*)QSE_STX_OBJPTR(stx,context); obj->header.class = qse_stx_lookup_class(stx,QSE_T("Context")); obj->ip = QSE_STX_TO_SMALLINT(0); obj->method = method; @@ -30,8 +30,8 @@ static qse_byte_t __fetch_byte ( { qse_word_t ip, method; - qse_assert (QSE_STX_IS_SMALLINT(context_obj->ip)); - ip = QSE_STX_FROM_SMALLINT(context_obj->ip); + QSE_ASSERT (QSE_STX_ISSMALLINT(context_obj->ip)); + ip = QSE_STX_FROMSMALLINT(context_obj->ip); method = context_obj->method; /* increment instruction pointer */ @@ -46,9 +46,10 @@ int qse_stx_run_context (qse_stx_t* stx, qse_word_t context) qse_byte_t byte, operand; qse_stx_context_t* context_obj; - context_obj = (qse_stx_context_t*)QSE_STX_OBJECT(stx,context); + context_obj = (qse_stx_context_t*)QSE_STX_OBJPTR(stx,context); - while (!stx->__wantabort) { + while (!stx->__wantabort) + { /* check_process_switch (); // hopefully */ byte = __fetch_byte (stx, context_obj); diff --git a/qse/lib/stx/dict.c b/qse/lib/stx/dict.c index 979d66b8..6df797d8 100644 --- a/qse/lib/stx/dict.c +++ b/qse/lib/stx/dict.c @@ -15,13 +15,10 @@ qse_word_t __new_association ( qse_stx_t* stx, qse_word_t key, qse_word_t value) { qse_word_t x; -#ifdef __GNUC__ - qse_word_t data[2] = { key, value }; -#else qse_word_t data[2]; data[0] = key; data[1] = value; -#endif + x = qse_stx_alloc_word_object ( stx, data, QSE_STX_ASSOCIATION_SIZE, QSE_NULL, 0); QSE_STX_CLASS(stx,x) = stx->class_association; @@ -34,8 +31,8 @@ static qse_word_t __dict_find_slot ( qse_word_t size, hash, index, assoc, symbol; qse_stx_word_object_t* dict_obj; - qse_assert (!QSE_STX_IS_SMALLINT(dict) && - QSE_STX_IS_WORD_OBJECT(stx, dict)); + qse_assert (!QSE_STX_ISSMALLINT(dict) && + QSE_STX_ISWORDOBJECT(stx, dict)); qse_assert (dict == stx->smalltalk || qse_stx_classof(stx,dict) == stx->class_system_dictionary); qse_assert (qse_stx_classof(stx,key) == stx->class_symbol); @@ -99,9 +96,13 @@ static void __grow_dict (qse_stx_t* stx, qse_word_t dict) /* TODO: explore if dict can be immediately destroyed. */ qse_assert (qse_sizeof(qse_stx_object_t*) == qse_sizeof(qse_uint_t)); - QSE_SWAP (QSE_STX_OBJECT(stx,dict), - QSE_STX_OBJECT(stx,new), - qse_stx_object_t*, qse_uint_t); + + QSE_SWAP ( + QSE_STX_OBJPTR(stx,dict), + QSE_STX_OBJPTR(stx,new), + qse_stx_object_t*, + qse_uint_t + ); } qse_word_t qse_stx_dict_lookup ( @@ -110,8 +111,8 @@ qse_word_t qse_stx_dict_lookup ( qse_word_t size, hash, index, assoc, symbol; qse_stx_word_object_t* dict_obj; - qse_assert (!QSE_STX_IS_SMALLINT(dict) && - QSE_STX_IS_WORD_OBJECT(stx, dict)); + qse_assert (!QSE_STX_ISSMALLINT(dict) && + QSE_STX_ISWORDOBJECT(stx, dict)); qse_assert (dict == stx->smalltalk || qse_stx_classof(stx,dict) == stx->class_system_dictionary); @@ -123,7 +124,8 @@ qse_word_t qse_stx_dict_lookup ( dict_obj = QSE_STX_WORD_OBJECT(stx,dict); - while (1) { + while (1) + { assoc = dict_obj->data[index]; if (assoc == stx->nil) break; @@ -154,17 +156,19 @@ qse_word_t qse_stx_dict_put ( qse_assert (QSE_STX_SIZE(stx,dict) > 1); capa = QSE_STX_SIZE(stx,dict) - 1; - tally = QSE_STX_FROM_SMALLINT(QSE_STX_WORD_AT(stx,dict,0)); - if (capa <= tally + 1) { + tally = QSE_STX_FROMSMALLINT(QSE_STX_WORD_AT(stx,dict,0)); + if (capa <= tally + 1) + { __grow_dict (stx, dict); /* refresh tally */ - tally = QSE_STX_FROM_SMALLINT(QSE_STX_WORD_AT(stx,dict,0)); + tally = QSE_STX_FROMSMALLINT(QSE_STX_WORD_AT(stx,dict,0)); } slot = __dict_find_slot (stx, dict, key); assoc = QSE_STX_WORD_AT(stx,dict,slot); - if (assoc == stx->nil) { + if (assoc == stx->nil) + { QSE_STX_WORD_AT(stx,dict,slot) = __new_association (stx, key, value); QSE_STX_WORD_AT(stx,dict,0) = QSE_STX_TO_SMALLINT(tally + 1); diff --git a/qse/lib/stx/err.c b/qse/lib/stx/err.c new file mode 100644 index 00000000..eff67acc --- /dev/null +++ b/qse/lib/stx/err.c @@ -0,0 +1,134 @@ +/* + * $Id$ + * + Copyright 2006-2011 Chung, Hyung-Hwan. + This file is part of QSE. + + QSE is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. + + QSE is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with QSE. If not, see . + */ + +#include "stx.h" +#include "../cmn/mem.h" +#include + +const qse_char_t* qse_stx_dflerrstr (qse_stx_t* stx, qse_stx_errnum_t errnum) +{ + static const qse_char_t* errstr[] = + { + QSE_T("no error"), + + QSE_T("out of memory"), + QSE_T("internal error"), + + QSE_T("exit"), + QSE_T("end of source"), + + QSE_T("I/O error"), + QSE_T("unexpected end of string"), + QSE_T("bad sharp expression"), + QSE_T("wrong use of dot"), + QSE_T("left parenthesis expected"), + QSE_T("right parenthesis expected"), + QSE_T("list too deep"), + + QSE_T("bad variable"), + QSE_T("bad arguments"), + QSE_T("too few arguments"), + QSE_T("too many arguments"), + QSE_T("undefined function '${0}'"), + QSE_T("bad function"), + QSE_T("duplicate formal"), + QSE_T("bad symbol"), + QSE_T("undefined symbol '${0}'"), + QSE_T("empty body"), + QSE_T("bad value"), + QSE_T("divide by zero") + }; + + return (errnum >= 0 && errnum < QSE_COUNTOF(errstr))? + errstr[errnum]: QSE_T("unknown error"); +} + +qse_stx_errstr_t qse_stx_geterrstr (qse_stx_t* stx) +{ + return stx->err.str; +} + +void qse_stx_seterrstr (qse_stx_t* stx, qse_stx_errstr_t errstr) +{ + stx->err.str = errstr; +} + +qse_stx_errnum_t qse_stx_geterrnum (qse_stx_t* stx) +{ + return stx->err.num; +} + +const qse_stx_loc_t* qse_stx_geterrloc (qse_stx_t* stx) +{ + return &stx->err.loc; +} + +const qse_char_t* qse_stx_geterrmsg (qse_stx_t* stx) +{ + return (stx->err.msg[0] == QSE_T('\0'))? + qse_stx_geterrstr(stx)(stx,stx->err.num): stx->err.msg; +} + +void qse_stx_geterror ( + qse_stx_t* stx, qse_stx_errnum_t* errnum, + const qse_char_t** errmsg, qse_stx_loc_t* errloc) +{ + if (errnum != QSE_NULL) *errnum = stx->err.num; + if (errmsg != QSE_NULL) + { + *errmsg = (stx->err.msg[0] == QSE_T('\0'))? + qse_stx_geterrstr(stx)(stx,stx->err.num): + stx->err.msg; + } + if (errloc != QSE_NULL) *errloc = stx->err.loc; +} + +void qse_stx_seterrnum ( + qse_stx_t* stx, qse_stx_errnum_t errnum, const qse_cstr_t* errarg) +{ + qse_stx_seterror (stx, errnum, errarg, QSE_NULL); +} + +void qse_stx_seterrmsg ( + qse_stx_t* stx, qse_stx_errnum_t errnum, + const qse_char_t* errmsg, const qse_stx_loc_t* errloc) +{ + stx->err.num = errnum; + qse_strxcpy (stx->err.msg, QSE_COUNTOF(stx->err.msg), errmsg); + if (errloc != QSE_NULL) stx->err.loc = *errloc; + else QSE_MEMSET (&stx->err.loc, 0, QSE_SIZEOF(stx->err.loc)); +} + +void qse_stx_seterror ( + qse_stx_t* stx, qse_stx_errnum_t errnum, + const qse_cstr_t* errarg, const qse_stx_loc_t* errloc) +{ + const qse_char_t* errfmt; + + stx->err.num = errnum; + + errfmt = qse_stx_geterrstr(stx)(stx,stx->err.num); + QSE_ASSERT (errfmt != QSE_NULL); + qse_strxfncpy (stx->err.msg, QSE_COUNTOF(stx->err.msg), errfmt, errarg); + + if (errloc != QSE_NULL) stx->err.loc = *errloc; + else QSE_MEMSET (&stx->err.loc, 0, QSE_SIZEOF(stx->err.loc)); +} + diff --git a/qse/lib/stx/interp.c b/qse/lib/stx/interp.c index 6b2f55f7..6d93f521 100644 --- a/qse/lib/stx/interp.c +++ b/qse/lib/stx/interp.c @@ -84,15 +84,15 @@ qse_printf (QSE_T("out of memory in qse_stx_interp\n")); proc.stack_base = 0; proc.stack_top = 0; - mthobj = (qse_stx_method_t*)QSE_STX_OBJECT(stx,method); + mthobj = (qse_stx_method_t*)QSE_STX_OBJPTR(stx,method); qse_assert (mthobj != QSE_NULL); proc.literals = mthobj->literals; proc.bytecodes = QSE_STX_DATA(stx, mthobj->bytecodes); proc.bytecode_size = QSE_STX_SIZE(stx, mthobj->bytecodes); /* TODO: disable the method with arguments for start-up */ - proc.argcount = QSE_STX_FROM_SMALLINT(mthobj->argcount); - proc.tmpcount = QSE_STX_FROM_SMALLINT(mthobj->tmpcount); + proc.argcount = QSE_STX_FROMSMALLINT(mthobj->argcount); + proc.tmpcount = QSE_STX_FROMSMALLINT(mthobj->tmpcount); proc.receiver = receiver; proc.method = method; @@ -281,10 +281,10 @@ qse_printf (QSE_T("cannot find the method....\n")); return -1; } - mthobj = (qse_stx_method_t*)QSE_STX_OBJECT(stx,method); + mthobj = (qse_stx_method_t*)QSE_STX_OBJPTR(stx,method); - argcount = QSE_STX_FROM_SMALLINT(mthobj->argcount); - tmpcount = QSE_STX_FROM_SMALLINT(mthobj->tmpcount); + argcount = QSE_STX_FROMSMALLINT(mthobj->argcount); + tmpcount = QSE_STX_FROMSMALLINT(mthobj->tmpcount); qse_assert (argcount == nargs); /* secure space for temporaries */ @@ -329,7 +329,7 @@ static int __return_from_message (qse_stx_t* stx, process_t* proc) method = proc->stack[proc->stack_base + 1 + proc->tmpcount + proc->argcount + 1]; pc = proc->stack[proc->stack_base + 1 + proc->tmpcount + proc->argcount]; - mthobj = (qse_stx_method_t*)QSE_STX_OBJECT(stx,method); + mthobj = (qse_stx_method_t*)QSE_STX_OBJPTR(stx,method); qse_assert (mthobj != QSE_NULL); /* return value is located on top of the previous stack */ @@ -346,8 +346,8 @@ static int __return_from_message (qse_stx_t* stx, process_t* proc) proc->literals = mthobj->literals; proc->bytecodes = QSE_STX_DATA(stx, mthobj->bytecodes); proc->bytecode_size = QSE_STX_SIZE(stx, mthobj->bytecodes); - proc->argcount = QSE_STX_FROM_SMALLINT(mthobj->argcount); - proc->tmpcount = QSE_STX_FROM_SMALLINT(mthobj->tmpcount); + proc->argcount = QSE_STX_FROMSMALLINT(mthobj->argcount); + proc->tmpcount = QSE_STX_FROMSMALLINT(mthobj->tmpcount); return 0; } @@ -364,12 +364,12 @@ static int __dispatch_primitive (qse_stx_t* stx, process_t* proc, qse_word_t no) break; case 2: qse_printf (QSE_T("<< FUNKY STX SMALLTALK >> %d\n"), - QSE_STX_FROM_SMALLINT(proc->stack[proc->stack_base + 1])); + QSE_STX_FROMSMALLINT(proc->stack[proc->stack_base + 1])); break; case 3: qse_printf (QSE_T("<< HIGH STX SMALLTALK >> %d, %d\n"), - QSE_STX_FROM_SMALLINT(proc->stack[proc->stack_base + 1]), - QSE_STX_FROM_SMALLINT(proc->stack[proc->stack_base + 2])); + QSE_STX_FROMSMALLINT(proc->stack[proc->stack_base + 1]), + QSE_STX_FROMSMALLINT(proc->stack[proc->stack_base + 2])); break; case 20: qse_printf (QSE_T("<< PRIMITIVE 20 >>\n")); diff --git a/qse/lib/stx/mem.c b/qse/lib/stx/mem.c new file mode 100644 index 00000000..3c282263 --- /dev/null +++ b/qse/lib/stx/mem.c @@ -0,0 +1,100 @@ +/* + * $Id: memory.c 118 2008-03-03 11:21:33Z baconevi $ + */ + +#include "stx.h" +#include "../cmn/mem.h" + +int qse_stx_initmem (qse_stx_t* stx, qse_size_t capa) +{ + qse_size_t n; + + QSE_ASSERT (capa > 0); + + QSE_ASSERTX ( + stx->mem.slot == QSE_NULL, + "This function is for internal use. Never call this again after initialization" + ); + + stx->mem.slot = (qse_stx_objptr_t*) QSE_MMGR_ALLOC ( + stx->mmgr, + capa * QSE_SIZEOF(*stx->mem.slot) + ); + if (stx->mem.slot == QSE_NULL) return -1; + + stx->mem.capa = capa; + + /* weave the free slot list */ + stx->mem.free = &stx->mem.slot[0]; + for (n = 0; n < capa - 1; n++) + { + stx->mem.slot[n] = (qse_stx_objptr_t)&stx->mem.slot[n + 1]; + } + stx->mem.slot[n] = QSE_NULL; + + return 0; +} + +void qse_stx_finimem (qse_stx_t* stx) +{ + /* TODO: free all linked objects... */ + + QSE_MMGR_FREE (stx->mmgr, stx->mem.slot); + stx->mem.capa = 0; + stx->mem.slot = QSE_NULL; + stx->mem.free = QSE_NULL; +} + +void qse_stx_gcmem (qse_stx_t* stx) +{ + /* TODO: implement this function */ +} + +qse_stx_objidx_t qse_stx_allocmem (qse_stx_t* stx, qse_size_t nbytes) +{ + qse_stx_objptr_t* slot; + qse_stx_objptr_t objptr; + + /* find the free object slot */ + if (stx->mem.free == QSE_NULL) + { + qse_stx_gcmem (stx); + if (stx->mem.free == QSE_NULL) return QSE_STX_OBJIDX_INVALID; + } + +/* TODO: memory allocation by region.. instead of calling individual QSE_MMGR_ALLOC + * compaction in gc... etc +*/ + objptr = (qse_stx_objptr_t) QSE_MMGR_ALLOC (stx->mmgr, nbytes); + if (objptr == QSE_NULL) + { + qse_stx_gcmem (stx); + + objptr = (qse_stx_objptr_t) QSE_MMGR_ALLOC (stx->mmgr, nbytes); + if (objptr == QSE_NULL) + { +QSE_ASSERT (QSE_T("MEMORY ALLOCATION ERROR\n") == QSE_NULL); + return QSE_STX_OBJIDX_INVALID; + } + } + + slot = stx->mem.free; + stx->mem.free = (qse_stx_objptr_t*)*slot; + *slot = objptr; + + QSE_MEMSET (objptr, 0, QSE_SIZEOF(nbytes)); + return (qse_stx_objidx_t)(slot - stx->mem.slot); +} + +void qse_stx_freemem (qse_stx_t* stx, qse_stx_objidx_t objidx) +{ + /* + * THIS IS PRIMITIVE LOW-LEVEL DEALLOC. THIS WILL NOT + * DEALLOCATE MEMORY ALLOCATED FOR ITS INSTANCE VARIABLES. + */ + + QSE_MMGR_FREE (stx->mmgr, stx->mem.slot[objidx]); + stx->mem.slot[objidx] = (qse_stx_objptr_t)stx->mem.free; + stx->mem.free = &stx->mem.slot[objidx]; +} + diff --git a/qse/lib/stx/mem.h b/qse/lib/stx/mem.h new file mode 100644 index 00000000..28e95d3e --- /dev/null +++ b/qse/lib/stx/mem.h @@ -0,0 +1,39 @@ +/* + * $Id$ + */ + +#ifndef _QSE_LIB_STX_MEM_H_ +#define _QSE_LIB_STX_MEM_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +int qse_stx_initmem ( + qse_stx_t* stx, + qse_size_t capa +); + +void qse_stx_finimem ( + qse_stx_t* stx +); + +void qse_stx_gcmem ( + qse_stx_t* stx +); + +qse_stx_objidx_t qse_stx_allocmem ( + qse_stx_t* stx, + qse_size_t nbytes +); + +void qse_stx_freemem ( + qse_stx_t* stx, + qse_stx_objidx_t objidx +); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/qse/lib/stx/memory.h b/qse/lib/stx/memory.h index 74565f6d..e60c2f9e 100644 --- a/qse/lib/stx/memory.h +++ b/qse/lib/stx/memory.h @@ -11,13 +11,26 @@ extern "C" { #endif -qse_stx_memory_t* qse_stx_memory_open ( - qse_stx_memory_t* mem, qse_word_t capacity); -void qse_stx_memory_close (qse_stx_memory_t* mem); +qse_stx_memory_t* qse_stx_initmem ( + qse_stx_memory_t* mem, + qse_word_t capacity +); -void qse_stx_memory_gc (qse_stx_memory_t* mem); -qse_word_t qse_stx_memory_alloc (qse_stx_memory_t* mem, qse_word_t size); -void qse_stx_memory_dealloc (qse_stx_memory_t* mem, qse_word_t object_index); +void qse_stx_finimem ( + qse_stx_memory_t* mem +); + +void qse_stx_gcmem ( + qse_stx_memory_t* mem +); + +qse_word_t qse_stx_alloc ( + qse_stx_memory_t* mem, qse_word_t size +); + +void qse_stx_memory_dealloc ( + qse_stx_memory_t* mem, qse_word_t object_index +); #ifdef __cplusplus } diff --git a/qse/lib/stx/misc.c b/qse/lib/stx/misc.c index f6a9e3b2..7a828102 100644 --- a/qse/lib/stx/misc.c +++ b/qse/lib/stx/misc.c @@ -1,9 +1,45 @@ /* - * $Id: misc.c 118 2008-03-03 11:21:33Z baconevi $ + * $Id$ */ -#include +#include "stx.h" +#include +qse_word_t qse_stx_hashstr (qse_stx_t* stx, const qse_char_t* str) +{ + qse_word_t h = 0; + qse_byte_t* bp, * be; + const qse_char_t* p = str; + + while (*p != QSE_T('\0')) + { + bp = (qse_byte_t*)p; + be = bp + QSE_SIZEOF(qse_char_t); + while (bp < be) h = h * 31 + *bp++; + p++; + } + + return h; +} + +qse_word_t qse_stx_hashstrx (qse_stx_t* stx, const qse_char_t* str, qse_word_t len) +{ + qse_word_t h = 0; + qse_byte_t* bp, * be; + const qse_char_t* p = str, * end = str + len; + + while (p < end) + { + bp = (qse_byte_t*)p; + be = bp + QSE_SIZEOF(qse_char_t); + while (bp < be) h = h * 31 + *bp++; + p++; + } + + return h; +} + +#if 0 qse_word_t qse_stx_hash (const void* data, qse_word_t len) { qse_word_t h = 0; @@ -14,39 +50,6 @@ qse_word_t qse_stx_hash (const void* data, qse_word_t len) return h; } - -qse_word_t qse_stx_strhash (const qse_char_t* str) -{ - qse_word_t h = 0; - qse_byte_t* bp, * be; - const qse_char_t* p = str; - - while (*p != QSE_T('\0')) { - bp = (qse_byte_t*)p; - be = bp + qse_sizeof(qse_char_t); - while (bp < be) h = h * 31 + *bp++; - p++; - } - - return h; -} - -qse_word_t qse_stx_strxhash (const qse_char_t* str, qse_word_t len) -{ - qse_word_t h = 0; - qse_byte_t* bp, * be; - const qse_char_t* p = str, * end = str + len; - - while (p < end) { - bp = (qse_byte_t*)p; - be = bp + qse_sizeof(qse_char_t); - while (bp < be) h = h * 31 + *bp++; - p++; - } - - return h; -} - qse_char_t* qse_stx_strword ( const qse_char_t* str, const qse_char_t* word, qse_word_t* word_index) { @@ -55,9 +58,11 @@ qse_char_t* qse_stx_strword ( qse_size_t len; qse_word_t index = 0; - while (p != QSE_NULL) { + while (p != QSE_NULL) + { p = qse_strtok (p, QSE_T(""), &tok, &len); - if (qse_strxcmp (tok, len, word) == 0) { + if (qse_strxcmp (tok, len, word) == 0) + { *word_index = index; return tok; } @@ -68,3 +73,4 @@ qse_char_t* qse_stx_strword ( *word_index = index; return QSE_NULL; } +#endif diff --git a/qse/lib/stx/obj.c b/qse/lib/stx/obj.c new file mode 100644 index 00000000..a0b03e0c --- /dev/null +++ b/qse/lib/stx/obj.c @@ -0,0 +1,300 @@ +/* + * $Id$ + */ + +#include "stx.h" +#include "mem.h" + +qse_word_t qse_stx_allocwordobj ( + qse_stx_t* stx, const qse_word_t* data, qse_word_t nflds, + const qse_word_t* variable_data, qse_word_t variable_nflds) +{ + qse_word_t total_nflds; + qse_size_t total_bytes; + qse_stx_objidx_t idx; + qse_word_t ref; + qse_stx_wordobjptr_t ptr; + + total_nflds = nflds + variable_nflds; + total_bytes = + (total_nflds * QSE_SIZEOF(qse_word_t)) + + QSE_SIZEOF(qse_stx_objhdr_t); + +/* TODO: check if n is larger then header.access nfield bits can represent... + * then.... reject .... */ + + idx = qse_stx_allocmem (stx, total_bytes); + if (idx == QSE_STX_OBJIDX_INVALID) return stx->ref.nil; + + ref = IDXTOREF(stx,idx); + ptr = (qse_stx_wordobjptr_t)PTRBYIDX(stx,idx); + + ptr->h._type = QSE_STX_WORDOBJ; + ptr->h._mark = 0; + ptr->h._refcnt = 0; + ptr->h._size = total_nflds; + ptr->h._class = stx->ref.nil; + ptr->h._backref = ref; + + if (variable_data) + { + while (total_nflds > nflds) + { + total_nflds--; + ptr->fld[total_nflds] = variable_data[total_nflds - nflds]; + } + } + else + { + while (total_nflds > nflds) + ptr->fld[--total_nflds] = stx->ref.nil; + } + + if (data) + { + while (total_nflds > 0) + { + total_nflds--; + ptr->fld[total_nflds] = data[total_nflds]; + } + } + else + { + while (total_nflds > 0) + ptr->fld[--total_nflds] = stx->ref.nil; + } + + return ref; +} + +qse_word_t qse_stx_allocbyteobj ( + qse_stx_t* stx, const qse_byte_t* variable_data, qse_word_t variable_nflds) +{ + qse_stx_objidx_t idx; + qse_word_t ref; + qse_stx_byteobjptr_t ptr; + + idx = qse_stx_allocmem ( + stx, variable_nflds + QSE_SIZEOF(qse_stx_objhdr_t)); + if (idx == QSE_STX_OBJIDX_INVALID) return stx->ref.nil; + + ref = QSE_STX_IDXTOREF(stx,idx); + ptr = (qse_stx_byteobjptr_t)PTRBYIDX(stx,idx); + + ptr->h._type = QSE_STX_BYTEOBJ; + ptr->h._mark = 0; + ptr->h._refcnt = 0; + ptr->h._size = variable_nflds; + ptr->h._class = stx->ref.nil; + ptr->h._backref = ref; + + if (variable_data) + { + while (variable_nflds > 0) + { + variable_nflds--; + ptr->fld[variable_nflds] = variable_data[variable_nflds]; + } + } + + return ref; +} + +#if 0 +qse_word_t qse_stx_alloc_char_object ( + qse_stx_t* stx, const qse_char_t* str) +{ + return (str == QSE_NULL)? + qse_stx_alloc_char_objectx (stx, QSE_NULL, 0): + qse_stx_alloc_char_objectx (stx, str, qse_strlen(str)); +} +#endif + +qse_word_t qse_stx_alloccharobj ( + qse_stx_t* stx, const qse_char_t* variable_data, qse_word_t variable_nflds) +{ + qse_stx_objidx_t idx; + qse_word_t ref; + qse_stx_charobjptr_t ptr; + qse_size_t total_bytes; + + total_bytes = + (variable_nflds + 1) * QSE_SIZEOF(qse_char_t) + + QSE_SIZEOF(qse_stx_objhdr_t); + + idx = qse_stx_allocmem (stx, total_bytes); + if (idx == QSE_STX_OBJIDX_INVALID) return stx->ref.nil; + + ref = QSE_STX_IDXTOREF(stx,idx); + ptr = (qse_stx_charobjptr_t)PTRBYIDX(stx,idx); + + ptr->h._type = QSE_STX_CHAROBJ; + ptr->h._mark = 0; + ptr->h._refcnt = 0; + ptr->h._size = variable_nflds; + ptr->h._class = stx->ref.nil; + ptr->h._backref = ref; + + if (variable_data) + { + while (variable_nflds > 0) + { + variable_nflds--; + ptr->fld[variable_nflds] = variable_data[variable_nflds]; + } + } + + QSE_ASSERT (ptr->fld[ptr->h._size] == QSE_T('\0')); + return ref; +} + +#if 0 +qse_word_t qse_stx_allocn_char_object (qse_stx_t* stx, ...) +{ + qse_word_t idx, n = 0; + const qse_char_t* p; + qse_va_list ap; + qse_stx_char_object_t* obj; + + QSE_ASSERT (stx->ref.nil == QSE_STX_NIL); + + qse_va_start (ap, stx); + while ((p = qse_va_arg(ap, const qse_char_t*)) != QSE_NULL) { + n += qse_strlen(p); + } + qse_va_end (ap); + + idx = qse_stx_memory_alloc (&stx->memory, + (n + 1) * QSE_SIZEOF(qse_char_t) + QSE_SIZEOF(qse_stx_object_t)); + if (idx >= stx->memory.capacity) return idx; /* failed */ + + idx = QSE_STX_TOOBJIDX(idx); + obj = QSE_STX_CHAR_OBJECT(stx,idx); + obj->header.class = stx->ref.nil; + obj->header.access = (n << 2) | QSE_STX_CHAR_INDEXED; + obj->data[n] = QSE_T('\0'); + + qse_va_start (ap, stx); + n = 0; + while ((p = qse_va_arg(ap, const qse_char_t*)) != QSE_NULL) + { + while (*p != QSE_T('\0')) + { + /*QSE_STX_CHAR_AT(stx,idx,n++) = *p++;*/ + obj->data[n++] = *p++; + } + } + qse_va_end (ap); + + return idx; +} + +qse_word_t qse_stx_hash_object (qse_stx_t* stx, qse_word_t objref) +{ + qse_word_t hv; + + if (QSE_STX_ISSMALLINT(objref)) + { + qse_word_t tmp = QSE_STX_FROMSMALLINT(objref); + hv = qse_stx_hash(&tmp, QSE_SIZEOF(tmp)); + } + else if (QSE_STX_ISCHAROBJECT(stx,objref)) + { + /* the additional null is not taken into account */ + hv = qse_stx_hash (QSE_STX_DATA(stx,objref), + QSE_STX_SIZE(stx,objref) * QSE_SIZEOF(qse_char_t)); + } + else if (QSE_STX_ISBYTEOBJECT(stx,objref)) + { + hv = qse_stx_hash ( + QSE_STX_DATA(stx,objref), QSE_STX_SIZE(stx,objref)); + } + else + { + QSE_ASSERT (QSE_STX_ISWORDOBJECT(stx,objref)); + hv = qse_stx_hash (QSE_STX_DATA(stx,objref), + QSE_STX_SIZE(stx,objref) * QSE_SIZEOF(qse_word_t)); + } + + return hv; +} + +qse_word_t qse_stx_instantiate ( + qse_stx_t* stx, qse_stx_objref_t class, const void* data, + const void* variable_data, qse_word_t variable_nflds) +{ + qse_stx_class_t* class_ptr; + qse_word_t spec, nflds, inst; + int indexable; + + QSE_ASSERT (class != stx->class_smallinteger); + class_ptr = (qse_stx_class_t*)QSE_STX_OBJPTR(stx, class); + + /* don't instantiate a metaclass whose instance must be + created in a different way */ + /* TODO: maybe delete the following line */ + QSE_ASSERT (QSE_STX_CLASS(class) != stx->class_metaclass); + QSE_ASSERT (QSE_STX_ISSMALLINT(class_obj->spec)); + + spec = QSE_STX_FROMSMALLINT(class_obj->spec); + nflds = (spec >> QSE_STX_SPEC_INDEXABLE_BITS); + indexable = spec & QSE_STX_SPEC_INDEXABLE_MASK; + + switch (indexable) + { + case QSE_STX_SPEC_BYTE_INDEXABLE: + /* variable-size byte class */ + QSE_ASSERT (nflds == 0 && data == QSE_NULL); + inst = qse_stx_alloc_byte_object( + stx, variable_data, variable_nflds); + break; + + case QSE_STX_SPEC_CHAR_INDEXABLE: + /* variable-size char class */ + QSE_ASSERT (nflds == 0 && data == QSE_NULL); + inst = qse_stx_alloc_char_objectx( + stx, variable_data, variable_nflds); + break; + + case QSE_STX_SPEC_WORD_INDEXABLE: + /* variable-size class */ + inst = qse_stx_alloc_word_object ( + stx, data, nflds, variable_data, variable_nflds); + break; + + case QSE_STX_SPEC_FIXED: + /* fixed size */ + QSE_ASSERT (indexable == QSE_STX_SPEC_NOT_INDEXABLE); + QSE_ASSERT (variable_nflds == 0 && variable_data == QSE_NULL); + inst = qse_stx_alloc_word_object ( + stx, data, nflds, QSE_NULL, 0); + break; + + default: + /* this should never happen */ + QSE_ASSERTX (0, "this should never happen"); + inst = QSE_STX_OBJREF_INVALID; + } + + if (inst != QSE_STX_OBJREF_INVALID) + QSE_STX_CLASSOF(stx,inst) = class; + return inst; +} + +qse_word_t qse_stx_class (qse_stx_t* stx, qse_stx_objref_t obj) +{ + return QSE_STX_ISSMALLINT(obj)? + stx->class_smallinteger: QSE_STX_CLASS(stx,obj); +} + +qse_word_t qse_stx_classof (qse_stx_t* stx, qse_stx_objref_t obj) +{ + return QSE_STX_ISSMALLINT(obj)? + stx->class_smallinteger: QSE_STX_CLASS(stx,obj); +} + +qse_word_t qse_stx_sizeof (qse_stx_t* stx, qse_stx_objref_t obj) +{ + return QSE_STX_ISSMALLINT(obj)? 1: QSE_STX_SIZE(stx,obj); +} +#endif diff --git a/qse/lib/stx/obj.h b/qse/lib/stx/obj.h new file mode 100644 index 00000000..a8c80ae2 --- /dev/null +++ b/qse/lib/stx/obj.h @@ -0,0 +1,61 @@ +/* + * $Id: object.h 118 2008-03-03 11:21:33Z baconevi $ + */ + +#ifndef _QSE_LIB_STX_OBJ_H_ +#define _QSE_LIB_STX_OBJ_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +qse_word_t qse_stx_allocwordobj ( + qse_stx_t* stx, + const qse_word_t* data, + qse_word_t nflds, + const qse_word_t* variable_data, + qse_word_t variable_nflds +); + +qse_word_t qse_stx_allocbyteobj ( + qse_stx_t* stx, + const qse_byte_t* variable_data, + qse_word_t variable_nflds +); + +qse_word_t qse_stx_alloccharobj ( + qse_stx_t* stx, + const qse_char_t* variable_data, + qse_word_t variable_nflds +); + + +#if 0 +qse_word_t qse_stx_alloc_word_object ( + qse_stx_t* stx, const qse_word_t* data, qse_word_t nfields, + const qse_word_t* variable_data, qse_word_t variable_nfields); + +qse_word_t qse_stx_alloc_byte_object ( + qse_stx_t* stx, const qse_byte_t* data, qse_word_t n); + +qse_word_t qse_stx_alloc_char_object ( + qse_stx_t* stx, const qse_char_t* str); +qse_word_t qse_stx_alloc_char_objectx ( + qse_stx_t* stx, const qse_char_t* str, qse_word_t n); +qse_word_t qse_stx_allocn_char_object (qse_stx_t* stx, ...); + +qse_word_t qse_stx_hash_object (qse_stx_t* stx, qse_word_t object); + +qse_word_t qse_stx_instantiate ( + qse_stx_t* stx, qse_word_t class_index, const void* data, + const void* variable_data, qse_word_t variable_nfields); +qse_word_t qse_stx_classof (qse_stx_t* stx, qse_word_t obj); +qse_word_t qse_stx_sizeof (qse_stx_t* stx, qse_word_t obj); +#endif + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/qse/lib/stx/object.c b/qse/lib/stx/object.c index 6b4fddbb..9a5e1ecd 100644 --- a/qse/lib/stx/object.c +++ b/qse/lib/stx/object.c @@ -13,7 +13,8 @@ qse_word_t qse_stx_alloc_word_object ( qse_stx_t* stx, const qse_word_t* data, qse_word_t nfields, const qse_word_t* variable_data, qse_word_t variable_nfields) { - qse_word_t idx, n; + qse_stx_objref_t idx; + qse_word_t n; qse_stx_word_object_t* obj; QSE_ASSERT (stx->nil == QSE_STX_NIL); @@ -23,29 +24,40 @@ qse_word_t qse_stx_alloc_word_object ( * number of variable instance variables) * word_size */ n = nfields + variable_nfields; - idx = qse_stx_memory_alloc (&stx->memory, - n * qse_sizeof(qse_word_t) + qse_sizeof(qse_stx_object_t)); - if (idx >= stx->memory.capacity) return idx; /* failed TODO: return a difference value OINDEX_INVALID */ - idx = QSE_STX_TO_OINDEX(idx); - obj = QSE_STX_WORD_OBJECT(stx,idx); +/* TODO: check if n is larger then header.access nfield bits can represent... + * then.... reject .... */ + + idx = qse_stx_memory_alloc ( + &stx->memory, + n * QSE_SIZEOF(qse_word_t) + QSE_SIZEOF(qse_stx_object_t)); + if (idx >= stx->memory.capacity) return QSE_STX_OBJREF_INVALID; /* failed TODO: return a difference value OBJIDX_INVALID */ + + idx = QSE_STX_TOOBJREF(idx); + obj = QSE_STX_WORDOBJPTR(stx,idx); + obj->header.class = stx->nil; obj->header.access = (n << 2) | QSE_STX_WORD_INDEXED; - if (variable_data == QSE_NULL) { + if (variable_data == QSE_NULL) + { while (n > nfields) obj->data[--n] = stx->nil; } - else { + else + { while (n > nfields) { n--; obj->data[n] = variable_data[n - nfields]; } } - if (data == QSE_NULL) { + if (data == QSE_NULL) + { while (n > 0) obj->data[--n] = stx->nil; } - else { - while (n > 0) { + else + { + while (n > 0) + { n--; obj->data[n] = data[n]; } } @@ -62,19 +74,24 @@ qse_word_t qse_stx_alloc_byte_object ( QSE_ASSERT (stx->nil == QSE_STX_NIL); +/* TODO: check if n is larger then header.access nfield bits can represent... + * then.... reject .... */ + idx = qse_stx_memory_alloc ( - &stx->memory, n + qse_sizeof(qse_stx_object_t)); + &stx->memory, n + QSE_SIZEOF(qse_stx_object_t)); if (idx >= stx->memory.capacity) return idx; /* failed */ - idx = QSE_STX_TO_OINDEX(idx); + idx = QSE_STX_TOOBJIDX(idx); obj = QSE_STX_BYTE_OBJECT(stx,idx); obj->header.class = stx->nil; obj->header.access = (n << 2) | QSE_STX_BYTE_INDEXED; - if (data == QSE_NULL) { + if (data == QSE_NULL) + { while (n-- > 0) obj->data[n] = 0; } - else { + else + { while (n-- > 0) obj->data[n] = data[n]; } @@ -98,20 +115,25 @@ qse_word_t qse_stx_alloc_char_objectx ( QSE_ASSERT (stx->nil == QSE_STX_NIL); +/* TODO: check if n is larger then header.access nfield bits can represent... + * then.... reject .... */ + idx = qse_stx_memory_alloc (&stx->memory, - (n + 1) * qse_sizeof(qse_char_t) + qse_sizeof(qse_stx_object_t)); + (n + 1) * QSE_SIZEOF(qse_char_t) + QSE_SIZEOF(qse_stx_object_t)); if (idx >= stx->memory.capacity) return idx; /* failed */ - idx = QSE_STX_TO_OINDEX(idx); + idx = QSE_STX_TOOBJIDX(idx); obj = QSE_STX_CHAR_OBJECT(stx,idx); obj->header.class = stx->nil; obj->header.access = (n << 2) | QSE_STX_CHAR_INDEXED; obj->data[n] = QSE_T('\0'); - if (str == QSE_NULL) { + if (str == QSE_NULL) + { while (n-- > 0) obj->data[n] = QSE_T('\0'); } - else { + else + { while (n-- > 0) obj->data[n] = str[n]; } @@ -134,10 +156,10 @@ qse_word_t qse_stx_allocn_char_object (qse_stx_t* stx, ...) qse_va_end (ap); idx = qse_stx_memory_alloc (&stx->memory, - (n + 1) * qse_sizeof(qse_char_t) + qse_sizeof(qse_stx_object_t)); + (n + 1) * QSE_SIZEOF(qse_char_t) + QSE_SIZEOF(qse_stx_object_t)); if (idx >= stx->memory.capacity) return idx; /* failed */ - idx = QSE_STX_TO_OINDEX(idx); + idx = QSE_STX_TOOBJIDX(idx); obj = QSE_STX_CHAR_OBJECT(stx,idx); obj->header.class = stx->nil; obj->header.access = (n << 2) | QSE_STX_CHAR_INDEXED; @@ -145,8 +167,10 @@ qse_word_t qse_stx_allocn_char_object (qse_stx_t* stx, ...) qse_va_start (ap, stx); n = 0; - while ((p = qse_va_arg(ap, const qse_char_t*)) != QSE_NULL) { - while (*p != QSE_T('\0')) { + while ((p = qse_va_arg(ap, const qse_char_t*)) != QSE_NULL) + { + while (*p != QSE_T('\0')) + { /*QSE_STX_CHAR_AT(stx,idx,n++) = *p++;*/ obj->data[n++] = *p++; } @@ -156,95 +180,111 @@ qse_word_t qse_stx_allocn_char_object (qse_stx_t* stx, ...) return idx; } -qse_word_t qse_stx_hash_object (qse_stx_t* stx, qse_word_t object) +qse_word_t qse_stx_hash_object (qse_stx_t* stx, qse_word_t objref) { qse_word_t hv; - if (QSE_STX_IS_SMALLINT(object)) { - qse_word_t tmp = QSE_STX_FROM_SMALLINT(object); - hv = qse_stx_hash(&tmp, qse_sizeof(tmp)); + if (QSE_STX_ISSMALLINT(objref)) + { + qse_word_t tmp = QSE_STX_FROMSMALLINT(objref); + hv = qse_stx_hash(&tmp, QSE_SIZEOF(tmp)); } - else if (QSE_STX_IS_CHAR_OBJECT(stx,object)) { + else if (QSE_STX_ISCHAROBJECT(stx,objref)) + { /* the additional null is not taken into account */ - hv = qse_stx_hash (QSE_STX_DATA(stx,object), - QSE_STX_SIZE(stx,object) * qse_sizeof(qse_char_t)); + hv = qse_stx_hash (QSE_STX_DATA(stx,objref), + QSE_STX_SIZE(stx,objref) * QSE_SIZEOF(qse_char_t)); } - else if (QSE_STX_IS_BYTE_OBJECT(stx,object)) { + else if (QSE_STX_ISBYTEOBJECT(stx,objref)) + { hv = qse_stx_hash ( - QSE_STX_DATA(stx,object), QSE_STX_SIZE(stx,object)); + QSE_STX_DATA(stx,objref), QSE_STX_SIZE(stx,objref)); } - else { - QSE_ASSERT (QSE_STX_IS_WORD_OBJECT(stx,object)); - hv = qse_stx_hash (QSE_STX_DATA(stx,object), - QSE_STX_SIZE(stx,object) * qse_sizeof(qse_word_t)); + else + { + QSE_ASSERT (QSE_STX_ISWORDOBJECT(stx,objref)); + hv = qse_stx_hash (QSE_STX_DATA(stx,objref), + QSE_STX_SIZE(stx,objref) * QSE_SIZEOF(qse_word_t)); } return hv; } qse_word_t qse_stx_instantiate ( - qse_stx_t* stx, qse_word_t class, const void* data, + qse_stx_t* stx, qse_stx_objref_t class, const void* data, const void* variable_data, qse_word_t variable_nfields) { - qse_stx_class_t* class_obj; - qse_word_t spec, nfields, new; + qse_stx_class_t* class_ptr; + qse_word_t spec, nfields, inst; int indexable; QSE_ASSERT (class != stx->class_smallinteger); - class_obj = (qse_stx_class_t*)QSE_STX_OBJECT(stx, class); + class_ptr = (qse_stx_class_t*)QSE_STX_OBJPTR(stx, class); /* don't instantiate a metaclass whose instance must be created in a different way */ /* TODO: maybe delete the following line */ - QSE_ASSERT (class_obj->header.class != stx->class_metaclass); - QSE_ASSERT (QSE_STX_IS_SMALLINT(class_obj->spec)); + QSE_ASSERT (QSE_STX_CLASS(class) != stx->class_metaclass); + QSE_ASSERT (QSE_STX_ISSMALLINT(class_obj->spec)); - spec = QSE_STX_FROM_SMALLINT(class_obj->spec); + spec = QSE_STX_FROMSMALLINT(class_obj->spec); nfields = (spec >> QSE_STX_SPEC_INDEXABLE_BITS); indexable = spec & QSE_STX_SPEC_INDEXABLE_MASK; - if (indexable == QSE_STX_SPEC_BYTE_INDEXABLE) + switch (indexable) { - QSE_ASSERT (nfields == 0 && data == QSE_NULL); - new = qse_stx_alloc_byte_object( - stx, variable_data, variable_nfields); - } - else if (indexable == QSE_STX_SPEC_CHAR_INDEXABLE) - { - QSE_ASSERT (nfields == 0 && data == QSE_NULL); - new = qse_stx_alloc_char_objectx( - stx, variable_data, variable_nfields); - } - else if (indexable == QSE_STX_SPEC_WORD_INDEXABLE) - { - new = qse_stx_alloc_word_object ( - stx, data, nfields, variable_data, variable_nfields); - } - else - { - QSE_ASSERT (indexable == QSE_STX_SPEC_NOT_INDEXABLE); - QSE_ASSERT (variable_nfields == 0 && variable_data == QSE_NULL); - new = qse_stx_alloc_word_object ( - stx, data, nfields, QSE_NULL, 0); + case QSE_STX_SPEC_BYTE_INDEXABLE: + /* variable-size byte class */ + QSE_ASSERT (nfields == 0 && data == QSE_NULL); + inst = qse_stx_alloc_byte_object( + stx, variable_data, variable_nfields); + break; + + case QSE_STX_SPEC_CHAR_INDEXABLE: + /* variable-size char class */ + QSE_ASSERT (nfields == 0 && data == QSE_NULL); + inst = qse_stx_alloc_char_objectx( + stx, variable_data, variable_nfields); + break; + + case QSE_STX_SPEC_WORD_INDEXABLE: + /* variable-size class */ + inst = qse_stx_alloc_word_object ( + stx, data, nfields, variable_data, variable_nfields); + break; + + case QSE_STX_SPEC_NOT_INDEXABLE: + /* fixed size */ + QSE_ASSERT (indexable == QSE_STX_SPEC_NOT_INDEXABLE); + QSE_ASSERT (variable_nfields == 0 && variable_data == QSE_NULL); + inst = qse_stx_alloc_word_object ( + stx, data, nfields, QSE_NULL, 0); + break; + + default: + /* this should never happen */ + QSE_ASSERTX (0, "this should never happen"); + inst = QSE_STX_OBJREF_INVALID; } - QSE_STX_CLASS(stx, new) = class; - return new; + if (inst != QSE_STX_OBJREF_INVALID) + QSE_STX_CLASSOF(stx,inst) = class; + return inst; } -qse_word_t qse_stx_class (qse_stx_t* stx, qse_word_t obj) +qse_word_t qse_stx_class (qse_stx_t* stx, qse_stx_objref_t obj) { - return QSE_STX_IS_SMALLINT(obj)? + return QSE_STX_ISSMALLINT(obj)? stx->class_smallinteger: QSE_STX_CLASS(stx,obj); } -qse_word_t qse_stx_classof (qse_stx_t* stx, qse_word_t obj) +qse_word_t qse_stx_classof (qse_stx_t* stx, qse_stx_objref_t obj) { - return QSE_STX_IS_SMALLINT(obj)? + return QSE_STX_ISSMALLINT(obj)? stx->class_smallinteger: QSE_STX_CLASS(stx,obj); } -qse_word_t qse_stx_sizeof (qse_stx_t* stx, qse_word_t obj) +qse_word_t qse_stx_sizeof (qse_stx_t* stx, qse_stx_objref_t obj) { - return QSE_STX_IS_SMALLINT(obj)? 1: QSE_STX_SIZE(stx,obj); + return QSE_STX_ISSMALLINT(obj)? 1: QSE_STX_SIZE(stx,obj); } diff --git a/qse/lib/stx/parser.c b/qse/lib/stx/parser.c index bc50f37a..6c4d0d96 100644 --- a/qse/lib/stx/parser.c +++ b/qse/lib/stx/parser.c @@ -412,7 +412,7 @@ static int __add_character_literal (qse_stx_parser_t* parser, qse_char_t ch) qse_stx_t* stx = parser->stx; for (i = 0; i < parser->literal_count; i++) { - c = QSE_STX_IS_SMALLINT(parser->literals[i])? + c = QSE_STX_ISSMALLINT(parser->literals[i])? stx->class_smallinteger: QSE_STX_CLASS (stx, parser->literals[i]); if (c != stx->class_character) continue; @@ -431,7 +431,7 @@ static int __add_string_literal ( qse_stx_t* stx = parser->stx; for (i = 0; i < parser->literal_count; i++) { - c = QSE_STX_IS_SMALLINT(parser->literals[i])? + c = QSE_STX_ISSMALLINT(parser->literals[i])? stx->class_smallinteger: QSE_STX_CLASS (stx, parser->literals[i]); if (c != stx->class_string) continue; @@ -509,7 +509,7 @@ static int __finish_method (qse_stx_parser_t* parser) qse_assert (parser->bytecode.size != 0); class_obj = (qse_stx_class_t*) - QSE_STX_OBJECT(stx, parser->method_class); + QSE_STX_OBJPTR(stx, parser->method_class); if (class_obj->methods == stx->nil) { /* TODO: reconfigure method dictionary size */ @@ -524,7 +524,7 @@ static int __finish_method (qse_stx_parser_t* parser) method = qse_stx_instantiate(stx, stx->class_method, QSE_NULL, parser->literals, parser->literal_count); - method_obj = (qse_stx_method_t*)QSE_STX_OBJECT(stx, method); + method_obj = (qse_stx_method_t*)QSE_STX_OBJPTR(stx, method); /* TODO: text saving must be optional */ /*method_obj->text = qse_stx_instantiate ( diff --git a/qse/lib/stx/stx.c b/qse/lib/stx/stx.c index 42311431..ae12a25c 100644 --- a/qse/lib/stx/stx.c +++ b/qse/lib/stx/stx.c @@ -2,23 +2,31 @@ * $Id: stx.c 118 2008-03-03 11:21:33Z baconevi $ */ -#include -#include -#include +#include "stx.h" +#include "mem.h" +#include "boot.h" +#include "../cmn/mem.h" -qse_stx_t* qse_stx_open (qse_stx_t* stx, qse_word_t capacity) +qse_stx_t* qse_stx_init (qse_stx_t* stx, qse_mmgr_t* mmgr, qse_size_t memcapa) { - qse_word_t i; + QSE_MEMSET (stx, 0, QSE_SIZEOF(*stx)); + stx->mmgr = mmgr; - if (stx == QSE_NULL) { - stx = (qse_stx_t*)qse_malloc (qse_sizeof(stx)); - if (stx == QSE_NULL) return QSE_NULL; - stx->__dynamic = qse_true; + /* initialize object memory subsystem */ + if (qse_stx_initmem (stx, memcapa) <= -1) return QSE_NULL; + + /* perform initial bootstrapping */ +/* TODO: if image file is available, load it.... */ + if (qse_stx_boot (stx) <= -1) + { + qse_stx_finimem (stx); + return QSE_NULL; } - else stx->__dynamic = qse_false; - if (qse_stx_memory_open (&stx->memory, capacity) == QSE_NULL) { - if (stx->__dynamic) qse_free (stx); +#if 0 + if (qse_stx_initsymtab (stx, 128) <= -1) + { + qse_stx_finimem (stx); return QSE_NULL; } @@ -26,15 +34,15 @@ qse_stx_t* qse_stx_open (qse_stx_t* stx, qse_word_t capacity) stx->symtab.capacity = 128; /* TODO: symbol table size */ stx->symtab.datum = (qse_word_t*)qse_malloc ( qse_sizeof(qse_word_t) * stx->symtab.capacity); - if (stx->symtab.datum == QSE_NULL) { + if (stx->symtab.datum == QSE_NULL) + { qse_stx_memory_close (&stx->memory); - if (stx->__dynamic) qse_free (stx); return QSE_NULL; } - stx->nil = QSE_STX_NIL; - stx->true = QSE_STX_TRUE; - stx->false = QSE_STX_FALSE; + stx->ref.nil = QSE_STX_NIL; + stx->ref.true = QSE_STX_TRUE; + stx->ref.false = QSE_STX_FALSE; stx->smalltalk = QSE_STX_NIL; @@ -53,18 +61,50 @@ qse_stx_t* qse_stx_open (qse_stx_t* stx, qse_word_t capacity) stx->class_method = QSE_STX_NIL; stx->class_smallinteger = QSE_STX_NIL; - for (i = 0; i < stx->symtab.capacity; i++) { + for (i = 0; i < stx->symtab.capacity; i++) + { stx->symtab.datum[i] = stx->nil; } +#endif - stx->__wantabort = qse_false; + return stx; +} + +void qse_stx_fini (qse_stx_t* stx) +{ + qse_stx_finimem (stx); +} + +qse_stx_t* qse_stx_open ( + qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_size_t memcapa) +{ + qse_stx_t* stx; + + if (mmgr == QSE_NULL) + { + mmgr = QSE_MMGR_GETDFL(); + QSE_ASSERTX (mmgr != QSE_NULL, + "Set the memory manager with QSE_MMGR_SETDFL()"); + if (mmgr == QSE_NULL) return QSE_NULL; + } + + stx = (qse_stx_t*) QSE_MMGR_ALLOC ( + mmgr, QSE_SIZEOF(qse_stx_t) + xtnsize + ); + if (stx == QSE_NULL) return QSE_NULL; + + if (qse_stx_init (stx, mmgr, memcapa) == QSE_NULL) + { + QSE_MMGR_FREE (stx->mmgr, stx); + return QSE_NULL; + } + return stx; } void qse_stx_close (qse_stx_t* stx) { - qse_free (stx->symtab.datum); - qse_stx_memory_close (&stx->memory); - if (stx->__dynamic) qse_free (stx); + qse_stx_fini (stx); + QSE_MMGR_FREE (stx->mmgr, stx); } diff --git a/qse/lib/stx/stx.h b/qse/lib/stx/stx.h index 5e7dd41d..4e7b45e7 100644 --- a/qse/lib/stx/stx.h +++ b/qse/lib/stx/stx.h @@ -1,147 +1,253 @@ /* - * $Id: stx.h 118 2008-03-03 11:21:33Z baconevi $ + * $Id$ */ -#ifndef _QSE_STX_STX_H_ -#define _QSE_STX_STX_H_ +#ifndef _QSE_LIB_STX_STX_H_ +#define _QSE_LIB_STX_STX_H_ -#include -#include +#include -typedef struct qse_stx_objhdr_t qse_stx_objhdr_t; -typedef struct qse_stx_object_t qse_stx_object_t; -typedef struct qse_stx_word_object_t qse_stx_word_object_t; -typedef struct qse_stx_byte_object_t qse_stx_byte_object_t; -typedef struct qse_stx_char_object_t qse_stx_char_object_t; -typedef struct qse_stx_memory_t qse_stx_memory_t; -typedef struct qse_stx_symtab_t qse_stx_symtab_t; -typedef struct qse_stx_t qse_stx_t; +typedef qse_word_t qse_stx_objidx_t; +#define QSE_STX_OBJIDX_INVALID ((qse_stx_objidx_t)-1) + +typedef struct qse_stx_objhdr_t qse_stx_objhdr_t; /* object header */ +typedef struct qse_stx_object_t qse_stx_object_t; /* abstract object */ + +typedef struct qse_stx_object_t* qse_stx_objptr_t; /* object pointer */ +typedef struct qse_stx_byteobj_t* qse_stx_byteobjptr_t; +typedef struct qse_stx_charobj_t* qse_stx_charobjptr_t; +typedef struct qse_stx_wordobj_t* qse_stx_wordobjptr_t; + +#include "mem.h" +#include "obj.h" +#include "sym.h" +#include "boot.h" + +enum qse_stx_objtype_t +{ + QSE_STX_BYTEOBJ = 0, + QSE_STX_CHAROBJ = 1, + QSE_STX_WORDOBJ = 2 +}; +typedef enum qse_stx_objtype_t qse_stx_objtype_t; -/* common object structure */ struct qse_stx_objhdr_t { /* access - type: 2; size: rest; * type - word indexed: 00 byte indexed: 01 char indexed: 10 */ - qse_word_t access; - qse_word_t class; +/* TODO: change the order depending on endian.... */ +/* mark, type(pinter,wordindexed,indexable), reference-count */ +/* +has pointer -> word, byte +variable -> variable, fixed; + +word variable => +char variable => +byte variale => + +byte fixed => not possible +char fixed => not possible +word fixed +*/ + qse_word_t _mark: 1; + qse_word_t _type: 2; + qse_word_t _variable: 1; + qse_word_t _refcnt: (QSE_SIZEOF_WORD_T-4); + + qse_word_t _size; + qse_word_t _class; + qse_word_t _backref; }; struct qse_stx_object_t { - qse_stx_objhdr_t header; + qse_stx_objhdr_t h; }; -struct qse_stx_word_object_t +struct qse_stx_wordobj_t { - qse_stx_objhdr_t header; - qse_word_t data[1]; + qse_stx_objhdr_t h; + qse_word_t fld[1]; }; -struct qse_stx_byte_object_t +struct qse_stx_byteobj_t { - qse_stx_objhdr_t header; - qse_byte_t data[1]; + qse_stx_objhdr_t h; + qse_byte_t fld[1]; }; -struct qse_stx_char_object_t +struct qse_stx_charobj_t { - qse_stx_objhdr_t header; - qse_char_t data[1]; -}; - - -struct qse_stx_memory_t -{ - qse_word_t capacity; - qse_stx_object_t** slots; - qse_stx_object_t** free; - qse_bool_t __dynamic; -}; - -struct qse_stx_symtab_t -{ - qse_word_t* datum; - qse_word_t size; - qse_word_t capacity; + qse_stx_objhdr_t h; + qse_char_t fld[1]; }; struct qse_stx_t { - qse_stx_memory_t memory; - qse_stx_symtab_t symtab; + QSE_DEFINE_COMMON_FIELDS (stx) - qse_word_t nil; - qse_word_t true; - qse_word_t false; + /** error information */ + struct + { + qse_stx_errstr_t str; /**< error string getter */ + qse_stx_errnum_t num; /**< stores an error number */ + qse_char_t msg[128]; /**< error message holder */ + qse_stx_loc_t loc; /**< location of the last error */ + } err; - qse_word_t smalltalk; + struct + { + qse_size_t capa; + qse_stx_objptr_t* slot; + qse_stx_objptr_t* free; + } mem; - qse_word_t class_symbol; - qse_word_t class_metaclass; - qse_word_t class_association; + struct + { + qse_size_t capa; + qse_size_t size; + qse_word_t* slot; + } symtab; - qse_word_t class_object; - qse_word_t class_class; - qse_word_t class_array; - qse_word_t class_bytearray; - qse_word_t class_string; - qse_word_t class_character; - qse_word_t class_context; - qse_word_t class_system_dictionary; - qse_word_t class_method; - qse_word_t class_smallinteger; + struct + { + qse_word_t nil; + qse_word_t true; + qse_word_t false; + + qse_word_t symtab; /* symbol table */ + qse_word_t sysdic; /* system dictionary */ + + qse_word_t class_symbol; + qse_word_t class_metaclass; + qse_word_t class_association; + + qse_word_t class_object; + qse_word_t class_class; + qse_word_t class_array; + qse_word_t class_bytearray; + qse_word_t class_string; + qse_word_t class_character; + qse_word_t class_context; + qse_word_t class_system_dictionary; + qse_word_t class_method; + qse_word_t class_smallinteger; + } ref; - qse_bool_t __dynamic; qse_bool_t __wantabort; /* TODO: make it a function pointer */ }; -#define QSE_STX_IS_SMALLINT(x) (((x) & 0x01) == 0x01) -#define QSE_STX_TO_SMALLINT(x) (((x) << 1) | 0x01) -#define QSE_STX_FROM_SMALLINT(x) ((x) >> 1) +/** + * The QSE_STX_REFISINT macro determines if the object reference is encoded + * of a small integer by checking if the bit 0 is on. + */ +#define QSE_STX_REFISINT(stx,x) (((x) & 0x01) == 0x01) +/** + * The QSE_STX_INTTOREF macro encodes a small integer to an object reference. + */ +#define QSE_STX_INTTOREF(stx,x) (((x) << 1) | 0x01) +/** + * The QSE_STX_REFTOINT macro decodes an object reference to a small integer. + */ +#define QSE_STX_REFTOINT(stx,x) ((x) >> 1) -#define QSE_STX_IS_OINDEX(x) (((x) & 0x01) == 0x00) -#define QSE_STX_TO_OINDEX(x) (((x) << 1) | 0x00) -#define QSE_STX_FROM_OINDEX(x) ((x) >> 1) +/** + * The QSE_STX_REFISIDX macro determines if the object reference is encoded + * of an object table index by checking if the bit 0 is off. + */ +#define QSE_STX_REFISIDX(stx,x) (((x) & 0x01) == 0x00) +/** + * The QSE_STX_IDXTOREF macro encodes a object table index to an object + * reference. + */ +#define QSE_STX_IDXTOREF(stx,x) (((x) << 1) | 0x00) +/** + * The QSE_STX_REFTOIDX macro decodes an object reference to a object + * table index. + */ +#define QSE_STX_REFTOIDX(stx,x) ((x) >> 1) -#define QSE_STX_NIL QSE_STX_TO_OINDEX(0) -#define QSE_STX_TRUE QSE_STX_TO_OINDEX(1) -#define QSE_STX_FALSE QSE_STX_TO_OINDEX(2) +/* get the object pointer by the raw object table index */ +#define QSE_STX_PTRBYIDX(stx,x) ((stx)->mem.slot[x]) +/* get the object pointer by the encoded object table index */ +#define QSE_STX_PTRBYREF(stx,x) QSE_STX_PTRBYIDX(stx,QSE_STX_REFTOIDX(stx,x)) -#define QSE_STX_OBJECT(stx,idx) (((stx)->memory).slots[QSE_STX_FROM_OINDEX(idx)]) -#define QSE_STX_CLASS(stx,idx) (QSE_STX_OBJECT(stx,(idx))->header.class) -#define QSE_STX_ACCESS(stx,idx) (QSE_STX_OBJECT(stx,(idx))->header.access) -#define QSE_STX_DATA(stx,idx) ((void*)(QSE_STX_OBJECT(stx,idx) + 1)) +#define QSE_STX_OBJTYPE(stx,ref) (QSE_STX_PTRBYREF(stx,ref)->h._type) +#define QSE_STX_OBJSIZE(stx,ref) (QSE_STX_PTRBYREF(stx,ref)->h._size) +#define QSE_STX_OBJCLASS(stx,ref) (QSE_STX_PTRBYREF(stx,ref)->h._class) -#define QSE_STX_TYPE(stx,idx) (QSE_STX_ACCESS(stx,idx) & 0x03) -#define QSE_STX_SIZE(stx,idx) (QSE_STX_ACCESS(stx,idx) >> 0x02) +#define QSE_STX_WORDAT(stx,ref,pos) \ + (((qse_stx_wordobjptr_t)QSE_STX_PTRBYREF(stx,ref))->fld[pos]) +#define QSE_STX_BYTEAT(stx,ref,pos) \ + (((qse_stx_byteobjptr_t)QSE_STX_PTRBYREF(stx,ref))->fld[pos]) +#define QSE_STX_CHARAT(stx,ref,pos) \ + (((qse_stx_charobjptr_t)QSE_STX_PTRBYREF(stx,ref))->fld[pos]) + + +/* REDEFINITION DROPPING PREFIX FOR INTERNAL USE */ +#define REFISINT(stx,x) QSE_STX_REFISINT(stx,x) +#define INTTOREF(stx,x) QSE_STX_INTTOREF(stx,x) +#define REFTOINT(stx,x) QSE_STX_REFTOINT(stx,x) + +#define REFISIDX(stx,x) QSE_STX_REFISIDX(stx,x) +#define IDXTOREF(stx,x) QSE_STX_IDXTOREF(stx,x) +#define REFTOIDX(stx,x) QSE_STX_REFTOIDX(stx,x) + +#define PTRBYREF(stx,x) QSE_STX_PTRBYREF(stx,x) +#define PTRBYIDX(stx,x) QSE_STX_PTRBYIDX(stx,x) + +#define OBJTYPE(stx,ref) QSE_STX_OBJTYPE(stx,ref) +#define OBJCLASS(stx,ref) QSE_STX_OBJCLASS(stx,ref) +#define OBJSIZE(stx,ref) QSE_STX_OBJSIZE(stx,ref) + +#define BYTEAT(stx,ref,pos) QSE_STX_BYTEAT(stx,ref,pos) +#define CHARAT(stx,ref,pos) QSE_STX_CHARAT(stx,ref,pos) +#define WORDAT(stx,ref,pos) QSE_STX_WORDAT(stx,ref,pos) + +#define BYTEOBJ QSE_STX_BYTEOBJ +#define CHAROBJ QSE_STX_CHAROBJ +#define WORDOBJ QSE_STX_WORDOBJ + +#if 0 +/* hardcoded object reference */ +#define QSE_STX_NIL(stx) QSE_STX_IDXTOREF(stx,0) +#define QSE_STX_TRUE(stx) QSE_STX_IDXTOREF(stx,1) +#define QSE_STX_FALSE(stx) QSE_STX_IDXTOREF(stx,2) + +#define QSE_STX_DATA(stx,idx) ((void*)(QSE_STX_OBJPTR(stx,idx) + 1)) +#endif + + +#if 0 #define QSE_STX_WORD_INDEXED (0x00) #define QSE_STX_BYTE_INDEXED (0x01) #define QSE_STX_CHAR_INDEXED (0x02) -#define QSE_STX_IS_WORD_OBJECT(stx,idx) \ +/* this type has nothing to do with + * the indexability of the object... */ +enum qse_stx_objtype_t +{ + QSE_STX_OBJTYPE_BYTE, + QSE_STX_OBJTYPE_CHAR, + QSE_STX_OBJTYPE_WORD +}; + +#define QSE_STX_ISWORDOBJECT(stx,idx) \ (QSE_STX_TYPE(stx,idx) == QSE_STX_WORD_INDEXED) -#define QSE_STX_IS_BYTE_OBJECT(stx,idx) \ +#define QSE_STX_ISBYTEOBJECT(stx,idx) \ (QSE_STX_TYPE(stx,idx) == QSE_STX_BYTE_INDEXED) -#define QSE_STX_IS_CHAR_OBJECT(stx,idx) \ +#define QSE_STX_ISCHAROBJECT(stx,idx) \ (QSE_STX_TYPE(stx,idx) == QSE_STX_CHAR_INDEXED) -#define QSE_STX_WORD_OBJECT(stx,idx) \ - ((qse_stx_word_object_t*)QSE_STX_OBJECT(stx,idx)) -#define QSE_STX_BYTE_OBJECT(stx,idx) \ - ((qse_stx_byte_object_t*)QSE_STX_OBJECT(stx,idx)) -#define QSE_STX_CHAR_OBJECT(stx,idx) \ - ((qse_stx_char_object_t*)QSE_STX_OBJECT(stx,idx)) +#define QSE_STX_WORDOBJPTR(stx,idx) \ + ((qse_stx_word_object_t*)QSE_STX_OBJPTR(stx,idx)) +#define QSE_STX_BYTEOBJPTR(stx,idx) \ + ((qse_stx_byte_object_t*)QSE_STX_OBJPTR(stx,idx)) +#define QSE_STX_CHAROBJPTR(stx,idx) \ + ((qse_stx_char_object_t*)QSE_STX_OBJPTR(stx,idx)) -/* -#define QSE_STX_WORD_AT(stx,idx,n) \ - (((qse_word_t*)(QSE_STX_OBJECT(stx,idx) + 1))[n]) -#define QSE_STX_BYTE_AT(stx,idx,n) \ - (((qse_byte_t*)(QSE_STX_OBJECT(stx,idx) + 1))[n]) -#define QSE_STX_CHAR_AT(stx,idx,n) \ - (((qse_char_t*)(QSE_STX_OBJECT(stx,idx) + 1))[n]) -*/ #define QSE_STX_WORD_AT(stx,idx,n) \ (QSE_STX_WORD_OBJECT(stx,idx)->data[n]) #define QSE_STX_BYTE_AT(stx,idx,n) \ @@ -149,12 +255,15 @@ struct qse_stx_t #define QSE_STX_CHAR_AT(stx,idx,n) \ (QSE_STX_CHAR_OBJECT(stx,idx)->data[n]) +#endif + #ifdef __cplusplus extern "C" { #endif -qse_stx_t* qse_stx_open (qse_stx_t* stx, qse_word_t capacity); -void qse_stx_close (qse_stx_t* stx); +/* + * + */ #ifdef __cplusplus } diff --git a/qse/lib/stx/sym.c b/qse/lib/stx/sym.c new file mode 100644 index 00000000..5e9a5d18 --- /dev/null +++ b/qse/lib/stx/sym.c @@ -0,0 +1,172 @@ +/* + * $Id$ + */ + +#include "stx.h" +#include + +/* Implements global symbol table */ + +struct qse_stx_symtab_t +{ + qse_stx_objhdr_t h; + qse_word_t tally; + qse_word_t slot[1]; +}; + +typedef struct qse_stx_symtab_t qse_stx_symtab_t; + +qse_word_t qse_stx_newsymbol ( + qse_stx_t* stx, qse_word_t tabref, const qse_char_t* name) +{ + qse_stx_symtab_t* tabptr; + qse_word_t symref; + qse_stx_charobjptr_t symptr; + qse_word_t capa, hash, count; + +#if 0 + /* the table must have at least one slot excluding the tally field */ + QSE_ASSERT (QSE_STX_OBJSIZE(stx,tab) > 1); +#endif + + tabptr = (qse_stx_symtab_t*) PTRBYREF (stx, tabref); + + capa = tabptr->h._size - 1; /* exclude the tally field */ + hash = qse_stx_hashstr (stx, name) % capa; + + for (count = 0; count < capa; count++) + { + symref = tabptr->slot[hash]; + if (symref == stx->ref.nil) break; /* not found */ + + symptr = (qse_stx_charobjptr_t) PTRBYREF (stx, symref); + QSE_ASSERT (symptr->h._type == QSE_STX_CHAROBJ); + + if (qse_strcmp (name, symptr->fld) == 0) return symref; + + hash = (hash + 1) % capa; + } + + if (tabptr->tally >= capa) + { +#if 0 + if (grow (stx, tab) <= -1) return -1; + /* refresh tally */ + tally = QSE_STX_REFTOINT(QSE_STX_WORDAT(stx,tab,QSE_STX_SET_TALLY)); +#endif + } + + symref = qse_stx_alloccharobj (stx, name, qse_strlen(name)); + if (symref != stx->ref.nil) + { + OBJCLASS(stx,symref) = stx->ref.class_symbol; + tabptr->slot[hash] = symref; + } + return symref; +} + +#if 0 +#include "stx.h" + +static int __grow_symtab (qse_stx_t* stx) +{ + qse_word_t capa, ncapa, i, j; + qse_word_t* nspace; + + capa = stx->symtab.capa; + ncapa = capa << 1; /* double the capacity */ + +/* TODO: allocate symbol table from stx->mem......... */ + nspace = (qse_word_t*) QSE_MMGR_ALLOC ( + stx->mmgr, ncapa * QSE_SIZEOF(*nspace) + ); + if (nspace == QSE_NULL) + { + /* TODO: handle memory error */ + qse_stx_seterrnum (stx, QSE_STX_ENOMEM); + return -1; + } + + for (i = 0; i < capa; i++) + { + qse_word_t x = stx->symtab.slot[i]; + if (x == stx->nil) continue; + + j = qse_stx_strxhash ( + QSE_STX_DATA(stx,x), QSE_STX_SIZE(stx,x)) % ncapa; + + while (1) + { + if (nspace[j] == stx->nil) + { + nspace[j] = x; + break; + } + j = (j % ncapa) + 1; + } + } + + stx->symtab.capa = ncapa; + QSE_MMGR_FREE (stx->mmgr, stx->symtab.slot); + stx->symtab.slot = nspace; + + return 0; +} + +qse_word_t qse_stx_newsym (qse_stx_t* stx, const qse_char_t* name) +{ + return qse_stx_newsymwithlen (stx, name, qse_strlen(name)); +} + +qse_word_t qse_stx_newsymwithlen (qse_stx_t* stx, const qse_char_t* name, qse_word_t len) +{ + qse_word_t capa, hash, index, size, x; + + capa = stx->symtab.capa; + size = stx->symtab.size; + + if (capa <= size + 1) + { + if (__grow_symtab (stx) <= -1) + { +/* TODO: .... */ + } + capa = stx->symtab.capa; + } + + hash = qse_stx_strxhash(name,len); + index = hash % stx->symtab.capa; + + while (1) + { + x = stx->symtab.slot[index]; + if (x == stx->nil) + { + /* insert a new item into an empty slot */ + x = qse_stx_alloc_char_objectx (stx, name, len); + QSE_STX_CLASS(stx,x) = stx->class_symbol; + stx->symtab.slot[index] = x; + stx->symtab.size++; + break; + } + + if (qse_strxncmp (name, len, QSE_STX_DATA(stx,x), QSE_STX_SIZE(stx,x)) == 0) break; + + index = (index % stx->symtab.capa) + 1; + } + + return x; +} + +void qse_stx_traverse_symbol_table ( + qse_stx_t* stx, void (*func) (qse_stx_t*,qse_word_t,void*), void* data) +{ + qse_word_t index, x; + + for (index = 0; index < stx->symtab.capa; index++) + { + x = stx->symtab.slot[index]; + if (x != stx->nil) func (stx, x, data); + } +} +#endif diff --git a/qse/lib/stx/sym.h b/qse/lib/stx/sym.h new file mode 100644 index 00000000..0fd87692 --- /dev/null +++ b/qse/lib/stx/sym.h @@ -0,0 +1,22 @@ +/* + * $Id: symbol.h 118 2008-03-03 11:21:33Z baconevi $ + */ + +#ifndef _QSE_LIB_STX_SYM_H_ +#define _QSE_LIB_STX_SYM_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +qse_word_t qse_stx_newsymbol ( + qse_stx_t* stx, + qse_word_t tabref, + const qse_char_t* name +); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/qse/samples/Makefile.am b/qse/samples/Makefile.am index dd966741..d6c4ff16 100644 --- a/qse/samples/Makefile.am +++ b/qse/samples/Makefile.am @@ -1 +1 @@ -SUBDIRS = cmn awk cut sed http +SUBDIRS = cmn awk cut sed diff --git a/qse/samples/Makefile.in b/qse/samples/Makefile.in index 3a6467c1..f77c2f79 100644 --- a/qse/samples/Makefile.in +++ b/qse/samples/Makefile.in @@ -226,7 +226,7 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -SUBDIRS = cmn awk cut sed http +SUBDIRS = cmn awk cut sed all: all-recursive .SUFFIXES: