diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-05-06 06:47:30 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-05-06 06:47:30 -0700 |
commit | 209e731429a0fd890ec6d922c1efc6f02d81a032 (patch) | |
tree | 55302eeaaaf8ee7e0fdc7add129f2e6c68756f27 /Makefile | |
parent | f7aaccf9231081e840987be9b1e5922592b147e6 (diff) | |
download | txr-209e731429a0fd890ec6d922c1efc6f02d81a032.tar.gz txr-209e731429a0fd890ec6d922c1efc6f02d81a032.tar.bz2 txr-209e731429a0fd890ec6d922c1efc6f02d81a032.zip |
New macro-based framework for assignment places.
The operators set, inc, dec, pop and others are now macros
which generate code, rather than built-in special forms
that use "C magic". Moreover, new such macros are easy to write, and
several new ones are already available. Moreover, new kinds of
assignable places are easy to create.
* place.tl: New file.
* lisplib.c, lisplib.h: New files.
* Makefile (OBJS): New target, lisplib.o.
(GEN_HDRS): New variable.
(LISP_TO_C_STRING): New recipe macro, with rule.
(clean): Remove generated headers named in $(GEN_HDRS).
* eval.c (dec_s, push_s, pop_s, flip_s, del_s): Variables removed.
(setq_s): New variable.
(lookup_var, lokup_sym_lisp_1, lookup_var_l, lookup_fun, lookup_mac,
lookup_symac, lookup_symac_lisp1): Trigger the delayed loading of
libraries for undefined global symbols, and re-try the lookup.
(op_modplace, dwim_loc, force_l): Static functions removed.
(op_setq): New static function.
(eval_init): Initialize setq_s; remove initializations of
removed variables; remove registrations for op_modplace;
add registration for sys:setq, sys:rplaca, sys:rplacd,
sys:dwim-set and sys:dwim-del intrinsics.
Call lisplib_init to initialize the dynamic library loading module.
* lib.c (sys_rplaca, sys_rplacd): New functions, differing
in return value from rplaca and rplacd.
(ref, refset): Handle hash table.
(dwim_set, dwim_del): New functions.
* lib.h (sys_rplaca, sys_rplacd, dwim_set, dwim_del): Declared.
* genvim.txr: Include place.tl in scan.
* tests/010/seq.txr: The del operator test
case no longer throws at run-time but at macro-expansion time, so the
test case is simply removed.
* tests/010/seq.expected: Updated output.
* tests/011/macros-2.txr: Reset *gensym-counter* to zero, because
the textual output of the test case includes gensyms, whose numberings
fluctuate with the content of the new Lisp library material.
* tests/011/macros-2.expected: Updated output.
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -46,11 +46,13 @@ EXTRA_OBJS-y := OBJS := txr.o lex.yy.o y.tab.o match.o lib.o regex.o gc.o unwind.o stream.o OBJS += arith.o hash.o utf8.o filter.o eval.o parser.o rand.o combi.o sysif.o +OBJS += lisplib.o OBJS-$(debug_support) += debug.o OBJS-$(have_syslog) += syslog.o OBJS-$(have_glob) += glob.o OBJS-$(have_posix_sigs) += signal.o EXTRA_OBJS-$(add_win_res) += win/txr.res +GEN_HDRS := place.h ifneq ($(have_git),) SRCS := $(addprefix $(top_srcdir)/,\ @@ -106,6 +108,14 @@ $(call ABBREV,LINK) $(V)$(CC) $(1) $(CFLAGS) -o $@ $^ -lm endef +define LISP_TO_C_STRING +$(call ABBREV,L2C) +$(V)echo "const wchli_t *${@:.h=}_code = wli(" > $@ +$(V)sed -n -e '/^(/,$$p' $< | \ + sed -e 's/["\\]/\\&/g' -e 's/$$/\\n/' -e 's/.*/"&"/' >> $@ +$(V)echo ");" >> $@ +endef + define WINDRES $(call ABBREV,RES) $(V)mkdir -p $(dir $@) @@ -130,6 +140,9 @@ opt/%.res: win/%.rc %.res: %.rc $(call WINDRES) +%.h: %.tl + $(call LISP_TO_C_STRING) + # The following pattern rule is used for test targets built by configure %.o: %.c $(call COMPILE_C) @@ -156,6 +169,10 @@ $(PROG)-win: $(patsubst %/txr.o,%/txr-win.o,$(OPT_OBJS)) $(EXTRA_OBJS-y) $(PROG)-win-dbg: $(patsubst %/txr.o,%/txr-win.o,$(DBG_OBJS)) $(EXTRA_OBJS-y) $(call LINK_PROG,-mwindows) +$(call ADD_CONF,dbg,lisplib.o): $(GEN_HDRS) + +$(call ADD_CONF,opt,lisplib.o): $(GEN_HDRS) + VPATH := $(top_srcdir) # Newline constant @@ -226,12 +243,13 @@ distclean: rm -rf config rm -rf config.* rm -rf mpi-1.?.? + rm -rf $(GEN_HDRS) else rebuild: clean repatch $(PROG) clean: conftest.clean tests.clean rm -f $(PROG)$(EXE) $(PROG)-dbg$(EXE) y.tab.c lex.yy.c y.tab.h y.output - rm -rf opt dbg $(EXTRA_OBJS-y) + rm -rf opt dbg $(EXTRA_OBJS-y) $(GEN_HDRS) distclean: clean rm -rf $(conf_dir) |