예제 #1
0
 public static UnaryExpression Decrementor(XzaarExpression item)
 {
     return(UnaryOperation(item, ExpressionType.Decrement));
 }
 public FunctionCallExpression1(FunctionExpression method, XzaarExpression arg0)
     : base(method)
 {
     _arg0 = arg0;
 }
 public FunctionCallExpression3(FunctionExpression method, XzaarExpression arg0, XzaarExpression arg1, XzaarExpression arg2)
     : base(method)
 {
     _arg0 = arg0;
     _arg1 = arg1;
     _arg2 = arg2;
 }
 public static FunctionCallExpression ArrayIndex(XzaarExpression array, params XzaarExpression[] indexes)
 {
     return(ArrayIndex(array, (IEnumerable <XzaarExpression>)indexes));
 }
 public InstanceFunctionCallExpressionN(FunctionExpression method, XzaarExpression instance, IList <XzaarExpression> args)
     : base(method)
 {
     _instance = instance;
     arguments = args;
 }
예제 #6
0
 public LoopExpression Update(LabelTarget breakLabel, LabelTarget continueLabel, XzaarExpression body)
 {
     if (breakLabel == BreakLabel && continueLabel == ContinueLabel && body == Body)
     {
         return(this);
     }
     return(XzaarExpression.Loop(body, breakLabel, continueLabel));
 }
예제 #7
0
 public static LoopExpression Loop(XzaarExpression body, LabelTarget @break)
 {
     return(Loop(body, @break, null));
 }
예제 #8
0
 public static IfElseExpression IfThen(XzaarExpression test, XzaarExpression ifTrue)
 {
     return(IfElse(test, ifTrue, XzaarExpression.Empty(), XzaarBaseTypes.Void));
 }
예제 #9
0
 public static IfElseExpression IfThenElse(XzaarExpression test, XzaarExpression ifTrue, XzaarExpression ifFalse)
 {
     return(IfElse(test, ifTrue, ifFalse, XzaarBaseTypes.Void));
 }
예제 #10
0
        public static IfElseExpression IfElse(XzaarExpression test, XzaarExpression ifTrue, XzaarExpression ifFalse)
        {
            RequiresCanRead(test, "test");
            RequiresCanRead(ifTrue, "ifTrue");
            RequiresCanRead(ifFalse, "ifFalse");

            if (test.Type != XzaarBaseTypes.Boolean && test.Type != XzaarBaseTypes.Any)
            {
                throw new InvalidOperationException("Argument must be boolean");
            }


            // only true for the '??' operator, but we don't have that in XzaarScript (yet)

            //if (!XzaarTypeUtils.AreEquivalent(ifTrue.Type, ifFalse.Type))
            //{
            //    // throw Error.ArgumentTypesMustMatch();
            //    throw new InvalidOperationException("Argument types must match");
            //}

            return(IfElseExpression.Make(test, ifTrue, ifFalse, ifTrue.Type));
        }
예제 #11
0
        public static IfElseExpression IfElse(XzaarExpression test, XzaarExpression ifTrue, XzaarExpression ifFalse, XzaarType type)
        {
            RequiresCanRead(test, "test");
            RequiresCanRead(ifTrue, "ifTrue");
            RequiresCanRead(ifFalse, "ifFalse");

            if (test.Type != XzaarBaseTypes.Boolean)
            {
                // throw Error.ArgumentMustBeBoolean();
                throw new InvalidOperationException("Argument must be boolean");
            }

            if (type != XzaarBaseTypes.Void)
            {
                if (!XzaarTypeUtils.AreReferenceAssignable(type, ifTrue.Type) ||
                    !XzaarTypeUtils.AreReferenceAssignable(type, ifFalse.Type))
                {
                    throw new InvalidOperationException("Argument types must match");
                }
            }

            return(IfElseExpression.Make(test, ifTrue, ifFalse, type));
        }
예제 #12
0
 public static ConditionalExpression Conditional(XzaarExpression test, XzaarExpression whenTrue, XzaarExpression whenFalse, XzaarType type)
 {
     return(new ConditionalExpression(test, whenTrue, whenFalse, type));
 }
예제 #13
0
 internal FullIfElseExpressionWithType(XzaarExpression test, XzaarExpression ifTrue, XzaarExpression ifFalse, XzaarType type)
     : base(test, ifTrue, ifFalse)
 {
     _type = type;
 }
예제 #14
0
 internal FullIfElseExpression(XzaarExpression test, XzaarExpression ifTrue, XzaarExpression ifFalse)
     : base(test, ifTrue)
 {
     _false = ifFalse;
 }
예제 #15
0
 internal FunctionExpression(string name, ParameterExpression[] parameters, XzaarType returnType, XzaarExpression body, bool isExtern)
 {
     this.name       = name;
     this.Parameters = parameters;
     this.returnType = returnType;
     this.body       = body;
     this.IsExtern   = isExtern;
 }
예제 #16
0
 internal IfElseExpression(XzaarExpression test, XzaarExpression ifTrue)
 {
     this.test   = test;
     this.ifTrue = ifTrue;
 }
예제 #17
0
 public FunctionExpression SetBody(XzaarExpression body)
 {
     this.body = body;
     return(this);
 }
예제 #18
0
 internal static IfElseExpression Make(XzaarExpression test, XzaarExpression ifTrue, XzaarExpression ifFalse, XzaarType type)
 {
     if (ifTrue.Type != type || ifFalse.Type != type)
     {
         return(new FullIfElseExpressionWithType(test, ifTrue, ifFalse, type));
     }
     if (ifFalse is DefaultExpression && ifFalse.Type == XzaarBaseTypes.Void)
     {
         return(new IfElseExpression(test, ifTrue));
     }
     else
     {
         return(new FullIfElseExpression(test, ifTrue, ifFalse));
     }
 }
예제 #19
0
 public static LoopExpression Loop(XzaarExpression body)
 {
     return(Loop(body, null));
 }
예제 #20
0
 internal virtual XzaarExpression GetFalse()
 {
     return(XzaarExpression.Empty());
 }
        private static XzaarExpression ValidateOneArgument(XzaarMethodBase method, ExpressionType nodeKind, XzaarExpression arg, XzaarParameterInfo pi)
        {
            // this is most likely an 'Any' object
            if (pi == null)
            {
                return(arg);
            }

            RequiresCanRead(arg, "arguments");

            var pType = pi.ParameterType;

            if (pType.IsByRef)
            {
                pType = pType.GetElementType();
            }
            // XzaarTypeUtils.ValidateType(pType);
            if (!XzaarTypeUtils.AreReferenceAssignable(pType, arg.Type))
            {
                if (!TryQuote(pType, ref arg))
                {
                    // Throw the right error for the node we were given
                    switch (nodeKind)
                    {
                    case ExpressionType.New:
                        throw new InvalidOperationException();

                    // throw Error.ExpressionTypeDoesNotMatchConstructorParameter(arg.Type, pType);
                    case ExpressionType.Invoke:
                        throw new InvalidOperationException();

                    // throw Error.ExpressionTypeDoesNotMatchParameter(arg.Type, pType);
                    case ExpressionType.Dynamic:
                    case ExpressionType.Call:
                        throw new InvalidOperationException();

                    // throw Error.ExpressionTypeDoesNotMatchMethodParameter(arg.Type, pType, method);
                    default:
                        throw new InvalidOperationException();
                        // throw ContractUtils.Unreachable;
                    }
                }
            }
            return(arg);
        }
예제 #22
0
 public static GotoExpression MakeGoto(GotoExpressionKind kind, LabelTarget target, XzaarExpression value, XzaarType type)
 {
     ValidateGoto(target, ref value, "target", "value");
     return(new GotoExpression(kind, target, value, type));
 }
 internal virtual FunctionCallExpression Rewrite(XzaarExpression instance, IList <XzaarExpression> args)
 {
     throw new InvalidOperationException();
 }
예제 #24
0
 public static GotoExpression Break(LabelTarget target, XzaarExpression value)
 {
     return(MakeGoto(GotoExpressionKind.Break, target, value, XzaarBaseTypes.Void));
 }
        private object _arg0;       // storage for the 1st argument or a readonly collection.  See IArgumentProvider

        public FunctionCallExpression1(XzaarMethodBase method, XzaarExpression arg0)
            : base(method)
        {
            _arg0 = arg0;
        }
예제 #26
0
 public static GotoExpression Break(LabelTarget target, XzaarExpression value, XzaarType type)
 {
     return(MakeGoto(GotoExpressionKind.Break, target, value, type));
 }
 public FunctionCallExpression2(FunctionExpression method, XzaarExpression arg0, XzaarExpression arg1)
     : base(method)
 {
     _arg0 = arg0;
     _arg1 = arg1;
 }
예제 #28
0
 public static FunctionExpression Function(string name, ParameterExpression[] parameters, XzaarType returnType, XzaarExpression body, bool isExtern)
 {
     if (name == null)
     {
         throw new ArgumentNullException(nameof(name));
     }
     return(new FunctionExpression(name, parameters, returnType, body, isExtern));
 }
        private readonly XzaarExpression _arg1, _arg2, _arg3; // storage for the 2nd - 4th args.

        public FunctionCallExpression4(XzaarMethodBase method, XzaarExpression arg0, XzaarExpression arg1, XzaarExpression arg2, XzaarExpression arg3)
            : base(method)
        {
            _arg0 = arg0;
            _arg1 = arg1;
            _arg2 = arg2;
            _arg3 = arg3;
        }
예제 #30
0
 public static UnaryExpression PostDecrementor(XzaarExpression item)
 {
     return(UnaryOperation(item, ExpressionType.PostDecrementAssign));
 }