Fix the bug of assignment conversion: 'short s = 12' should be allowed. And for such...
[IRC.git] / Robust / src / IR / Flat / BuildFlat.java
index f5347897aea1d504607285d37952c4d2f9aecee8..c9f4b783de711176f69ab93eff5c4840b864add2 100644 (file)
@@ -360,6 +360,7 @@ public class BuildFlat {
       }
       return new NodePair(fn,last);
     } else {
+      if(con.getArrayInitializer() == null) {
       FlatNode first=null;
       FlatNode last=null;
       TempDescriptor[] temps=new TempDescriptor[con.numArgs()];
@@ -390,6 +391,11 @@ public class BuildFlat {
        return new NodePair(first,np.getEnd());
       } else
        return new NodePair(first, fn);
+      } else if(state.MGC) {
+      // array creation with initializers
+        return flattenArrayInitializerNode(con.getArrayInitializer(), out_temp);
+      }
+      return null;
     }
   }
 
@@ -536,9 +542,13 @@ public class BuildFlat {
 
     //Get src value
     if (an.getSrc()!=null) {
-      NodePair np_src=flattenExpressionNode(an.getSrc(),src_tmp);
-      first=np_src.getBegin();
-      last=np_src.getEnd();
+      if(an.getSrc().getEval() != null) {
+        first = last = new FlatLiteralNode(an.getSrc().getType(), an.getSrc().getEval().longValue(), src_tmp);
+      } else {
+        NodePair np_src=flattenExpressionNode(an.getSrc(),src_tmp);
+        first=np_src.getBegin();
+        last=np_src.getEnd();
+      }
     } else if (!pre) {
       FlatLiteralNode fln=new FlatLiteralNode(new TypeDescriptor(TypeDescriptor.INT),new Integer(1),src_tmp);
       first=fln;
@@ -1390,7 +1400,7 @@ public class BuildFlat {
     boolean isGlobal = false;
     String disjointId = null;
     // get the type the array to be initialized
-    TypeDescriptor td = out_temp.getType();
+    TypeDescriptor td = ain.getType();
 
     // create a new array of size equal to the array initializer
     FlatNode first=null;