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 Operation getBaseOp() {
29         switch(operation) {
30         case EQ:
31             return null;
32         case MULTEQ:
33             return new Operation(Operation.MULT);
34         case DIVEQ:
35             return new Operation(Operation.DIV);
36         case MODEQ:
37             return new Operation(Operation.MOD);
38         case PLUSEQ:
39             return new Operation(Operation.ADD);
40         case MINUSEQ:
41             return new Operation(Operation.SUB);
42         case LSHIFTEQ:
43             return new Operation(Operation.LEFTSHIFT);
44         case RSHIFTEQ:
45             return new Operation(Operation.RIGHTSHIFT);
46         case ANDEQ:
47             return new Operation(Operation.BIT_AND);
48         case XOREQ:
49             return new Operation(Operation.BIT_XOR);
50         case OREQ:
51             return new Operation(Operation.BIT_OR);
52         case POSTINC:
53             return new Operation(Operation.POSTINC);
54         case POSTDEC:
55             return new Operation(Operation.POSTDEC);
56         }
57         throw new Error();
58     }
59
60     public static int parseOp(String st) {
61         if (st.equals("eq"))
62             return EQ;
63         else if (st.equals("multeq"))
64             return MULTEQ;
65         else if (st.equals("diveq"))
66             return DIVEQ;
67         else if (st.equals("modeq"))
68             return MODEQ;
69         else if (st.equals("pluseq"))
70             return PLUSEQ;
71         else if (st.equals("minuseq"))
72             return MINUSEQ;
73         else if (st.equals("lshifteq"))
74             return LSHIFTEQ;
75         else if (st.equals("rshifteq"))
76             return RSHIFTEQ;
77         else if (st.equals("andeq"))
78             return ANDEQ;
79         else if (st.equals("xoreq"))
80             return XOREQ;
81         else if (st.equals("oreq"))
82             return OREQ;
83         else if (st.equals("postinc"))
84             return POSTINC;
85         else if (st.equals("postdec"))
86             return POSTDEC;
87         else throw new Error();
88     }
89
90     public String toString() {
91         if (operation==EQ)
92             return "=";
93         else if (operation==MULTEQ)
94             return "*=";
95         else if (operation==DIVEQ)
96             return "/=";
97         else if (operation==MODEQ)
98             return "%=";
99         else if (operation==PLUSEQ)
100             return "+=";
101         else if (operation==MINUSEQ)
102             return "-=";
103         else if (operation==LSHIFTEQ)
104             return "<=";
105         else if (operation==RSHIFTEQ)
106             return ">=";
107         else if (operation==ANDEQ)
108             return "&=";
109         else if (operation==XOREQ)
110             return "^=";
111         else if (operation==OREQ)
112             return "|=";
113         else if (operation==POSTINC)
114             return "postinc";
115         else if (operation==POSTDEC)
116             return "postdec";
117         else throw new Error();
118     }
119
120
121 }