klisp

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

commit a5918fe39a773464b182e961730a38cf591022b7
parent c8dd66263abdb1fdbc3d477ddad15eb212abbc21
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Wed, 16 Mar 2011 15:37:04 -0300

Added make-keyed-dynamic-variable to the ground environment.

Diffstat:
Msrc/Makefile | 7+++++--
Msrc/kgcontinuations.h | 4++++
Asrc/kgkd_vars.h | 25+++++++++++++++++++++++++
Msrc/kground.c | 18+++++++++++++++---
4 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/src/Makefile b/src/Makefile @@ -14,7 +14,7 @@ CORE_O= kobject.o ktoken.o kpair.o kstring.o ksymbol.o kread.o \ kground.o kghelpers.o kgbooleans.o kgeqp.o kgequalp.o \ kgsymbols.o kgcontrol.o kgpairs_lists.o kgpair_mut.o kgenvironments.o \ kgenv_mut.o kgcombiners.o kgcontinuations.o kgencapsulations.o \ - kgpromises.o + kgpromises.o kgkd_vars.o KRN_T= klisp KRN_O= klisp.o @@ -77,7 +77,7 @@ kground.o: kground.c kground.h kstate.h kobject.h klisp.h kenvironment.h \ kapplicative.h koperative.h ksymbol.h kerror.h kghelpers.h \ kgbooleans.h kgeqp.h kgequalp.h kgsymbols.h kgpairs_lists.h \ kgpair_mut.h kgenvironments.h kgenv_mut.h kgcombiners.h \ - kgcontinuations.h kgencapsulations.h kgpromises.h + kgcontinuations.h kgencapsulations.h kgpromises.h kgkd_vars.h kghelpers.o: kghelpers.c kghelpers.h kstate.h kstate.h klisp.h kpair.h \ kapplicative.h koperative.h kerror.h kobject.h ksymbol.h kgbooleans.o: kgbooleans.c kgbooleans.c kghelpers.h kstate.h klisp.h \ @@ -112,3 +112,6 @@ kgencapsulations.o: kgencapsulations.c kgencapsulations.h kghelpers.h \ kgpromises.o: kgpromises.c kgpromises.h kghelpers.h kstate.h klisp.h \ kobject.h kerror.h kapplicative.h koperative.h kcontinuation.h \ kpair.h kpromise.h +kgkd_vars.o: kgkd_vars.c kgkd_vars.h kghelpers.h kstate.h klisp.h \ + kobject.h kerror.h kapplicative.h koperative.h kcontinuation.h \ + kpair.h kenvironment.h kgcontinuations.h diff --git a/src/kgcontinuations.h b/src/kgcontinuations.h @@ -18,6 +18,10 @@ #include "kstate.h" #include "kghelpers.h" +/* Helpers (also used in keyed dynamic code */ +void pass_value(klisp_State *K, TValue *xparams, TValue obj); + + /* 7.1.1 continuation? */ /* uses typep */ diff --git a/src/kgkd_vars.h b/src/kgkd_vars.h @@ -0,0 +1,25 @@ +/* +** kgkd_vars.h +** Keyed Dynamic Variables features for the ground environment +** See Copyright Notice in klisp.h +*/ + +#ifndef kgkd_vars_h +#define kgkd_vars_h + +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> +#include <stdint.h> + +#include "kobject.h" +#include "klisp.h" +#include "kstate.h" +#include "kghelpers.h" + +/* 10.1.1 make-keyed-dynamic-variable */ +void make_keyed_dynamic_variable(klisp_State *K, TValue *xparams, + TValue ptree, TValue denv); + +#endif diff --git a/src/kground.c b/src/kground.c @@ -33,6 +33,7 @@ #include "kgcontinuations.h" #include "kgencapsulations.h" #include "kgpromises.h" +#include "kgkd_vars.h" /* ** BEWARE: this is highly unhygienic, it assumes variables "symbol" and @@ -413,8 +414,6 @@ void kinit_ground_env(klisp_State *K) add_applicative(K, ground_env, "make-encapsulation-type", make_encapsulation_type, 0); - - /* ** ** 9 Promises @@ -425,7 +424,6 @@ void kinit_ground_env(klisp_State *K) ** 9.1 Library features */ - /* 9.1.1 promise? */ add_applicative(K, ground_env, "promise?", typep, 2, symbol, i2tv(K_TPROMISE)); @@ -439,6 +437,20 @@ void kinit_ground_env(klisp_State *K) /* 9.1.4 memoize */ add_applicative(K, ground_env, "memoize", memoize, 0); + /* + ** + ** 10 Keyed Dynamic Variables + ** + */ + + /* + ** 10.1 Primitive features + */ + + /* 10.1.1 make-keyed-dynamic-variable */ + add_applicative(K, ground_env, "make-keyed-dynamic-variable", + make_keyed_dynamic_variable, 0); + return; }