e8dce7de3117b797cbdaa11e8294e3150ba7e527
[IRC.git] / Robust / src / IR / AssignOperation.java
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
17     private int operation;
18     public AssignOperation(int op) {
19         this.operation=op;
20     }
21
22     public AssignOperation(String op) {
23         this.operation=parseOp(op);
24     }
25
26     public static int parseOp(String st) {
27         if (st.equals("eq"))
28             return EQ;
29         else if (st.equals("multeq"))
30             return MULTEQ;
31         else if (st.equals("diveq"))
32             return DIVEQ;
33         else if (st.equals("modeq"))
34             return MODEQ;
35         else if (st.equals("pluseq"))
36             return PLUSEQ;
37         else if (st.equals("minuseq"))
38             return MINUSEQ;
39         else if (st.equals("lshifteq"))
40             return LSHIFTEQ;
41         else if (st.equals("rshifteq"))
42             return RSHIFTEQ;
43         else if (st.equals("andeq"))
44             return ANDEQ;
45         else if (st.equals("xoreq"))
46             return XOREQ;
47         else if (st.equals("oreq"))
48             return OREQ;
49         else throw new Error();
50     }
51
52     public String toString() {
53         if (operation==EQ)
54             return "=";
55         else if (operation==MULTEQ)
56             return "*=";
57         else if (operation==DIVEQ)
58             return "/=";
59         else if (operation==MODEQ)
60             return "%=";
61         else if (operation==PLUSEQ)
62             return "+=";
63         else if (operation==MINUSEQ)
64             return "-=";
65         else if (operation==LSHIFTEQ)
66             return "<=";
67         else if (operation==RSHIFTEQ)
68             return ">=";
69         else if (operation==ANDEQ)
70             return "&=";
71         else if (operation==XOREQ)
72             return "^=";
73         else if (operation==OREQ)
74             return "|=";
75         else throw new Error();
76     }
77
78
79 }