cache converted hscript from ktxt2

This commit is contained in:
2021-11-09 12:22:37 -07:00
parent f022286b37
commit 30c465617d
4 changed files with 23 additions and 2 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
bin/
externLog.txt
*.memoized

View File

@@ -48,8 +48,23 @@ class KissInterp extends Interp {
variables.set("kiss", {});
}
public var cacheConvertedHScript = false;
public function evalKiss(kissStr:String):Dynamic {
return evalHaxe(Prelude.convertToHScript(kissStr));
#if !(sys || hxnodejs)
if (cacheConvertedHScript) {
throw "Cannot used cacheConvertedHScript on a non-sys target";
}
#end
var convert =
#if (sys || hxnodejs)
if (cacheConvertedHScript) {
Prelude.cachedConvertToHScript;
} else
#end
Prelude.convertToHScript;
return evalHaxe(convert(kissStr));
}
public function evalHaxe(hscriptStr:String):Dynamic {

View File

@@ -506,6 +506,10 @@ class Prelude {
#end
}
#if (sys || hxnodejs)
public static var cachedConvertToHScript:String->String = cast(fsMemoize(convertToHScript, "convertToHScript"));
#end
public static function getTarget():KissTarget {
return #if cpp
Cpp;

View File

@@ -69,6 +69,7 @@
(let [&mut sourceText ""
&mut outputText ""
interp (new KissInterp)]
(set interp.cacheConvertedHScript true)
(doFor ktxtElement (splitFileElements fileStream)
(case ktxtElement
((Block (objectWith source output))