From 1681e09843550979cd509005f934fd198d989c20 Mon Sep 17 00:00:00 2001 From: stephey Date: Fri, 22 Apr 2011 08:38:18 +0000 Subject: [PATCH] Updated to support being able to do calls such as package1.package2.class abc = new package1.package2.class(); without an explicit import. However, we still do not support importing a class within a class yet. P.S. Someone forgot to checkin a TryCatchTest.output.goal --- Robust/src/IR/Tree/BuildIR.java | 13 ++++++------- Robust/src/IR/Tree/SemanticCheck.java | 4 ---- Robust/src/IR/TypeUtil.java | 1 - 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Robust/src/IR/Tree/BuildIR.java b/Robust/src/IR/Tree/BuildIR.java index 943f52c5..30779661 100644 --- a/Robust/src/IR/Tree/BuildIR.java +++ b/Robust/src/IR/Tree/BuildIR.java @@ -53,15 +53,15 @@ public class BuildIR { 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 " + - nd.getPathFromRootToHere(nd.getIdentifier()).replace("___________", ".")); + ((String)mandatoryImports.get(nd.getIdentifier())) + " and " + + nd.getPathFromRootToHere()); } else { // This kind of breaks away from tradition a little bit by doing the file checks here // instead of in Semantic check, but doing it here is easier because we have a mapping early on // if I wait until semantic check, I have to change ALL the type descriptors to match the new // mapping and that's both ugly and tedious. - File folder = new File(nd.getPathFromRootToHere(nd.getIdentifier()).replace('.', '/')); + File folder = new File(nd.getPathFromRootToHere().replace('.', '/')); if (folder.exists()) { for (String file : folder.list()) { // if the file is of type *.java add to multiImport list. @@ -75,8 +75,7 @@ public class BuildIR { multiimports.put(classname, new Error("Error: class " + nd.getIdentifier() + " is defined more than once in a multi-import in " + sourcefile)); } else { - multiimports.put(classname, nd.getIdentifier().replace("\\.", "___________") - + "___________" + classname); + multiimports.put(classname, nd.getIdentifier() + "." + classname); } } } @@ -486,8 +485,8 @@ public class BuildIR { if(packageName == null) { cn=new ClassDescriptor(pn.getChild("name").getTerminal(), false); } else { - String newClassname = packageName + "___________" + pn.getChild("name").getTerminal(); - cn= new ClassDescriptor(packageName, newClassname.replaceAll("\\.", "___________") , false); + String newClassname = packageName + "." + pn.getChild("name").getTerminal(); + cn= new ClassDescriptor(packageName, newClassname, false); } cn.setImports(mandatoryImports); if (!isEmpty(pn.getChild("super").getTerminal())) { diff --git a/Robust/src/IR/Tree/SemanticCheck.java b/Robust/src/IR/Tree/SemanticCheck.java index a7238a89..6f87cbe8 100644 --- a/Robust/src/IR/Tree/SemanticCheck.java +++ b/Robust/src/IR/Tree/SemanticCheck.java @@ -147,10 +147,6 @@ public class SemanticCheck { return; /* Done */ else if (td.isClass()) { String name=td.toString(); - int index = name.lastIndexOf('.'); - if(index != -1) { - name = name.substring(index+1); - } ClassDescriptor field_cd=checkAll?getClass(cd, name):getClass(cd, name, REFERENCE); if (field_cd==null) diff --git a/Robust/src/IR/TypeUtil.java b/Robust/src/IR/TypeUtil.java index 50f68639..30c3c555 100644 --- a/Robust/src/IR/TypeUtil.java +++ b/Robust/src/IR/TypeUtil.java @@ -43,7 +43,6 @@ public class TypeUtil { } public void addNewClass(String cl, Set todo) { - System.out.println("I'm looking for "+cl.replace(".", "/")); //search through the default locations for the file. for (int i = 0; i < state.classpath.size(); i++) { String path = (String) state.classpath.get(i); -- 2.34.1