summaryrefslogtreecommitdiff
path: root/src/ops/express.h
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2011-10-08 20:30:28 +0200
committerHenrik Rydberg <rydberg@euromail.se>2011-10-08 20:30:28 +0200
commit5df79c53745fde5d6c3340a2979b1429cd5892c1 (patch)
tree1a81af141708b826e9c61e8a04019994fcca8298 /src/ops/express.h
Initial import of htcd system 1.0
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/ops/express.h')
-rw-r--r--src/ops/express.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/ops/express.h b/src/ops/express.h
new file mode 100644
index 0000000..79148f6
--- /dev/null
+++ b/src/ops/express.h
@@ -0,0 +1,79 @@
1/*************************************************************************
2 *
3 * HTCd - Copyright (C) 1998-2006 Henrik Rydberg
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef EXPRESSH
21#define EXPRESSH
22
23#include <ops/operator.h>
24#include <mt/split.h>
25#include <mt/uniheap.h>
26
27const int OP_LOCAL=1;
28const int OP_GLOBAL=2;
29const int OP_NINIT=4;
30const int OP_ALL=OP_LOCAL|OP_GLOBAL|OP_NINIT;
31
32class expr_t {
33public:
34 sref expr;
35 const op_t* op;
36 int status;
37 mstring result;
38 expr_t *left,*right;
39
40 expr_t():
41 expr(),op(0),status(OP_ALL),result(),left(0),right(0) {}
42 expr_t(const expr_t& x):
43 expr(),op(0),status(OP_ALL),result(),left(0),right(0) { copy(x); }
44 expr_t(const sref& s):
45 expr(s),op(0),status(OP_ALL),result(),left(0),right(0) {}
46 expr_t(const sref& s,const op_t* o):
47 expr(s),op(o),status(OP_ALL),result(),left(0),right(0) {}
48 expr_t(const sref& s,const op_t* o,expr_t* p):
49 expr(s),op(o),status(OP_ALL),result(),left(p),right(0) {}
50 ~expr_t() { delete left; delete right; }
51
52 void clear();
53 expr_t& operator=(const expr_t& x) { clear(); copy(x); return *this; }
54 expr_t& operator=(const sref& in) { clear(); expr=in; return *this; }
55
56 void trav(mstream& out,int n);
57 void expand(op_env& env) throw(merror_t);
58 void eval(mstream& out,op_env& env,int opt) throw(merror_t);
59
60 static void* operator new(size_t n);
61 static void operator delete(void* p);
62protected:
63 void copy(const expr_t& x);
64 static uniheap<36> tree;
65};
66
67////////////////////////////////////////////////////////////
68
69struct op_env {
70 opmap* ops;
71
72 op_env() : ops(0) {}
73 op_env(opmap& map) : ops(&map) {}
74
75 virtual int split(sref& first,sref& rest) throw(merror_t) { return 0; }
76 virtual void term(mstream& out,expr_t* x) throw(merror_t) { x->status=0; }
77};
78
79#endif