klisp

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

kenvironment.h (1339B)


      1 /*
      2 ** kenvironment.h
      3 ** Kernel Environments
      4 ** See Copyright Notice in klisp.h
      5 */
      6 
      7 #ifndef kenvironment_h
      8 #define kenvironment_h
      9 
     10 #include "kobject.h"
     11 #include "kstate.h"
     12 
     13 /* GC: Assumes parents is rooted */
     14 TValue kmake_environment(klisp_State *K, TValue parents);
     15 #define kmake_empty_environment(kst_) (kmake_environment(kst_, KNIL))
     16 void kadd_binding(klisp_State *K, TValue env, TValue sym, TValue val);
     17 TValue kget_binding(klisp_State *K, TValue env, TValue sym);
     18 bool kbinds(klisp_State *K, TValue env, TValue sym);
     19 /* keyed dynamic vars */
     20 /* GC: Assumes parents, key & val are rooted */
     21 TValue kmake_keyed_static_env(klisp_State *K, TValue parent, TValue key, 
     22                               TValue val);
     23 TValue kget_keyed_static_var(klisp_State *K, TValue env, TValue key);
     24 
     25 /* environments with hashtable bindings */
     26 /* TEMP: for now only for ground & std environments
     27    TODO: Should profile too see when it makes sense & should add code 
     28    to all operatives creating environments to see when it's appropriate 
     29    or should add code to add binding to at certain point move over to 
     30    hashtable */
     31 TValue kmake_table_environment(klisp_State *K, TValue parents);
     32 
     33 #if KTRACK_NAMES
     34 void ktry_set_name(klisp_State *K, TValue obj, TValue sym);
     35 /* assumes it has a name */
     36 TValue kget_name(klisp_State *K, TValue obj);
     37 #endif
     38 
     39 #endif