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; }
public LoopExpression Update(LabelTarget breakLabel, LabelTarget continueLabel, XzaarExpression body) { if (breakLabel == BreakLabel && continueLabel == ContinueLabel && body == Body) { return(this); } return(XzaarExpression.Loop(body, breakLabel, continueLabel)); }
public static LoopExpression Loop(XzaarExpression body, LabelTarget @break) { return(Loop(body, @break, null)); }
public static IfElseExpression IfThen(XzaarExpression test, XzaarExpression ifTrue) { return(IfElse(test, ifTrue, XzaarExpression.Empty(), XzaarBaseTypes.Void)); }
public static IfElseExpression IfThenElse(XzaarExpression test, XzaarExpression ifTrue, XzaarExpression ifFalse) { return(IfElse(test, ifTrue, ifFalse, XzaarBaseTypes.Void)); }
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)); }
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)); }
public static ConditionalExpression Conditional(XzaarExpression test, XzaarExpression whenTrue, XzaarExpression whenFalse, XzaarType type) { return(new ConditionalExpression(test, whenTrue, whenFalse, type)); }
internal FullIfElseExpressionWithType(XzaarExpression test, XzaarExpression ifTrue, XzaarExpression ifFalse, XzaarType type) : base(test, ifTrue, ifFalse) { _type = type; }
internal FullIfElseExpression(XzaarExpression test, XzaarExpression ifTrue, XzaarExpression ifFalse) : base(test, ifTrue) { _false = ifFalse; }
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; }
internal IfElseExpression(XzaarExpression test, XzaarExpression ifTrue) { this.test = test; this.ifTrue = ifTrue; }
public FunctionExpression SetBody(XzaarExpression body) { this.body = body; return(this); }
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)); } }
public static LoopExpression Loop(XzaarExpression body) { return(Loop(body, null)); }
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); }
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(); }
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; }
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; }
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; }
public static UnaryExpression PostDecrementor(XzaarExpression item) { return(UnaryOperation(item, ExpressionType.PostDecrementAssign)); }