EmbeddedScript and AsyncEmbeddedScript use _try() when building

This commit is contained in:
2021-11-17 17:33:29 -07:00
parent 21bddc14e2
commit 4e856bc4a7
3 changed files with 33 additions and 27 deletions

View File

@@ -61,22 +61,25 @@ class AsyncEmbeddedScript {
scriptFile = Path.join([loadingDirectory, scriptFile]);
k.fieldList = [];
Reader.readAndProcess(Stream.fromFile(scriptFile), k, (nextExp) -> {
var exprString = Reader.toString(nextExp.def);
var expr = Kiss.readerExpToHaxeExpr(nextExp, k);
Kiss._try(() -> {
Reader.readAndProcess(Stream.fromFile(scriptFile), k, (nextExp) -> {
var exprString = Reader.toString(nextExp.def);
var expr = Kiss.readerExpToHaxeExpr(nextExp, k);
#if debug
expr = macro { trace($v{exprString}); $expr; };
#end
#if debug
expr = macro { trace($v{exprString}); $expr; };
#end
if (expr != null) {
commandList.push(macro function(self, cc) {
$expr;
});
}
if (expr != null) {
commandList.push(macro function(self, cc) {
$expr;
});
}
// This return is essential for type unification of concat() and push() above... ugh.
return;
// This return is essential for type unification of concat() and push() above... ugh.
return;
});
null;
});
classFields = classFields.concat(k.fieldList);

View File

@@ -62,21 +62,24 @@ class EmbeddedScript {
classFields = classFields.concat(Kiss.build(dslFile, k));
scriptFile = Path.join([loadingDirectory, scriptFile]);
Reader.readAndProcess(Stream.fromFile(scriptFile), k, (nextExp) -> {
var expr = Kiss.readerExpToHaxeExpr(nextExp, k);
Kiss._try(() -> {
Reader.readAndProcess(Stream.fromFile(scriptFile), k, (nextExp) -> {
var expr = Kiss.readerExpToHaxeExpr(nextExp, k);
if (expr != null) {
commandList.push(macro function(self) {
$expr;
});
}
if (expr != null) {
commandList.push(macro function(self) {
$expr;
});
}
// This return is essential for type unification of concat() and push() above... ugh.
return;
// TODO also allow label setting and multiple commands coming from the same expr?
// Multiple things could come from the same expr by returning begin, or a call to a function that does more stuff
// i.e. knot declarations need to end the previous knot, and BELOW that set a label for the new one, then increment the read count
// TODO test await
// This return is essential for type unification of concat() and push() above... ugh.
return;
// TODO also allow label setting and multiple commands coming from the same expr?
// Multiple things could come from the same expr by returning begin, or a call to a function that does more stuff
// i.e. knot declarations need to end the previous knot, and BELOW that set a label for the new one, then increment the read count
// TODO test await
});
null;
});
classFields.push({

View File

@@ -121,7 +121,7 @@ class Kiss {
return k;
}
static function _try<T>(operation:() -> T):Null<T> {
public static function _try<T>(operation:() -> T):Null<T> {
#if !macrotest
try {
#end