klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit 2f4dba85227938e51620d6818a2c718ea82c80c8
parent 381168551af04f57d0976e1cae57b65803e86056
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Thu, 28 Apr 2011 19:23:37 -0300

Added provisory automatic naming of operatives after applicatives that wrap around them.

Diffstat:
Msrc/Makefile | 2+-
Msrc/kenvironment.c | 17+++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/Makefile b/src/Makefile @@ -68,7 +68,7 @@ kmem.o: kmem.c kmem.h klisp.h kerror.h klisp.h kstate.h kgc.h klispconf.h kerror.o: kerror.c kerror.h klisp.h kstate.h klisp.h kmem.h kstring.h kpair.h kauxlib.o: kauxlib.c kauxlib.h klisp.h kstate.h klisp.h kenvironment.o: kenvironment.c kenvironment.h kpair.h kobject.h kerror.h \ - kmem.h kstate.h klisp.h kgc.h ktable.h klispconf.h + kmem.h kstate.h klisp.h kgc.h ktable.h klispconf.h kapplicative.h kcontinuation.o: kcontinuation.c kcontinuation.h kmem.h kstate.h kobject.h \ klisp.h kgc.h koperative.o: koperative.c koperative.h kmem.h kstate.h kobject.h \ diff --git a/src/kenvironment.c b/src/kenvironment.c @@ -15,6 +15,7 @@ #include "kmem.h" #include "ktable.h" #include "kgc.h" +#include "kapplicative.h" /* keyed dynamic vars */ #define env_keyed_parents(env_) (tv2env(env_)->keyed_parents) @@ -121,6 +122,22 @@ void try_set_name(klisp_State *K, TValue obj, TValue sym) gcvalue(obj)->gch.kflags |= K_FLAG_HAS_NAME; TValue *node = klispH_set(K, tv2table(K->name_table), obj); *node = sym; + + /* TEMP: use this until we have a general mechanism to add + objects to be named after some other obj */ + if (ttisapplicative(obj)) { + /* underlying is rooted by means of obj */ + TValue underlying = kunwrap(obj); + while (kcan_have_name(underlying) && !khas_name(underlying)) { + gcvalue(underlying)->gch.kflags |= K_FLAG_HAS_NAME; + node = klispH_set(K, tv2table(K->name_table), underlying); + *node = sym; + if (ttisapplicative(underlying)) + underlying = kunwrap(underlying); + else + break; + } + } } } #endif