diff --git a/source_.jar b/source_.jar index 1aa1a7a5..0203767a 100644 Binary files a/source_.jar and b/source_.jar differ diff --git a/src/main/java/cod/ir/IRManager.java b/src/main/java/cod/ir/IRManager.java index 220d910d..02a8263f 100644 --- a/src/main/java/cod/ir/IRManager.java +++ b/src/main/java/cod/ir/IRManager.java @@ -210,7 +210,7 @@ private void putArtifactCache(String unit, String className, Artifact artifact) } private File getIRFile(String unit, String className) { - String path = projectRoot + "/src/" + BIN_DIR + "/" + unit + "/" + className + IR_EXT; + String path = projectRoot + "/src/" + BIN_DIR + "/" + toUnitPath(unit) + "/" + className + IR_EXT; return new File(path); } @@ -220,7 +220,12 @@ private File getContainerFile(String unit) { } private String getContainerEntryName(String unit, String className) { - return unit + "/" + className + IR_EXT; + return toUnitPath(unit) + "/" + className + IR_EXT; + } + + public static String toUnitPath(String unit) { + if (unit == null) return ""; + return unit.replace('.', '/'); } private String getProjectIndexEntryName() { diff --git a/src/main/java/cod/ptac/Lowerer.java b/src/main/java/cod/ptac/Lowerer.java index bac3a95d..47b37717 100644 --- a/src/main/java/cod/ptac/Lowerer.java +++ b/src/main/java/cod/ptac/Lowerer.java @@ -14,6 +14,7 @@ public final class Lowerer { private int lambdaCounter = 0; public Unit lower(String unitName, Type type) { + resetCounters(); Unit unit = new Unit(); unit.unitName = unitName; unit.className = type != null ? type.name : null; @@ -34,6 +35,12 @@ public Unit lower(String unitName, Type type) { return unit; } + private void resetCounters() { + tempCounter = 0; + patternCounter = 0; + lambdaCounter = 0; + } + private Function lowerMethod(Method method, Unit unit) { Function fn = new Function(); fn.name = method != null ? method.methodName : "anonymous"; diff --git a/src/main/java/cod/runner/CommandRunner.java b/src/main/java/cod/runner/CommandRunner.java index 3b17d708..85a3346c 100644 --- a/src/main/java/cod/runner/CommandRunner.java +++ b/src/main/java/cod/runner/CommandRunner.java @@ -139,7 +139,8 @@ private void handleCompileCommand(String[] args) throws Exception { int compiled = 0; for (Type type : ast.unit.types) { bm.save(ast.unit.name, type); - System.out.println("Compiled (CodP-TAC artifact): " + type.name + " → .codc/" + ast.unit.name + "/" + type.name + ".codb"); + String unitPath = IRManager.toUnitPath(ast.unit.name); + System.out.println("Compiled (CodP-TAC artifact): " + type.name + " → .codc/" + unitPath + "/" + type.name + ".codb"); compiled++; } @@ -227,7 +228,8 @@ private void compileToBytecode(Program ast) { try { irManager.save(unitName, type); compiled++; - DebugSystem.debug(NAME + LOG_TAG, "Compiled CodP-TAC artifact: " + type.name + " → .codc/" + unitName + "/" + type.name + ".codb"); + String unitPath = IRManager.toUnitPath(unitName); + DebugSystem.debug(NAME + LOG_TAG, "Compiled CodP-TAC artifact: " + type.name + " → .codc/" + unitPath + "/" + type.name + ".codb"); } catch (Exception e) { DebugSystem.warn(NAME + LOG_TAG, "Failed to compile " + type.name + ": " + e.getMessage()); } @@ -287,4 +289,5 @@ private Type findMainType(Program ast) { } return !ast.unit.types.isEmpty() ? ast.unit.types.get(0) : null; } + } diff --git a/src/main/java/cod/runner/TestRunner.java b/src/main/java/cod/runner/TestRunner.java index 28d36df7..88be6f2b 100644 --- a/src/main/java/cod/runner/TestRunner.java +++ b/src/main/java/cod/runner/TestRunner.java @@ -312,7 +312,8 @@ private void compileToBytecode(Program ast) { try { irManager.save(unitName, type); compiled++; - DebugSystem.debug(NAME + LOG_TAG, "Compiled CodP-TAC artifact: " + type.name + " → .codc/" + unitName + "/" + type.name + ".codb"); + String unitPath = IRManager.toUnitPath(unitName); + DebugSystem.debug(NAME + LOG_TAG, "Compiled CodP-TAC artifact: " + type.name + " → .codc/" + unitPath + "/" + type.name + ".codb"); } catch (Exception e) { DebugSystem.warn(NAME + LOG_TAG, "Failed to compile " + type.name + ": " + e.getMessage()); } @@ -386,4 +387,5 @@ private Type findMainType(Program ast) { } return !ast.unit.types.isEmpty() ? ast.unit.types.get(0) : null; } + }