2
* Copyright (C) 1997-2004 Jiri (George) Lebl
4
* Author: Jiri (George) Lebl
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
28
/*dictionary function structure*/
30
GEL_BUILTIN_FUNC = 0, /*function internal to genius*/
31
GEL_USER_FUNC, /*function that points to an GelETree for evaluation*/
32
GEL_VARIABLE_FUNC, /*function that points to an GelETree result */
33
GEL_REFERENCE_FUNC /*a function that points to some other GelEFunc*/
34
} GelEFuncType; /* should fit in 3 bits (it does) */
36
typedef struct _GelEFunc GelEFunc;
37
typedef union _GelETree GelETree;
38
typedef struct _GelETreeAny GelETreeAny;
39
/*typedef struct _GelETreeNull GelETreeNull;*/
40
typedef struct _GelETreeValue GelETreeValue;
41
typedef struct _GelETreeMatrix GelETreeMatrix;
42
typedef struct _GelETreeSet GelETreeSet;
43
typedef struct _GelETreePolynomial GelETreePolynomial;
44
typedef struct _GelETreeOperator GelETreeOperator;
45
typedef struct _GelETreeIdentifier GelETreeIdentifier;
46
typedef struct _GelETreeString GelETreeString;
47
typedef struct _GelETreeFunction GelETreeFunction;
48
typedef struct _GelETreeComparison GelETreeComparison;
49
typedef struct _GelETreeUsertype GelETreeUsertype;
50
typedef struct _GelETreeBool GelETreeBool;
52
typedef struct _GelETreeMatrixRow GelETreeMatrixRow;
53
/*typedef struct _GelETreeMatrixStart GelETreeMatrixStart;*/
54
/*typedef struct _GelETreeExprlistStart GelETreeExprlistStart;*/
55
typedef struct _GelETreeSpacer GelETreeSpacer;
56
typedef struct _GelToken GelToken;
58
typedef struct _GelEvalStack GelEvalStack;
59
typedef struct _GelEvalLoop GelEvalLoop;
60
typedef struct _GelEvalFor GelEvalFor;
61
typedef struct _GelEvalForIn GelEvalForIn;
62
typedef struct _GelCtx GelCtx;
64
typedef struct _GelExecSetup GelExecSetup;
65
typedef struct _GelOutput GelOutput;
67
/*not defined here, but needed and we can't include matrixw.h, but
68
matrixw.h includes structs.h*/
69
typedef struct _GelMatrixW GelMatrixW;
71
typedef GelETree *(* ParameterSetFunc) (GelETree *val);
72
typedef GelETree *(* ParameterGetFunc) (void);
74
typedef GelETree *(* GelBIFunction) (GelCtx *ctx, GelETree * *, gboolean *); /*the gboolean is exception*/
76
/* tokens point to this structure globaly, there is
77
one such structure for each token. */
83
/* For built-in parameters this is the get and set function
84
* of type ParameterGetFunc and ParameterSetFunc */
90
guint8 built_in_parameter:1;
95
GelToken *symbolic_id; /* id for symbolic math, preserved under
96
assignment, if NULL we use the id */
97
int context; /*the context number this is used for .. if we pop this
98
context, we will destroy the function*/
99
GSList *named_args; /*names of arguments*/
107
GelEFunc *next; /*this is for keeping a free list*/
110
guint16 nargs; /*number of arguments*/
112
/* GelEFuncType type; */
115
/* if true, we must take this off the subst list for a context pop,
116
* before we free the function */
117
guint8 on_subst_list:1;
119
guint8 propagate_mod:1;
120
guint8 no_mod_all_args:1;
127
SET_NODE, /* FIXME: Note implemented */
128
POLYNOMIAL_NODE, /* FIXME: Note implemented */
132
FUNCTION_NODE, /*stores an anonymous function*/
134
USERTYPE_NODE, /*for user types, FIXME: not finished*/
135
BOOL_NODE, /*boolean*/
138
MATRIX_ROW_NODE=1000,
144
struct _GelETreeAny {
149
/*struct _GelETreeNull {
154
struct _GelETreeValue {
160
struct _GelETreeMatrix {
166
/* gboolean is faster, then a bitfield and we right now
167
don't gain anything */
173
/* FIXME: Not implemented */
174
struct _GelETreeSet {
180
/* gboolean is faster, then a bitfield and we right now
181
don't gain anything */
187
struct _GelETreePolynomial {
190
guint16 largest; /* largest exponent */
191
guint8 vars; /* number of variables */
193
/* This needs redoing. No need to store
194
this in the ETree struct since we want to
195
conserve memory. Probably need an array
201
mpw_ptr *indexes; /* indexes when written out in standard form
202
from smallest to largest. If more then one
203
variable then this is '(largest+1)^vars'
207
struct _GelETreeOperator {
215
struct _GelETreeIdentifier {
221
struct _GelETreeString {
227
/* gboolean is faster, then a bitfield and we right now
228
don't gain anything */
229
/* guint constant:1; */
232
struct _GelETreeFunction {
235
GelEFunc *func; /*anon function*/
238
struct _GelETreeComparison {
246
struct _GelETreeUsertype {
253
struct _GelETreeBool {
258
/* gboolean is faster, then a bitfield and we right now
259
don't gain anything */
264
struct _GelETreeMatrixRow {
271
/*struct _GelETreeMatrixStart {
276
/*struct _GelETreeExprlistStart {
281
struct _GelETreeSpacer {
289
GelETreeAny any; /*for allocation purposes only*/
290
/*GelETreeNull null;*/
294
GelETreePolynomial poly;
296
GelETreeIdentifier id;
298
GelETreeFunction func;
299
GelETreeComparison comp;
302
GelETreeMatrixRow row;
303
/*GelETreeMatrixStart mats;*/
304
/*GelETreeExprlistStart exps;*/
308
/* Evaluation stack */
310
/* The flag for the stack */
313
GE_RESULT = 1, /*used for recursive evluation with the same ctx*/
330
GE_WHACKARG = 1<<16 /* only on GE_PRE, GE_POST, GE_MODULOOP */
333
#define GE_ADDWHACKARG(flag,whackarg) \
334
((whackarg) ? ((flag) | GE_WHACKARG) : (flag))
336
/*should take up about a page
337
we will use a single pointer for data and the next pointer for post/pre flag
338
we can use next as a marker that we have gone too far, and current as a marker
339
that we have underpopped*/
340
#define STACK_SIZE 1022
341
struct _GelEvalStack {
342
gpointer stack[STACK_SIZE];
352
/*data structure for while/until loops*/
353
struct _GelEvalLoop {
354
GelETree * condition;
356
guint8 is_while:1; /*if false, this is an until loop*/
357
guint8 body_first:1; /*if true body is the first argument*/
359
/*data structure for 'for' loops*/
368
GelETree * orig_body;
372
/*data structure for 'forin' loops*/
373
struct _GelEvalForIn {
379
GelETree * orig_body;
383
/* evaluation context structure */
397
GEL_OUTPUT_BLACK_HOLE
400
typedef int (*GelOutputLineFunc)(GelOutput *);
401
typedef void (*GelOutputNotifyFunc)(GelOutput *);
408
gboolean length_limit; /* if TRUE limit by below, else don't */
409
int line_length; /* limit the output to this number of characters,
410
if <=0 then always print normally */
411
GelOutputLineFunc line_length_get;
412
/* if this is set, this function is used instead of
414
int cur_line_pos; /* position on current line */
415
gboolean inside_escape; /* inside a shell escape, don't increment the
421
/* new data notifier */
422
GelOutputNotifyFunc notify;
428
#endif /* STRUCTS_H */