|
@@ -77,14 +77,20 @@ namespace NTERA.Engine.Runtime
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- private void PrintStackTrace()
|
|
|
+ private void PrintStackTrace(bool toSystemConsoleOnly)
|
|
|
{
|
|
|
- Console.PrintError("Stack trace:");
|
|
|
+ if (!toSystemConsoleOnly)
|
|
|
+ Console.PrintError("Stack trace:");
|
|
|
|
|
|
foreach (var stackMember in ExecutionStack)
|
|
|
{
|
|
|
string name = stackMember.IsAnonymous ? "<anonymous>" : $"@{stackMember.SelfDefinition.Name}";
|
|
|
- Console.PrintError($" - {name} ({stackMember.SelfDefinition.Position} > {stackMember.SelfDefinition.Filename})");
|
|
|
+ string msg = $" - {name} ({stackMember.SelfDefinition.Position} > {stackMember.SelfDefinition.Filename})";
|
|
|
+ if (toSystemConsoleOnly) {
|
|
|
+ System.Console.Write(msg + "\n");
|
|
|
+ } else {
|
|
|
+ Console.PrintError(msg);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -105,7 +111,7 @@ namespace NTERA.Engine.Runtime
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
Console.PrintError($"Unhandled exception: {ex.Message}");
|
|
|
- PrintStackTrace();
|
|
|
+ PrintStackTrace(false);
|
|
|
|
|
|
throw;
|
|
|
}
|
|
@@ -272,6 +278,7 @@ namespace NTERA.Engine.Runtime
|
|
|
}
|
|
|
else {
|
|
|
System.Console.Write($"Error: {ex.Message}\n");
|
|
|
+ PrintStackTrace(true);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -369,6 +376,15 @@ namespace NTERA.Engine.Runtime
|
|
|
|
|
|
case "call":
|
|
|
string functionName = expressionNode["target"];
|
|
|
+ if (functionName == "__INLINEIF") {
|
|
|
+ // For syntax like \@THIRD_PERSON?Third Person#Second Person\@
|
|
|
+ var node = expressionNode.GetSubtype("parameters");
|
|
|
+ bool condition = ComputeExpression(context, node[0]).Real != 0;
|
|
|
+ if (condition)
|
|
|
+ return ComputeExpression(context, node[1]);
|
|
|
+ else
|
|
|
+ return ComputeExpression(context, node[2]);
|
|
|
+ }
|
|
|
var function = TotalProcedureDefinitions.FirstOrDefault(func => func.IsReturnFunction && func.Name.Equals(functionName, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
if (function == null)
|