6a8ea956a6fc0b788e4d79fc0296b196dc9e4da2
[satune.git] / src / AST / element.h
1 #ifndef ELEMENT_H
2 #define ELEMENT_H
3 #include "classlist.h"
4 #include "mymemory.h"
5 #include "structs.h"
6 #include "astnode.h"
7 #include "functionencoding.h"
8 #include "elementencoding.h"
9 #include "boolean.h"
10
11 #define GETELEMENTTYPE(o) (o->type)
12 #define GETELEMENTPARENTS(o) (&((Element *)o)->parents)
13 class Element : public ASTNode {
14  public:
15         Element(ASTNodeType type);
16         virtual ~Element();
17         Vector<ASTNode *> parents;
18         ElementEncoding encoding;
19         MEMALLOC;
20 };
21
22 class ElementConst : public Element {
23  public:
24         ElementConst(uint64_t value, VarType type);
25         ~ElementConst();
26         Set *set;
27         uint64_t value;
28         MEMALLOC;
29 };
30
31 class ElementSet : public Element {
32  public:
33         ElementSet(Set *s);
34         Set *set;
35         MEMALLOC;
36 };
37
38 class ElementFunction : public Element {
39  public:
40         ElementFunction(Function *function, Element **array, uint numArrays, Boolean *overflowstatus);
41         ~ElementFunction();
42         Function *function;
43         Array<Element *> inputs;
44         Boolean *overflowstatus;
45         FunctionEncoding functionencoding;
46         MEMALLOC;
47 };
48
49 Set *getElementSet(Element *This);
50
51 static inline ElementEncoding *getElementEncoding(Element *e) {
52         return &e->encoding;
53 }
54
55 static inline FunctionEncoding *getElementFunctionEncoding(ElementFunction *func) {
56         return &func->functionencoding;
57 }
58 #endif