Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        static string Dynamic(IFunctionInvocation functionInvocation, ICppScope scope)
        {
            var function = functionInvocation.Function;

            if (function.Declaration.Implementation.Expressions.Count == 1 && function.Declaration.Implementation.Expressions.First() is IIntrinsicExpression)
            {
                scope.EnsureGlobal(function.Name, () => { return(CreateGlobalDeclaration(scope, subScope => DeclareFunction(function.Declaration, subScope))); });
            }

            var leftArgs   = BuildArgumentValues(function, function.Declaration.LeftArguments, functionInvocation.Left, scope, kind: "Left");
            var rightArgs  = BuildArgumentValues(function, function.Declaration.RightArguments, functionInvocation.Right, scope, kind: "Right");
            var resultName = string.Empty;
            var resultArgs = BuildResultValues(function, scope, ref resultName);

            scope.Runtime.AddLine(BuildInvocation(function.Name, leftArgs, rightArgs, resultArgs));
            return(resultName);
        }
Exemplo n.º 3
0
 void AssertExpression(IFunctionInvocation expected, IFunctionInvocation actual, string label)
 {
     Assert.AreEqual(expected.Function, actual.Function, $"{label}.Function");
     AssertNamedExpressionTuple(expected.Left, actual.Left, label: $"{label}.Left");
     AssertNamedExpressionTuple(expected.Right, actual.Right, label: $"{label}.Right");
 }