private Expression CallOverloadInverted(DynamicMetaObject target, DynamicMetaObject arg, OverloadOperation op, Expression fallback)
 {
     return Expression.Coalesce(
         Expression.Call(
             typeof(Builtins).GetMethod("CallOverloadInverted"),
             Expression.Constant(Runtime),
             Expression.Constant(op),
             Utils.CastScalar(target),
             Utils.CastAny(arg)),
         fallback);
 }
Exemplo n.º 2
0
        public static P5Scalar CallOverloadInverted(Runtime runtime, OverloadOperation op,
                                                    P5Scalar left, IP5Any right)
        {
            Overloads oright;

            if (!IsOverloaded(runtime, right, out oright))
                return null;

            return oright.CallOperation(runtime, op, left, right, true);
        }
Exemplo n.º 3
0
        public void AddOperation(Runtime runtime, OverloadOperation op,
                                 IP5Any value)
        {
            P5Scalar s = value as P5Scalar;
            int idx = (int)op;

            if (s != null && s.IsReference(runtime))
            {
                var code = s.Dereference(runtime) as P5Code;

                if (code != null)
                {
                    subroutines[idx] = code;
                    methods[idx] = null;
                    return;
                }
            }

            subroutines[idx] = null;
            methods[idx] = value.AsString(runtime);
        }
Exemplo n.º 4
0
        public static P5Scalar CallOverload(Runtime runtime, OverloadOperation op,
                                            P5Scalar left, IP5Any right)
        {
            Overloads oleft, oright;

            if (   !IsOverloaded(runtime, left, out oleft)
                && !IsOverloaded(runtime, right, out oright))
                return null;

            Overloads overload = oleft ?? oright;

            return overload.CallOperation(runtime, op, left, right,
                                          overload == oright);
        }
Exemplo n.º 5
0
        public P5Scalar CallOperation(Runtime runtime, OverloadOperation op,
                                      P5Scalar left, IP5Any right,
                                      bool inverted)
        {
            var args = new P5Array(runtime,
                                   inverted ? right : left,
                                   inverted ? left : right,
                                   new P5Scalar(runtime, inverted));

            if (subroutines[(int)op] != null)
            {
                return subroutines[(int)op].Call(runtime,
                                                 Opcode.ContextValues.SCALAR,
                                                 args) as P5Scalar;
            }
            else
            {
                return args.CallMethod(runtime, Opcode.ContextValues.SCALAR,
                                       methods[(int)op]) as P5Scalar;
            }
        }