Skip to content

Commit 6bbe01f

Browse files
committed
made const fold pass kosher
1 parent 9384f7f commit 6bbe01f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

compiler/src/jlang/JLangScheduler.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,15 @@ public Goal JLangConstFold(Job job) {
104104
ExtensionInfo extInfo = job.extensionInfo();
105105
JLangTypeSystem ts = (JLangTypeSystem) extInfo.typeSystem();
106106
JLangNodeFactory nf = (JLangNodeFactory) extInfo.nodeFactory();
107-
return new VisitorGoal(job, new StringLitFold(ts, nf));
108-
107+
Goal constGoal = new VisitorGoal(job, new StringLitFold(ts, nf));
108+
try {
109+
// ensure all desugaring is done for the file (might generate more constants)
110+
constGoal.addPrerequisiteGoal(LLVMDesugared(job), this);
111+
} catch (CyclicDependencyException e) {
112+
throw new InternalCompilerError(e);
113+
}
114+
// intern goal to remove duplicate objects being created (explicit singleton)
115+
return internGoal(constGoal);
109116
}
110117

111118
@Override

0 commit comments

Comments
 (0)