static void BuildResultValues(LocalValueScope localValues, ArgumentInstanceCollection results, IContext functionContext) { foreach (var result in results) { var value = result.Argument.Value != null?Dynamic((dynamic)result.Argument.Value, functionContext) : CreateValue(result.Type); localValues.Add(result, value); } }
static IExpression Dynamic(IFunctionInvocation functionInvocation, IContext callerContext) { var localValues = new LocalValueScope(); var argumentIdentifiers = functionInvocation.Function.ArgumentIdentifiers; var localContext = new Context(argumentIdentifiers, localValues); BuildArgumentValues(localValues, functionInvocation.Left, argumentIdentifiers, functionInvocation.Function.LeftArguments, callerContext, localContext); BuildArgumentValues(localValues, functionInvocation.Right, argumentIdentifiers, functionInvocation.Function.RightArguments, callerContext, localContext); BuildResultValues(localValues, functionInvocation.Function.Results, localContext); var result = Dynamic(functionInvocation.Function.Declaration.Implementation, localContext); ExtractArgumentReferenceValues(localValues, functionInvocation.Left, functionInvocation.Function.LeftArguments, callerContext); ExtractArgumentReferenceValues(localValues, functionInvocation.Right, functionInvocation.Function.RightArguments, callerContext); return(ExtractResultValues(localValues, result, functionInvocation.Function.Results)); }