This commit was manufactured by cvs2svn to create tag 'buildscript'.
[IRC.git] /
1 package IR;
2
3 public class AssignOperation {
4     public static final int EQ=1;
5     public static final int MULTEQ=2;
6     public static final int DIVEQ=3;
7     public static final int MODEQ=4;
8     public static final int PLUSEQ=5;
9     public static final int MINUSEQ=6;
10     public static final int LSHIFTEQ=7;
11     public static final int RSHIFTEQ=8;
12     public static final int URSHIFTEQ=9;
13     public static final int ANDEQ=10;
14     public static final int XOREQ=11;
15     public static final int OREQ=12;
16     public static final int POSTINC=13;
17     public static final int POSTDEC=14;
18
19     private int operation;
20     public AssignOperation(int op) {
21         this.operation=op;
22     }
23
24     public AssignOperation(String op) {
25         this.operation=parseOp(op);
26     }
27
28     public int getOp() {
29         return operation;
30     }
31
32     public Operation getBaseOp() {
33         switch(operation) {
34         case EQ:
35             return null;
36         case MULTEQ:
37             return new Operation(Operation.MULT);
38         case DIVEQ:
39             return new Operation(Operation.DIV);
40         case MODEQ:
41             return new Operation(Operation.MOD);
42         case PLUSEQ:
43             return new Operation(Operation.ADD);
44         case MINUSEQ:
45             return new Operation(Operation.SUB);
46         case LSHIFTEQ:
47             return new Operation(Operation.LEFTSHIFT);
48         case RSHIFTEQ:
49             return new Operation(Operation.RIGHTSHIFT);
50         case URSHIFTEQ:
51             return new Operation(Operation.URIGHTSHIFT);
52         case ANDEQ:
53             return new Operation(Operation.BIT_AND);
54         case XOREQ:
55             return new Operation(Operation.BIT_XOR);
56         case OREQ:
57             return new Operation(Operation.BIT_OR);
58         case POSTINC:
59             return new Operation(Operation.POSTINC);
60         case POSTDEC:
61             return new Operation(Operation.POSTDEC);
62         }
63         throw new Error();
64     }
65
66     public static int parseOp(String st) {
67         if (st.equals("eq"))
68             return EQ;
69         else if (st.equals("multeq"))
70             return MULTEQ;
71         else if (st.equals("diveq"))
72             return DIVEQ;
73         else if (st.equals("modeq"))
74             return MODEQ;
75         else if (st.equals("pluseq"))
76             return PLUSEQ;
77         else if (st.equals("minuseq"))
78             return MINUSEQ;
79         else if (st.equals("lshifteq"))
80             return LSHIFTEQ;
81         else if (st.equals("urshifteq"))
82             return URSHIFTEQ;
83         else if (st.equals("rshifteq"))
84             return RSHIFTEQ;
85         else if (st.equals("andeq"))
86             return ANDEQ;
87         else if (st.equals("xoreq"))
88             return XOREQ;
89         else if (st.equals("oreq"))
90             return OREQ;
91         else if (st.equals("postinc"))
92             return POSTINC;
93         else if (st.equals("postdec"))
94             return POSTDEC;
95         else throw new Error();
96     }
97
98     public String toString() {
99         if (operation==EQ)
100             return "=";
101         else if (operation==MULTEQ)
102             return "*=";
103         else if (operation==DIVEQ)
104             return "/=";
105         else if (operation==MODEQ)
106             return "%=";
107         else if (operation==PLUSEQ)
108             return "+=";
109         else if (operation==MINUSEQ)
110             return "-=";
111         else if (operation==LSHIFTEQ)
112             return "<=";
113         else if (operation==RSHIFTEQ)
114             return ">=";
115         else if (operation==RSHIFTEQ)
116             return ">>=";
117         else if (operation==ANDEQ)
118             return "&=";
119         else if (operation==XOREQ)
120             return "^=";
121         else if (operation==OREQ)
122             return "|=";
123         else if (operation==POSTINC)
124             return "postinc";
125         else if (operation==POSTDEC)
126             return "postdec";
127         else throw new Error();
128     }
129
130
131 }