SolidityStatement CreateMultiInstanceCounterDefinition() { if (userTaskElement.LoopCardinality != 0 || userTaskElement.LoopCollection != null) { var variableName = ConversionTemplates.MultiInstanceCounterVariable(GetElementCallName()); return(new SolidityStatement($"uint256 {variableName}")); } return(null); }
public override SolidityStatement GetStatementForPrevious(ProcessElement previous) { var statement = new SolidityStatement(); if (counterVariablePresent) { statement.Add(new SolidityStatement($"{ConversionTemplates.MultiInstanceCounterVariable(GetElementCallName())} = 0")); } statement.Add(GetChangeActiveStateStatement(true)); return(statement); }
List <SolidityComponent> CreateCallNextBody() { var components = new List <SolidityComponent>(); var callNextStatement = GetChangeActiveStateStatement(false); callNextStatement.Add(processConverter.GetStatementOfNextElement(userTaskElement)); if (userTaskElement.InstanceType != InstanceType.Single) { //The tasks will run until it gets interrupted by some boundary event if (userTaskElement.LoopCardinality == -1 || (userTaskElement.LoopCardinality == 0 && userTaskElement.LoopCollection == null)) { return(components); } var ifStatement = new SolidityIfElse(); var counterVariableName = ConversionTemplates.MultiInstanceCounterVariable(GetElementCallName()); components.Add(new SolidityStatement($"{counterVariableName}++")); counterVariablePresent = true; if (userTaskElement.LoopCardinality > 0) { ifStatement.AddConditionBlock($"{counterVariableName} >= {userTaskElement.LoopCardinality}", callNextStatement); } else if (userTaskElement.LoopCollection != null) { ifStatement.AddConditionBlock($"{counterVariableName} >= {GetCountTarget(userTaskElement)}", callNextStatement); } components.Add(ifStatement); } else { components.Add(callNextStatement); } return(components); }