From fef1c1937bb59847b3be3820dcf65c51ea6c0213 Mon Sep 17 00:00:00 2001 From: jjenista Date: Thu, 19 Feb 2009 19:28:20 +0000 Subject: [PATCH] A start for array initializers. THIS IS NOT A WORKING IMPLEMENTATION\! I checked in a short circuit to bomb out in BuildIR.java until I have time to go back and finish it. --- Robust/src/IR/Flat/BuildFlat.java | 43 ++++++++++++++++++++ Robust/src/IR/Tree/ArrayInitializerNode.java | 42 +++++++++++++++++++ Robust/src/IR/Tree/BuildIR.java | 18 ++++++++ Robust/src/IR/Tree/Kind.java | 1 + Robust/src/IR/Tree/SemanticCheck.java | 9 ++++ Robust/src/Parse/java14.cup | 41 +++++++++++++------ Robust/src/Tests/ArrayInitializerTest.java | 8 ++++ 7 files changed, 149 insertions(+), 13 deletions(-) create mode 100644 Robust/src/IR/Tree/ArrayInitializerNode.java create mode 100644 Robust/src/Tests/ArrayInitializerTest.java diff --git a/Robust/src/IR/Flat/BuildFlat.java b/Robust/src/IR/Flat/BuildFlat.java index f964dd12..df775be2 100644 --- a/Robust/src/IR/Flat/BuildFlat.java +++ b/Robust/src/IR/Flat/BuildFlat.java @@ -792,6 +792,9 @@ public class BuildFlat { case Kind.InstanceOfNode: return flattenInstanceOfNode((InstanceOfNode)en,out_temp); + + case Kind.ArrayInitializerNode: + return flattenArrayInitializerNode((ArrayInitializerNode)en,out_temp); } throw new Error(); } @@ -1090,6 +1093,46 @@ public class BuildFlat { return new NodePair(cond.getBegin(),fion); } + private NodePair flattenArrayInitializerNode(ArrayInitializerNode ain, TempDescriptor out_temp) { + /* + TempDescriptor expr_temp=TempDescriptor.tempFactory("arry_init",ain.getType()); + + // create a new array of size equal to the array initializer + //FlatNode first=null; + //FlatNode last=null; + TempDescriptor[] temps=new TempDescriptor[ain.numVarInitializers()]; + + for (int i=0; i