/// <summary> /// Provides the callable that is called by this expression /// </summary> /// <param name="context"></param> /// <param name="explain"></param> /// <returns></returns> public override ICallable GetCalled(InterpretationContext context, ExplanationPart explain) { ICallable retVal = null; Function function = InitialValue.Ref as Function; if (function == null) { function = InitialValue.GetCalled(context, explain) as Function; } if (function != null) { if (function.FormalParameters.Count == 1) { int token = context.LocalScope.PushContext(); context.LocalScope.SetGraphParameter((Parameter)function.FormalParameters[0]); Graph graph = CreateGraph(context, (Parameter)function.FormalParameters[0], explain); context.LocalScope.PopContext(token); if (graph != null) { retVal = graph.Function; } } else if (function.FormalParameters.Count == 2) { int token = context.LocalScope.PushContext(); context.LocalScope.SetSurfaceParameters((Parameter)function.FormalParameters[0], (Parameter)function.FormalParameters[1]); Surface surface = CreateSurface(context, (Parameter)function.FormalParameters[0], (Parameter)function.FormalParameters[1], explain); context.LocalScope.PopContext(token); if (surface != null) { retVal = surface.Function; } } else { AddError("Cannot evaluate REDUCE expression to a function", RuleChecksEnum.ExecutionFailed); } } else { AddError("Cannot evaluate REDUCE expression to a function", RuleChecksEnum.ExecutionFailed); } return(retVal); }