public int Execute(Frame frame)
        {
            InternalLambda[] lambdas = new InternalLambda[descriptions.Length];
            for (int i = 0; i < lambdas.Length; i++)
            {
                lambdas[i] = new InternalLambda
                {
                    closures = frame.closures,
                    context = frame.global,
                    description = descriptions[i]
                };
            }

            frame.result = RuntimeUtil.CanonicalizeLambdas(lambdas);
            return 1;
        }
Exemple #2
0
        public int Execute(Frame frame)
        {
            RedwoodType leftType  = leftKnownType ?? RuntimeUtil.GetTypeOf(frame.stack[leftIndex]);
            RedwoodType rightType = rightKnownType ?? RuntimeUtil.GetTypeOf(frame.stack[rightIndex]);

            string lambdaName = RuntimeUtil.NameForOperator(op);
            Lambda leftLambda;
            Lambda rightLambda;

            leftLambda  = ResolveLambda(leftType, lambdaName);
            rightLambda = ResolveLambda(rightType, lambdaName);

            Lambda lambda = RuntimeUtil.CanonicalizeLambdas(leftLambda, rightLambda);

            lambda = RuntimeUtil.SelectSingleOverload(
                new RedwoodType[] { leftType, rightType },
                lambda
                );

            frame.result = lambda;
            return(1);

            Lambda ResolveLambda(RedwoodType type, string lambdaName)
            {
                Lambda lambda;

                if (type.CSharpType == null)
                {
                    int slot = type.staticSlotMap.GetValueOrDefault(lambdaName, -1);

                    if (slot == -1)
                    {
                        lambda = null;
                    }
                    else
                    {
                        lambda = type.staticLambdas[slot];
                    }
                }
                else
                {
                    MemberResolver.TryResolveLambda(null, type, lambdaName, out lambda);
                }

                return(lambda);
            }
        }
 public int Execute(Frame frame)
 {
     frame.result = RuntimeUtil.CanonicalizeLambdas(new LambdaGroup(frame.result, group.infos));
     return 1;
 }