From a030059383c335f4a6f56391cc60000926448f58 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Wed, 15 Feb 2006 00:01:06 +0000 Subject: [PATCH] dd --- Robust/src/IR/AssignOperation.java | 79 ++++++++++++++++++++++++++++++ Robust/src/IR/VarDescriptor.java | 32 ++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 Robust/src/IR/AssignOperation.java create mode 100644 Robust/src/IR/VarDescriptor.java diff --git a/Robust/src/IR/AssignOperation.java b/Robust/src/IR/AssignOperation.java new file mode 100644 index 00000000..e8dce7de --- /dev/null +++ b/Robust/src/IR/AssignOperation.java @@ -0,0 +1,79 @@ +package IR; + +public class AssignOperation { + public static final int EQ=1; + public static final int MULTEQ=2; + public static final int DIVEQ=3; + public static final int MODEQ=4; + public static final int PLUSEQ=5; + public static final int MINUSEQ=6; + public static final int LSHIFTEQ=7; + public static final int RSHIFTEQ=8; + public static final int URSHIFTEQ=9; + public static final int ANDEQ=10; + public static final int XOREQ=11; + public static final int OREQ=12; + + private int operation; + public AssignOperation(int op) { + this.operation=op; + } + + public AssignOperation(String op) { + this.operation=parseOp(op); + } + + public static int parseOp(String st) { + if (st.equals("eq")) + return EQ; + else if (st.equals("multeq")) + return MULTEQ; + else if (st.equals("diveq")) + return DIVEQ; + else if (st.equals("modeq")) + return MODEQ; + else if (st.equals("pluseq")) + return PLUSEQ; + else if (st.equals("minuseq")) + return MINUSEQ; + else if (st.equals("lshifteq")) + return LSHIFTEQ; + else if (st.equals("rshifteq")) + return RSHIFTEQ; + else if (st.equals("andeq")) + return ANDEQ; + else if (st.equals("xoreq")) + return XOREQ; + else if (st.equals("oreq")) + return OREQ; + else throw new Error(); + } + + public String toString() { + if (operation==EQ) + return "="; + else if (operation==MULTEQ) + return "*="; + else if (operation==DIVEQ) + return "/="; + else if (operation==MODEQ) + return "%="; + else if (operation==PLUSEQ) + return "+="; + else if (operation==MINUSEQ) + return "-="; + else if (operation==LSHIFTEQ) + return "<="; + else if (operation==RSHIFTEQ) + return ">="; + else if (operation==ANDEQ) + return "&="; + else if (operation==XOREQ) + return "^="; + else if (operation==OREQ) + return "|="; + else throw new Error(); + } + + +} diff --git a/Robust/src/IR/VarDescriptor.java b/Robust/src/IR/VarDescriptor.java new file mode 100644 index 00000000..f2ed53f2 --- /dev/null +++ b/Robust/src/IR/VarDescriptor.java @@ -0,0 +1,32 @@ +package IR; +import IR.Tree.Modifiers; +import IR.Tree.ExpressionNode; + +/** + * Descriptor + * + * represents a symbol in the language (var name, function name, etc). + */ + +public class VarDescriptor extends Descriptor { + + protected TypeDescriptor td; + protected String identifier; + protected ExpressionNode en; + + public VarDescriptor(TypeDescriptor t, String identifier, ExpressionNode e) { + super(identifier); + this.td=t; + this.identifier=identifier; + this.en=e; + this.safename = "__" + name + "__"; + this.uniqueid=count++; + } + + public String toString() { + if (en==null) + return td.toString()+" "+identifier+";"; + else + return td.toString()+" "+identifier+"="+en.printNode()+";"; + } +} -- 2.34.1