Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified source_.jar
Binary file not shown.
9 changes: 7 additions & 2 deletions src/main/java/cod/ir/IRManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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() {
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/cod/ptac/Lowerer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/cod/runner/CommandRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 + " → <project>.codc/" + ast.unit.name + "/" + type.name + ".codb");
String unitPath = IRManager.toUnitPath(ast.unit.name);
System.out.println("Compiled (CodP-TAC artifact): " + type.name + " → <project>.codc/" + unitPath + "/" + type.name + ".codb");
compiled++;
}

Expand Down Expand Up @@ -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 + " → <project>.codc/" + unitName + "/" + type.name + ".codb");
String unitPath = IRManager.toUnitPath(unitName);
DebugSystem.debug(NAME + LOG_TAG, "Compiled CodP-TAC artifact: " + type.name + " → <project>.codc/" + unitPath + "/" + type.name + ".codb");
} catch (Exception e) {
DebugSystem.warn(NAME + LOG_TAG, "Failed to compile " + type.name + ": " + e.getMessage());
}
Expand Down Expand Up @@ -287,4 +289,5 @@ private Type findMainType(Program ast) {
}
return !ast.unit.types.isEmpty() ? ast.unit.types.get(0) : null;
}

}
4 changes: 3 additions & 1 deletion src/main/java/cod/runner/TestRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 + " → <project>.codc/" + unitName + "/" + type.name + ".codb");
String unitPath = IRManager.toUnitPath(unitName);
DebugSystem.debug(NAME + LOG_TAG, "Compiled CodP-TAC artifact: " + type.name + " → <project>.codc/" + unitPath + "/" + type.name + ".codb");
} catch (Exception e) {
DebugSystem.warn(NAME + LOG_TAG, "Failed to compile " + type.name + ": " + e.getMessage());
}
Expand Down Expand Up @@ -386,4 +387,5 @@ private Type findMainType(Program ast) {
}
return !ast.unit.types.isEmpty() ? ast.unit.types.get(0) : null;
}

}