Lhogho  0.0.028
 All Data Structures Files Functions Variables Typedefs Macros Pages
vars.h
Go to the documentation of this file.
1 //
2 // Project: Lhogho
3 // File: vars.h
4 //
5 // Copyright (C) 2007 P.Boytchev
6 //
7 // Revision history:
8 // 2007-02-27 - file created
9 // 2007-03-19 - PRIORITY_*
10 // 2007-05-17 - license info
11 // 2007-05-22 - doxygen-friendly documentation
12 // 2007-05-29 - find_local_var()
13 // 2007-06-06 - definitions spread to where they belong
14 // 2007-06-09 - added dump_var()
15 // 2007-06-18 - new_local_var()
16 // 2007-08-07 - BASE_OFFSET_PARAMS, BASE_OFFSET_LOCALS
17 // 2007-08-13 - globals, printdepthlimit, printwidthlimit,
18 // fullprintp;
19 // 2007-09-15 - caseignoredp
20 // 2007-12-14 - Support for FULLTEXT
21 // 2011-10-13 - Fixed Doxygen warnings
22 // 2011-12-26 - Support for SUBSTRING
23 // 2012-01-05 - More synonyms for primitives
24 //
25 //
26 // This program is free software; you can redistribute it and/or modify
27 // it under the terms of the GNU General Public License as published by
28 // the Free Software Foundation; either version 2 of the License, or
29 // (at your option) any later version.
30 //
31 // This program is distributed in the hope that it will be useful,
32 // but WITHOUT ANY WARRANTY; without even the implied warranty of
33 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 // GNU General Public License for more details.
35 //
36 // You should have received a copy of the GNU General Public License
37 // along with this program; if not, write to the Free Software
38 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
39 //
40 
41 
42 #ifndef LHOGHO_VARS_H
43 #define LHOGHO_VARS_H
44 
45 
46 
47 //===================================================
49 //===================================================
50 #define PRIORITY_VAR 6
51 #define PRIORITY_MUL 5
52 #define PRIORITY_ADD 4
53 #define PRIORITY_FUN 3
54 #define PRIORITY_CMP 2
55 #define PRIORITY_LOG 1
56 #define PRIORITY_CMD 0
57 
58 #define PRIORITY_MAX PRIORITY_VAR
59 #define PRIORITY_MIN PRIORITY_CMD
60 
61 
62 
63 
64 //===================================================
69 //===================================================
70 #define OFFSET_DESCR1 8
71 #define OFFSET_ADDRESS 12
72 
73 #define DESCR1(x) ((x)->unode.a[2])
74 #define DESCR2(x) ((x)->unode.a[3])
75 #define PARENT(x) (DESCR1(x)->unode.a[0])
76 #define NAME(x) (DESCR1(x)->unode.a[2])
77 #define ADDRESS(x) (DESCR1(x)->unode.n[3])
78 #define OFFSET(x) (DESCR1(x)->unode.n[3])
79 #define VALUE(x) (DESCR1(x)->unode.a[3])
80 #define LEVEL(x) (DESCR1(x)->unode.b[4])
81 #define CTYPE(x) (DESCR1(x)->unode.b[5])
82 #define PRIORITY(x) (DESCR1(x)->unode.b[5])
83 #define LARGS(x) (DESCR1(x)->unode.b[6])
84 #define RARGS(x) (DESCR1(x)->unode.b[7])
85 #define DEFINITIONS(x) (DESCR2(x)->unode.a[0])
86 #define FULLSOURCE(x) (CAR(DEFINITIONS(x)))
87 #define SOURCE(x) (CAR(CDR(DEFINITIONS(x))))
88 #define BODY(x) (CAR(CDR(CDR(DEFINITIONS(x)))))
89 #define TREE(x) (CAR(CDR(CDR(CDR(DEFINITIONS(x))))))
90 #define LOCALS(x) (DESCR2(x)->unode.a[1])
91 #define BINARY(x) (DESCR2(x)->unode.a[3])
92 #define VARTYPE(x) ((x)->unode.b[5])
93 #define VARCLASS(x) ((VARTYPE(x)-VAR_TYPE_EXTERNAL)&0x3F)
94 
95 
96 //===================================================
103 //===================================================
104 #define FLAG_PRIMITIVE 0x0001
105 #define FLAG_VARIABLE 0x0002
106 #define FLAG_FUNCTION 0x0004
107 #define FLAG_COMMAND 0x0008
108 
109 #define FLAG_CAN_BE_UNARY 0x0010
110 #define FLAG_INFINITE_ARGS 0x0020
111 #define FLAG_MAY_SKIP_LAST_ARG 0x0040
112 #define FLAG_PROCESS_ARGS 0x0080
113 #define FLAG_PUSH_PARENT 0x0100
114 #define FLAG_SET_ONE_VAR 0x0200
115 #define FLAG_SET_ALL_VARS 0x0400
116 #define FLAG_MAY_HAVE_EXTRA_ARG 0x0800
117 #define FLAG_PUSH_FRAME 0x1000
118 #define FLAG_PRINT_VARS 0x2000
119 #define FLAG_EQUAL_VARS 0x4000
120 #define FLAG_PUSH_MODE 0x8000
121 #define ALL_VAR_FLAGS 0xFFFF
122 
123 //===================================================
127 //===================================================
128 #define VAR_TYPE_NORMAL 0x00
129 #define VAR_TYPE_RUNTIME 0x01
130 #define VAR_TYPE_TAG 0x02
131 #define VAR_TYPE_EXTERNAL 0x80
132 #define VAR_TYPE_INTERNAL 0xC0
133 
134 #define FLAG_PRIORITY_MUL 0x010000
135 #define FLAG_PRIORITY_ADD 0x020000
136 #define FLAG_PRIORITY_LOG 0x040000
137 #define FLAG_PRIORITY_CMP 0x080000
138 
139 
140 //===================================================
147 //===================================================
148 #define BASE_OFFSET_PARAMS 12
149 #define BASE_OFFSET_PARAMSCOUNT 8
150 #define BASE_OFFSET_DYNAMIC 0
151 #define BASE_OFFSET_STATIC -4
152 #define BASE_OFFSET_PARENT -8
153 #define BASE_OFFSET_REPEATCHAIN -12
154 #define BASE_OFFSET_TEST -16
155 #define BASE_OFFSET_LOCALS -20
156 
157 
158 
159 //===================================================
163 //===================================================
164 #ifdef WINDOWS
165 #define LOGO_PLATFORM TEXT("Windows")
166 #endif
167 #ifdef LINUX
168 #define LOGO_PLATFORM TEXT("Linux")
169 #endif
170 #ifdef APPLE
171 #define LOGO_PLATFORM TEXT("Mac OS X")
172 #endif
173 #define LOGO_VERSION TEXT("0.0")
174 #define LOGO_DIALECT TEXT("Lhogho")
175 
176 
177 
178 //===================================================
180 //===================================================
181 // @{
182 #define IS_PRIMITIVE(x) GET_FLAGS(x,FLAG_PRIMITIVE)
183 #define IS_VARIABLE(x) GET_FLAGS(x,FLAG_VARIABLE)
184 #define IS_FUNCTION(x) GET_FLAGS(x,FLAG_FUNCTION)
185 #define IS_COMMAND(x) GET_FLAGS(x,FLAG_COMMAND)
186 #define IS_VARATOM(x) (ID(x)==VAR_ID)
187 #define IS_UNBOUND(x) ((x)==unbound)
188 #define IS_STOPPED(x) ((x)==stopped)
189 #define IS_GLOBAL(x) (PARENT(x)==globals)
190 #define IS_NORMAL(x) (VARTYPE(x)==VAR_TYPE_NORMAL)
191 #define IS_TAG(x) (VARTYPE(x)==VAR_TYPE_TAG)
192 #define IS_RUNTIME(x) (VARTYPE(x)==VAR_TYPE_RUNTIME)
193 #define IS_EXTERNAL(x) ((VARTYPE(x)&0xC0)==VAR_TYPE_EXTERNAL)
194 #define IS_INTERNAL(x) ((VARTYPE(x)&0xC0)==VAR_TYPE_INTERNAL)
195 // @}
196 
197 
198 
199 
200 #define ROOT_VAR_NAME TEXT("%root%")
201 #define GLOBALS_VAR_NAME TEXT("%globals%")
202 
203 
204 
205 extern atom_t root;
206 extern atom_t word_to;
207 extern atom_t word_to_syn;
208 extern atom_t word_end;
209 extern atom_t word_run;
210 extern atom_t word_make;
211 extern atom_t word_plus;
212 extern atom_t word_toplevel;
213 extern atom_t word_system;
214 extern atom_t word_error;
215 extern atom_t unbound;
216 extern atom_t stopped;
217 extern atom_t repeat_chain;
218 extern atom_t globals;
219 extern atom_t printdepthlimit;
220 extern atom_t printwidthlimit;
221 extern atom_t fullprintp;
222 extern atom_t caseignoredp;
223 extern atom_t last_error;
224 extern atom_t delayed_free;
225 
226 extern int root_frame;
227 extern int backup_frame;
228 extern atom_t error_flag;
229 extern int catch_output_flag;
230 
231 extern void init_vars( );
232 extern void finit_vars( );
233 extern atom_t new_var( atom_t name, atom_t parent, int attach );
234 extern atom_t new_local_var( atom_t name, atom_t function, int quoted );
235 extern void delete_var( atom_t a );
236 extern void dump_var( atom_t a, int level );
237 extern atom_t find_var( atom_t name, atom_t parent );
238 extern atom_t find_local_var( atom_t name, atom_t parent );
239 extern atom_t find_runtime_var( atom_t name, int static_link );
240 extern int need_descr2( atom_t var );
241 //extern void __attribute__((used,noinline,regparm(0),stdcall)) copy_local_vars( int frame );
242 extern void copy_local_vars( int frame );
243 
244 
245 #endif //LHOGHO_VARS_H

[ HOME | INDEX | ATOMS | VARS | REFERENCE ]
Lhogho Developer's Documentation
Wed Jul 10 2013