Accepted update test db for error messages
[Klink.git] / klink-private.h
blob9c3e78e196e4ab87bb88c395e33e6106787f7b55
1 /*_. Klink 0.0: klink-private.h */
2 /*_ , Header */
3 /*_ . Purpose */
4 /* Private internal definitions */
5 /*_ . Credits and License */
6 /*
7 Copyright (C) 2010,2011 Tom Breton (Tehom)
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 /*_ . Once */
25 #ifndef _KLINK_PRIVATE_H
26 #define _KLINK_PRIVATE_H
28 /*_ . Own includes */
30 #include "klink.h"
31 #include <setjmp.h>
33 /*_ . C++ nonmangling */
34 #ifdef __cplusplus
35 extern "C"
37 #endif
39 /*_ , Body */
40 /*_ . Ubiquitous objects */
41 pko K_T;
42 pko K_F;
43 pko K_NIL;
44 pko K_EOF;
45 pko K_INERT;
46 pko K_IGNORE;
48 /*_ . Structs */
50 /*_ , Stack cells */
52 typedef struct dump_stack_frame_cell * _kt_spagstack;
55 /*_ , The interpreter itself */
57 struct klink
59 /** True internal variables **/
60 _kt_spagstack dump; /* The dynamic stack (Really one leaf
61 of a spaghetti stack). The center
62 of the interpreter. */
63 int done; /* Whether eval loop should stop. */
64 jmp_buf pseudocontinuation; /* longjmping here goes directly to
65 next eval loop iteration. (Or
66 terminates, if we're not in eval
67 loop) */
69 /* Caches of ground-environment variables, provided for built-ins. */
70 pko error_continuation; /* What to do on error. */
71 /* Don't seem to can use a root_continuation cache. */
73 /** Caches and pseudo-caches of dynamic variables **/
74 int tracing; /* Are we tracing? */
75 int new_tracing; /* Are we tracing? */
76 pko fail_continuation; /* Logical fail */
78 pko envir; /* Current environment. No cache key; it's
79 always in use so we don't deep-store it.
80 But conceptually it's a dynamic variable. */
82 /* Unused for now. */
83 pko ca_inport; /* Will become just a cache */
84 pko ca_outport; /* Same */
85 pko ca_nesting; /* Same */
87 /** Obsolescent **/
88 /* global pointers to special symbols */
89 pko QUOTE; /* pointer to syntax quote */
91 pko QQUOTE; /* pointer to symbol quasiquote */
92 pko UNQUOTE; /* pointer to symbol unquote */
93 pko UNQUOTESP; /* pointer to symbol unquote-splicing */
94 pko COLON_HOOK; /* *colon-hook* */
95 pko SHARP_HOOK; /* *sharp-hook* */
97 /*** Scratch variables ***/
98 #define LINESIZE 1024
99 char linebuff[LINESIZE];
100 #define STRBUFFSIZE 256
101 char strbuff[STRBUFFSIZE];
103 /** Special-purpose pseudo-passing **/
104 int tok; /* Token from tokenizer to read */
105 pko value; /* Value from longjmp to eval
106 loop iteration */
107 pko next_func; /* Next functor, from frame pop to
108 eval loop iteration */
109 int retcode; /* return code, from exit operation to
110 true termination. */
112 void *ext_data; /* For the benefit of foreign functions */
113 struct klink_interface *vptr;
116 /*_ . Function signatures */
118 int is_string (pko p);
119 char *string_value (pko p);
120 int is_number (pko p);
121 num nvalue (pko p);
122 long ivalue (pko p);
123 double rvalue (pko p);
124 int is_integer (pko p);
125 int is_real (pko p);
126 int is_character (pko p);
127 long charvalue (pko p);
128 int is_vector (pko p);
130 int is_port (pko p);
132 int is_pair (pko p);
133 pko pair_car (klink * sc, pko p);
134 pko pair_cdr (klink * sc, pko p);
135 pko set_car (klink * sc, pko p, pko q);
136 pko set_cdr (klink * sc, pko p, pko q);
138 int is_symbol (pko p);
139 char *symname (klink * sc, pko p);
143 int is_continuation (pko p);
144 int is_promise (pko p);
145 int is_environment (pko p);
146 int is_immutable (pko p);
147 void setimmutable (pko p);
150 /*_ , Footers */
151 /*_ . End nonmangling */
152 #ifdef __cplusplus
154 #endif
156 /*_ . End Once */
158 #endif
161 Local variables:
162 c-file-style: "gnu"
163 mode: allout
164 End: