public void Convert() { MethodRoot.Start = ConvertNode(MethodRoot.Start); var graphNodes = MethodRoot.Start.IterateGraphNodesRecursive(false).ToArray(); foreach (var graphNode in graphNodes) { ConvertNode(graphNode); } GraphNode ConvertNode(GraphNode graphNode) { return(graphNode switch { null => throw new ArgumentOutOfRangeException(nameof(graphNode)), GraphDataFlowBlockNode _ => graphNode, GraphDataFlowExpressionNode _ => graphNode, GraphControlFlowBlockNode blockNode => ConvertControlFlowNode(blockNode), GraphControlFlowConditionalNode conditionalNode => ConvertControlFlowNode(conditionalNode), GraphControlFlowReturnNode returnNode => ConvertControlFlowNode(returnNode), GraphDataFlowConditionalNode _ => graphNode, GraphDataFlowReturnNode _ => graphNode, _ => throw new ArgumentOutOfRangeException(nameof(graphNode)) }); }
private void SolveConditionContexts( [NotNull] GraphDataFlowConditionalNode node, [NotNull] LogicExpressionBase expression, [NotNull] GraphNode[] path) { var trueChanges = new List <(ValueVariantBase, IDataValue)>(); var falseChanges = new List <(ValueVariantBase, IDataValue)>(); if (!SolveExpression(node.EnterAnalysisContext, expression, trueChanges, falseChanges)) { Log.Information("Logic: {Operator} -> {Expression}", expression.Operator, expression); } foreach (var grouping in trueChanges.GroupBy(x => x.Item1, x => x.Item2)) { var(variant, dataValue) = (grouping.Key, grouping.ToArray()); var newVariant = variant.Clone(node.EnterAnalysisContext, path); newVariant.Value = ValueUtilities.IterateValues(dataValue, variant.Value, dataValue.Length + 1, ValueUtilities.IterateValuesAndFunc); node.TrueExitAnalysisContext[variant] = newVariant; } foreach (var grouping in falseChanges.GroupBy(x => x.Item1, x => x.Item2)) { var(variant, dataValue) = (grouping.Key, grouping.ToArray()); var newVariant = variant.Clone(node.EnterAnalysisContext, path); newVariant.Value = ValueUtilities.IterateValues(dataValue, variant.Value, dataValue.Length + 1, ValueUtilities.IterateValuesAndFunc); node.FalseExitAnalysisContext[variant] = newVariant; } }