This commit was manufactured by cvs2svn to create tag 'buildscript'.
[IRC.git] /
1 package IR;
2
3 public class Operation {
4     public static final int LOGIC_OR=1;
5     public static final int LOGIC_AND=2;
6     public static final int BIT_OR=3;
7     public static final int BIT_XOR=4;
8     public static final int BIT_AND=5;
9     public static final int EQUAL=6;
10     public static final int NOTEQUAL=7;
11     public static final int LT=8;
12     public static final int GT=9;
13     public static final int LTE=10;
14     public static final int GTE=11;
15     public static final int LEFTSHIFT=12;
16     public static final int RIGHTSHIFT=13;
17     public static final int SUB=14;
18     public static final int ADD=15;
19     public static final int MULT=16;
20     public static final int DIV=17;
21     public static final int MOD=18;
22     public static final int UNARYPLUS=19;
23     public static final int UNARYMINUS=20;
24     public static final int POSTINC=21;
25     public static final int POSTDEC=22;
26     public static final int PREINC=23;
27     public static final int PREDEC=24;
28     public static final int LOGIC_NOT=25;
29     /* Flat Operations */
30     public static final int ASSIGN=100;
31
32     private int operation;
33     public Operation(int op) {
34         this.operation=op;
35     }
36
37     public Operation(String op) {
38         this.operation=parseOp(op);
39     }
40
41     public int getOp() {
42         return operation;
43     }
44     
45     public static int parseOp(String st) {
46         if (st.equals("logical_or"))
47             return LOGIC_OR;
48         else if (st.equals("logical_and"))
49             return LOGIC_AND;
50         else if (st.equals("bitwise_or"))
51             return BIT_OR;
52         else if (st.equals("bitwise_xor"))
53             return BIT_XOR;
54         else if (st.equals("bitwise_and"))
55             return BIT_AND;
56         else if (st.equals("equal"))
57             return EQUAL;
58         else if (st.equals("not_equal"))
59             return NOTEQUAL;
60         else if (st.equals("comp_lt"))
61             return LT;
62         else if (st.equals("comp_gt"))
63             return GT;
64         else if (st.equals("comp_lte"))
65             return LTE;
66         else if (st.equals("comp_gte"))
67             return GTE;
68         else if (st.equals("leftshift"))
69             return LEFTSHIFT;
70         else if (st.equals("rightshift"))
71             return RIGHTSHIFT;
72         else if (st.equals("sub"))
73             return SUB;
74         else if (st.equals("add"))
75             return ADD;
76         else if (st.equals("mult"))
77             return MULT;
78         else if (st.equals("div"))
79             return DIV;
80         else if (st.equals("mod"))
81             return MOD;
82         else if (st.equals("unaryplus"))
83             return UNARYPLUS;
84         else if (st.equals("unaryminus"))
85             return UNARYMINUS;
86         else if (st.equals("postinc"))
87             return POSTINC;
88         else if (st.equals("postdec"))
89             return POSTDEC;
90         else if (st.equals("preinc"))
91             return PREINC;
92         else if (st.equals("predec"))
93             return PREDEC;
94         else if (st.equals("not"))
95             return LOGIC_NOT;
96         else
97             throw new Error();
98     }
99
100     public String toString() {
101         if (operation==LOGIC_OR)
102             return "||";
103         else if (operation==LOGIC_AND)
104             return "&&";
105         else if (operation==LOGIC_NOT)
106             return "not";
107         else if (operation==BIT_OR)
108             return "|";
109         else if (operation==BIT_XOR)
110             return "^";
111         else if (operation==BIT_AND)
112             return "&";
113         else if (operation==EQUAL)
114             return "==";
115         else if (operation==NOTEQUAL)
116             return "!=";
117         else if (operation==LT)
118             return "<";
119         else if (operation==GT)
120             return ">";
121         else if (operation==LTE)
122             return "<=";
123         else if (operation==GTE)
124             return ">=";
125         else if (operation==LEFTSHIFT)
126             return "<<";
127         else if (operation==RIGHTSHIFT)
128             return ">>";
129         else if (operation==SUB)
130             return "-";
131         else if (operation==ADD)
132             return "+";
133         else if (operation==MULT)
134             return "*";
135         else if (operation==DIV)
136             return "/";
137         else if (operation==MOD)
138             return "%";
139         else if (operation==UNARYPLUS)
140             return "unaryplus";
141         else if (operation==UNARYMINUS)
142             return "unaryminus";
143         else if (operation==POSTINC)
144             return "postinc";
145         else if (operation==POSTDEC)
146             return "postdec";
147         else if (operation==PREINC)
148             return "preinc";
149         else if (operation==PREDEC)
150             return "predec";
151         else if (operation==ASSIGN)
152             return "assign";
153         else throw new Error();
154     }
155
156
157 }