private StatementSyntax CreateScriptInvocationSyntax(List <StatementSyntax> dependentStatements) { // Collect names of value supplier variables List <string> variableIdentifiers = ObjectBuilder.Inputs.Select((t, index) => Inputs[index].VariableSyntaxName(t.Input.VariableName)).ToList(); // add instance method invocation var invocationExpression = MySyntaxFactory.MethodInvocation("RunScript", variableIdentifiers, m_instanceName); if (dependentStatements == null) { return(SyntaxFactory.ExpressionStatement(invocationExpression)); } var ifStatement = MySyntaxFactory.IfExpressionSyntax(invocationExpression, dependentStatements); return(ifStatement); }
internal override void CollectSequenceExpressions(List <StatementSyntax> expressions) { // Create conditional statement for easier event evaluation. // Considering the first parameter is the key. if (ObjectBuilder.SequenceOutputID == -1) { return; } var nextSequenceNode = Navigator.GetNodeByID(ObjectBuilder.SequenceOutputID); var ifBodyExpressions = new List <StatementSyntax>(); // Collect the syntax from the true branch nextSequenceNode.CollectSequenceExpressions(ifBodyExpressions); var keyIndexes = new List <int>(); var parameters = m_fieldInfo.FieldType.GetMethod("Invoke").GetParameters(); var attribute = m_fieldInfo.FieldType.GetCustomAttribute <VisualScriptingEvent>(); // Find the keys of this key event for (var index = 0; index < parameters.Length; index++) { if (index >= attribute.IsKey.Length) { break; } if (attribute.IsKey[index]) { keyIndexes.Add(index); } } // generate the condition statement var condition = CreateAndClauses(keyIndexes.Count - 1, keyIndexes); var ifStatment = MySyntaxFactory.IfExpressionSyntax(condition, ifBodyExpressions); expressions.Add(ifStatment); }
internal override void CollectSequenceExpressions(List <StatementSyntax> expressions) { // Collect mine input expressions and pushed expressions CollectInputExpressions(expressions); var trueStatments = new List <StatementSyntax>(); var falseStatments = new List <StatementSyntax>(); // Sequence outputs can be connected only to one input if (m_nextTrueSequenceNode != null) { m_nextTrueSequenceNode.CollectSequenceExpressions(trueStatments); } if (m_nextFalseSequenceNode != null) { m_nextFalseSequenceNode.CollectSequenceExpressions(falseStatments); } var inputNodeVariableName = m_comparerNode.VariableSyntaxName(ObjectBuilder.InputID.VariableName); // write my expression before the collected inputs expressions.Add(MySyntaxFactory.IfExpressionSyntax(inputNodeVariableName, trueStatments, falseStatments)); }