bug fixes
authorroot <root>
Fri, 17 Feb 2006 00:47:00 +0000 (00:47 +0000)
committerroot <root>
Fri, 17 Feb 2006 00:47:00 +0000 (00:47 +0000)
Robust/src/IR/Flat/BuildFlat.java
Robust/src/IR/Tree/DeclarationNode.java
Robust/src/IR/VarDescriptor.java

index b2aa3fdb8649ec0cb656838e777fca61b54e311d..0c44e8337a6eb73a2147cdf81ea62612f4044378 100644 (file)
@@ -5,8 +5,11 @@ import java.util.*;
 
 public class BuildFlat {
     State state;
+    Hashtable temptovar;
+
     public BuildFlat(State st) {
        state=st;
+       temptovar=new Hashtable();
     }
 
     public void buildFlat() {
@@ -108,9 +111,21 @@ public class BuildFlat {
     }
 
     private NodePair flattenDeclarationNode(DeclarationNode dn) {
-       throw new Error();
+       VarDescriptor vd=dn.getVarDescriptor();
+       TempDescriptor td=getTempforVar(vd);
+       return flattenExpressionNode(dn.getExpression(),td);
     }
         
+    private TempDescriptor getTempforVar(VarDescriptor vd) {
+       if (temptovar.containsKey(vd))
+           return (TempDescriptor)temptovar.get(vd);
+       else {
+           TempDescriptor td=TempDescriptor.tempFactory(vd.getName());
+           temptovar.put(vd,td);
+           return td;
+       }
+    }
+
     private NodePair flattenIfStatementNode(IfStatementNode isn) {
        TempDescriptor cond_temp=TempDescriptor.tempFactory("condition");
        NodePair cond=flattenExpressionNode(isn.getCondition(),cond_temp);
index b354be9ce19205b2135391cf2f5119ef9d663743..aa1b4eb50bd7602278240a9d399409876b8f5632 100644 (file)
@@ -15,6 +15,14 @@ public class DeclarationNode extends BlockStatementNode {
        else return vd.toString()+"="+init_en.printNode(0);
     }
 
+    public ExpressionNode getExpression() {
+       return init_en;
+    }
+    
+    public VarDescriptor getVarDescriptor() {
+       return vd;
+    }
+
     public int kind() {
        return Kind.DeclarationNode;
     }
index 610e7a6679cfaeb72a62696b7dee4d6d4eddb534..d8726f28676d1b12263adbaa0bc17ebd01317316 100644 (file)
@@ -21,6 +21,10 @@ public class VarDescriptor extends Descriptor {
        this.uniqueid=count++;
     }
 
+    public String getName() {
+       return identifier;
+    }
+
     public String toString() {
            return td.toString()+" "+identifier;
     }