public override IExecutableNode Execute(ExecutionFlowData data) { int count = GetInputValue("Count", this.count); // Execution does not leave this node until the loop completes IExecutableNode next = GetNextExecutableNode(); for (current = 0; current < count; current++) { (Graph as MonoBehaviourGraph).Execute(next, data); } return(GetNextExecutableNode("Then")); }
/// <summary> /// Execute the graph starting from the given parent node /// </summary> public void Execute(IExecutableNode root, ExecutionFlowData data) { // Execute through the graph until we run out of nodes to execute. // Each node will return the next node to be executed in the path. IExecutableNode next = root; int iterations = 0; while (next != null) { next = next.Execute(data); iterations++; if (iterations > 2000) { Debug.LogError("Potential infinite loop detected. Stopping early.", this); break; } } }
public static async Task RunNode(this IExecutableNode item, object input) { var result = await Task.Run(() => item.OnExecuteAction(input)); Task.Run(() => item.CallNextItem(result)); // fire and forget }
private bool BindInReturnStatement(ReturnStatementNode returnStatement, VariableIdentifierMap variableIdentifierMap) { TypeSymbolNode?returnedType = null; if (returnStatement.ReturnExpressionNode != null) { returnedType = BindInExpression(returnStatement.ReturnExpressionNode, variableIdentifierMap); if (returnedType == null) { return(false); } } IExecutableNode functionOrProgram = FindReturnableParent(returnStatement); if (!typeManager.TryGetTypeSymbol(functionOrProgram.ReturnTypeNode, out TypeSymbolNode? actualReturnType)) { return(false); } if (returnedType == null) { if (actualReturnType != null) { string functionName = functionOrProgram is FunctionDeclarationNode declaration ? declaration.Identifier : "<Program>"; ErrorProvider.ReportError(ErrorCode.ReturnedNoValueEvenThoughFunctionShouldReturn, Compilation, (Node?)returnStatement.ReturnExpressionNode ?? returnStatement, $"Function: {functionName}"); return(false); } return(true); } else if (actualReturnType == null) { string functionName = functionOrProgram is FunctionDeclarationNode declaration ? declaration.Identifier : "<Program>"; ErrorProvider.ReportError(ErrorCode.ReturnedValueEvenThoughFunctionDoesNotHaveReturnType, Compilation, (Node?)returnStatement.ReturnExpressionNode ?? returnStatement, $"Function: {functionName}"); return(false); } if (!TypeIsCompatibleWith(returnedType, actualReturnType, possiblyOffendingNode: returnStatement.ReturnExpressionNode !, out ImplicitConversionSymbolNode? conversion)) { return(false); } if (conversion != null) { returnStatement.ReturnExpressionNode !.SpecifyImplicitConversion(conversion); } return(true); }