DataDictionary.Interpreter.Call.CreateGraph C# (CSharp) Method

CreateGraph() public method

Creates the graph associated to this expression, when the given parameter ranges over the X axis
public CreateGraph ( DataDictionary.Interpreter.InterpretationContext context, Utils.Parameter parameter, ExplanationPart explain ) : Graph
context DataDictionary.Interpreter.InterpretationContext The interpretation context
parameter Utils.Parameter The parameters of *the enclosing function* for which the graph should be created
explain ExplanationPart
return Graph
        public override Graph CreateGraph(InterpretationContext context, Parameter parameter, ExplanationPart explain)
        {
            Graph retVal = base.CreateGraph(context, parameter, explain);

            Cast cast = Called.Ref as Cast;
            if (cast != null)
            {
                // In case of cast, just take the graph of the enclosed expression
                Parameter param = (Parameter) cast.FormalParameters[0];
                retVal = cast.CreateGraphForParameter(context, param, explain);
            }
            else
            {
                Function calledFunction = Called.Ref as Function;
                Dictionary<Parameter, Expression> parameterAssociation;
                if (calledFunction == null)
                {
                    calledFunction = Called.GetValue(context, explain) as Function;
                    parameterAssociation = CreateParameterAssociation(calledFunction);
                }
                else
                {
                    parameterAssociation = ParameterAssociation;
                }

                if (calledFunction != null)
                {
                    Parameter xAxis = null;
                    foreach (KeyValuePair<Parameter, Expression> pair in parameterAssociation)
                    {
                        if (pair.Value.Ref == parameter)
                        {
                            if (xAxis == null)
                            {
                                xAxis = pair.Key;
                            }
                            else
                            {
                                Root.AddError("Cannot evaluate graph for function call " + ToString() +
                                              " which has more than 1 parameter used as X axis");
                                xAxis = null;
                                break;
                            }
                        }
                    }

                    int token = context.LocalScope.PushContext();
                    calledFunction.AssignParameters(context,
                        AssignParameterValues(context, calledFunction, false, explain));
                    if (xAxis != null)
                    {
                        retVal = calledFunction.CreateGraphForParameter(context, xAxis, explain);
                    }
                    else
                    {
                        retVal = Function.CreateGraphForValue(GetValue(context, explain));
                    }
                    context.LocalScope.PopContext(token);
                }
                else
                {
                    AddError("Cannot determine called function", RuleChecksEnum.SemanticAnalysisError);
                }
            }

            return retVal;
        }