Fixed some bugs...
[repair.git] / Repair / RepairInterpreter / element.h
1 // provides an object wrapper around elementary types
2
3
4 #ifndef ELEMENT_H
5 #define ELEMENT_H
6 #include "common.h"
7 #include "classlist.h"
8
9 class ElementWrapper;
10
11 #define ELEMENT_INT 1
12 #define ELEMENT_BIT 2
13 #define ELEMENT_BYTE 3
14 #define ELEMENT_TOKEN 4
15 #define ELEMENT_OBJECT 5
16 #define ELEMENT_FTUPLE 6
17 #define ELEMENT_SHORT 7
18
19 class ElementWrapper {
20  public:
21   virtual unsigned int hashCode()=0;
22   virtual bool equals(ElementWrapper *other)=0;
23   virtual int type()=0;
24  private:
25 };
26
27
28 class Element:public ElementWrapper {
29  public:
30   Element();
31   Element(int value);
32   Element(short value);
33   Element(bool b);
34   Element(char byte);
35   Element(char * token);
36   Element(Element * o);
37   unsigned int hashCode();
38   bool equals(ElementWrapper *other);
39   int intvalue();
40   short getshortvalue();
41   char getbytevalue();
42   bool getboolvalue();
43   bool isnumber();
44   void * getobject();
45   int type();
46   structure * getstructure();
47   Element(void * objptr, structure * str);
48   char * gettoken();
49   ~Element();
50   void print();
51
52  private:
53   char *token;
54   void *object;
55   int typevalue;
56   short shortvalue;
57   int integervalue;
58   char bytevalue;
59   bool bitvalue;
60   structure *itemtype;
61 };
62
63 unsigned int hashelement(ElementWrapper *e);
64
65 int elementequals(ElementWrapper *e1, ElementWrapper *e2);
66
67 #endif