Skip to content

Commit cc35acf

Browse files
committed
enable caching per default
1 parent fb48177 commit cc35acf

4 files changed

Lines changed: 7 additions & 9 deletions

File tree

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/CompiletimeFunctionRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public CompiletimeFunctionRunner(
8686
this.translator = tr;
8787
this.imProg = imProg;
8888
globalState = new ProgramStateIO(mapFile, mpqEditor, gui, imProg, true);
89-
this.interpreter = new ILInterpreter(imProg, gui, mapFile, globalState, cache);
89+
this.interpreter = new ILInterpreter(imProg, gui, mapFile, globalState);
9090

9191
interpreter.addNativeProvider(new CompiletimeNatives(globalState, projectConfigData, isProd));
9292
interpreter.addNativeProvider(new ReflectionNativeProvider(interpreter));

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/RunTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public TestResult runTests(ImTranslator translator, ImProg imProg, Optional<Func
157157
globalState = new ProgramState(gui, imProg, true);
158158
}
159159
if (interpreter == null) {
160-
interpreter = new ILInterpreter(imProg, gui, Optional.empty(), globalState, false);
160+
interpreter = new ILInterpreter(imProg, gui, Optional.empty(), globalState);
161161
interpreter.addNativeProvider(new ReflectionNativeProvider(interpreter));
162162
}
163163

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/intermediatelang/interpreter/ILInterpreter.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,18 @@
2828

2929
public class ILInterpreter implements AbstractInterpreter {
3030
private ImProg prog;
31-
private static boolean cache = false;
3231
private final ProgramState globalState;
3332
private final TimerMockHandler timerMockHandler = new TimerMockHandler();
3433

35-
public ILInterpreter(ImProg prog, WurstGui gui, Optional<File> mapFile, ProgramState globalState, boolean cache) {
34+
public ILInterpreter(ImProg prog, WurstGui gui, Optional<File> mapFile, ProgramState globalState) {
3635
this.prog = prog;
3736
this.globalState = globalState;
38-
ILInterpreter.cache = cache;
3937
globalState.addNativeProvider(new BuiltinFuncs(globalState));
4038
// globalState.addNativeProvider(new NativeFunctions());
4139
}
4240

43-
public ILInterpreter(ImProg prog, WurstGui gui, Optional<File> mapFile, boolean isCompiletime, boolean cache) {
44-
this(prog, gui, mapFile, new ProgramState(gui, prog, isCompiletime), cache);
41+
public ILInterpreter(ImProg prog, WurstGui gui, Optional<File> mapFile, boolean isCompiletime) {
42+
this(prog, gui, mapFile, new ProgramState(gui, prog, isCompiletime));
4543
}
4644

4745
public static LocalState runFunc(ProgramState globalState, ImFunction f, @Nullable Element caller,
@@ -174,7 +172,7 @@ private static LocalState runBuiltinFunction(ProgramState globalState, ImFunctio
174172
private static LocalState runBuiltinFunction(ProgramState globalState, ImFunction f, ILconst[] args, boolean isVarargs) {
175173
// Cache purity + name once
176174
final String fname = f.getName();
177-
final boolean pure = cache && isFunctionPure(fname);
175+
final boolean pure = isFunctionPure(fname);
178176

179177
// Fast, zero-allocation rolling hash for args (no Object[] boxing like Objects.hash)
180178
final int combinedHash = pure ? fastHashArgs(args) : 0;

de.peeeq.wurstscript/src/test/java/tests/wurstscript/tests/WurstScriptTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ private void runPjass(File outputFile) throws Error {
558558
private void executeImProg(WurstGui gui, ImProg imProg) throws TestFailException {
559559
try {
560560
// run the interpreter on the intermediate language
561-
ILInterpreter interpreter = new ILInterpreter(imProg, gui, Optional.empty(), false, false);
561+
ILInterpreter interpreter = new ILInterpreter(imProg, gui, Optional.empty(), false);
562562
interpreter.addNativeProvider(new ReflectionNativeProvider(interpreter));
563563
interpreter.executeFunction("main", null);
564564
} catch (TestSuccessException e) {

0 commit comments

Comments
 (0)