klisp

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

klibrary.c (702B)


      1 /*
      2 ** klibrary.c
      3 ** Kernel Libraries
      4 ** See Copyright Notice in klisp.h
      5 */
      6 
      7 #include "kobject.h"
      8 #include "kstate.h"
      9 #include "klibrary.h"
     10 #include "kmem.h"
     11 #include "kgc.h"
     12 
     13 /* GC: Assumes env & ext_list are roooted */
     14 /* ext_list should be immutable (and it may be empty) */
     15 TValue kmake_library(klisp_State *K, TValue env, TValue exp_list)
     16 {
     17     klisp_assert(ttisnil(exp_list) || kis_immutable(exp_list));
     18     Library *new_lib = klispM_new(K, Library);
     19 
     20     /* header + gc_fields */
     21     klispC_link(K, (GCObject *) new_lib, K_TLIBRARY, 
     22                 K_FLAG_CAN_HAVE_NAME);
     23 
     24     /* library specific fields */
     25     new_lib->env = env;
     26     new_lib->exp_list = exp_list;
     27     return gc2lib(new_lib);
     28 }