Fixes so that our unit tests now pass. Single and multi imports currently only work...
authorstephey <stephey>
Thu, 21 Apr 2011 23:40:14 +0000 (23:40 +0000)
committerstephey <stephey>
Thu, 21 Apr 2011 23:40:14 +0000 (23:40 +0000)
TODO: Add support for importing subclasses
Add support for implicit imports (i.e. dir1.dir2.obj o = new dir1.dir2.obj(); calls).

P.S. Jin told me to put in the .goal file

Robust/src/IR/NameDescriptor.java
Robust/src/IR/Tree/BuildIR.java
Robust/src/Tests/output/StaticInnerClassTest.output.goal [new file with mode: 0644]

index 3814320edd4d3c3ecd94cc91ac0f36b178f11951..fb4f5344486cd3d8feee06d5b6dee91c1dd71738 100644 (file)
@@ -30,6 +30,10 @@ public class NameDescriptor extends Descriptor {
       return nd.getRoot();
   }
   
+  public String getPathFromRootToHere() {
+    return getPathFromRootToHere(identifier);
+  }
+  
   public String getPathFromRootToHere(String id) {
     String path = id;
     NameDescriptor temp = this.nd;
index 29ced9be558150be8d282834212728bfbe2213dc..943f52c5f91e36d805ad798fb8e502c4c1a6c240 100644 (file)
@@ -50,7 +50,7 @@ public class BuildIR {
         if (isNode(pnimport, "import_single"))
           if (!mandatoryImports.containsKey(nd.getIdentifier())) {
             // map name to full name (includes package/directory
-            mandatoryImports.put(nd.getIdentifier(), nd.getPathFromRootToHere(nd.getIdentifier()));
+            mandatoryImports.put(nd.getIdentifier(), nd.getPathFromRootToHere());
           } else {
             throw new Error("An ambiguous class "+ nd.getIdentifier() +" has been found. It is included for " +
                        ((String)mandatoryImports.get(nd.getIdentifier())).replace("___________", ".") + " and " +
@@ -92,8 +92,10 @@ public class BuildIR {
     ParseNode ppn=pn.getChild("packages").getChild("package");
     String packageName = null;
     if (ppn!=null) {
-      packageName = ppn.getChild("name").getChild("identifier").getTerminal();
+      NameDescriptor nd = parseName(ppn.getChild("name"));
+      packageName = nd.getPathFromRootToHere();
     }
+    
     ParseNode tpn=pn.getChild("type_declaration_list");
     if (tpn != null) {
       ParseNodeVector pnv = tpn.getChildren();
diff --git a/Robust/src/Tests/output/StaticInnerClassTest.output.goal b/Robust/src/Tests/output/StaticInnerClassTest.output.goal
new file mode 100644 (file)
index 0000000..4ff1891
--- /dev/null
@@ -0,0 +1 @@
+Tasmania