make AsyncEmbeddedScript instruction tracing possible without debug build

This commit is contained in:
2023-07-17 11:43:05 -06:00
parent 552d3978e4
commit d608beaf32
2 changed files with 6 additions and 3 deletions

View File

@@ -192,6 +192,8 @@ class AsyncEmbeddedScript {
return [for (label => ip in labels) label => () -> skipToInstruction(ip)];
}
public var printCurrentInstruction = true;
#if macro
public static function build(dslHaxelib:String, dslFile:String, scriptFile:String):Array<Field> {
// trace('AsyncEmbeddedScript.build $dslHaxelib $dslFile $scriptFile');
@@ -288,10 +290,8 @@ class AsyncEmbeddedScript {
var expr = Kiss.readerExpToHaxeExpr(nextExp, k);
if (Kiss.isEmpty(expr))
return;
#if debug
expr = macro { Prelude.print($v{exprString}); $expr; };
expr = macro { if (printCurrentInstruction) Prelude.print($v{exprString}); $expr; };
expr = expr.expr.withMacroPosOf(nextExp);
#end
if (expr != null) {
var c = macro function(self, cc) {
$expr;

View File

@@ -42,6 +42,9 @@ class DSLScript extends EmbeddedScript {}
@:build(kiss.AsyncEmbeddedScript.build("", "DSL.kiss", "AsyncDSLScript.dsl"))
class AsyncDSLScript extends AsyncEmbeddedScript {}
// One of these two classes will reuse instructions from the cache, but
// I can't guarantee which one compiles first:
@:build(kiss.AsyncEmbeddedScript.build("", "DSL.kiss", "AsyncDSLScriptThatWillCache.dsl"))
class AsyncDSLScriptThatWillCache extends AsyncEmbeddedScript {}