internal static IsVarExpr Bound(Expr expr, TypeExpr type, LocalSymbol var) { bool?check = null; if (expr.Datatype.IsValueType) { if (Binder.TypesMatch(expr.Datatype, type.Symbol as TypeSymbol)) { check = true; } else if (Binder.TypesMatch(type.Symbol as TypeSymbol, Compilation.Get(WellKnownTypes.System_ValueType))) { check = true; } else if (Binder.TypesMatch(type.Symbol as TypeSymbol, Compilation.Get(NativeType.Object))) { check = true; } else { check = false; } } return(new IsVarExpr(expr, type, null, null) { Symbol = type.Symbol, Datatype = Compilation.Get(NativeType.Boolean), Var = var, Check = check }); }
internal static Expr Bound(Expr expr, TypeExpr type) { return(new AsTypeExpr(expr, type, null) { Symbol = type.Symbol, Datatype = type.Symbol as TypeSymbol }); }
internal static CtorCallExpr Bound(Binder b, TypeExpr type, ArgList args) { Expr writeBack; var sym = b.BindCtorCall(type, type.Symbol, args, out writeBack); return(new CtorCallExpr(type, args) { Symbol = sym, Datatype = sym.Type(), WriteBack = writeBack }); }
internal static Expr Bound(Expr expr, TypeExpr type) { if (expr.Datatype.IsValueType) { if (Binder.TypesMatch(expr.Datatype, type.Symbol as TypeSymbol)) { return(LiteralExpr.Bound(Constant.Create(true))); } else if (Binder.TypesMatch(type.Symbol as TypeSymbol, Compilation.Get(WellKnownTypes.System_ValueType))) { return(LiteralExpr.Bound(Constant.Create(true))); } else if (Binder.TypesMatch(type.Symbol as TypeSymbol, Compilation.Get(NativeType.Object))) { return(LiteralExpr.Bound(Constant.Create(true))); } return(LiteralExpr.Bound(Constant.Create(false))); } return(new IsExpr(expr, type, null) { Symbol = type.Symbol, Datatype = Compilation.Get(NativeType.Boolean) }); }
internal AsTypeExpr(Expr e, TypeExpr t, Token o) : base(o) { Expr = e; Type = t; }
internal IsVarExpr(Expr e, TypeExpr t, Token o, Token name) : base(e, t, o) { Name = name; }
internal TypeConversion(TypeExpr t, Expr e) : base(t, e) { }
internal TypeCast(TypeExpr t, Expr e) : base(t?.Token ?? e.Token) { Type = t; Expr = e; }
internal DefaultExpr(TypeExpr e, Token t) : base(t) { Type = e; }
internal SizeOfExpr(TypeExpr e, Token t) : base(t) { Type = e; }
internal QualifiedNameExpr(TypeExpr e, NameExpr n) : base(n.Token, n.Name, n.Arity) { Expr = e; Member = n; }
internal SwitchBlockType(Token t, Token n, TypeExpr type, Expr when, Stmt s) : base(t, s) { Name = n; Type = type; When = when; }
internal CtorCallExpr(TypeExpr e, ArgList a) : base(e, a) { }
internal CatchBlock(Token t, Token name, TypeExpr type, Expr when, Stmt s) : base(t) { Name = name; Type = type; When = when; Stmt = s; }
internal VarDecl(Token t, TypeExpr a) : this(t, t.Value, null, a, null) { }
internal VarDecl(Token t, Expr[] asub, TypeExpr a, Expr i) : this(t, t.Value, asub, a, i) { }
internal VarDecl(Token t, string n, Expr[] asub, TypeExpr a, Expr i) : base(t) { Name = n; ArraySub = asub; Type = a; Initializer = i; }
internal LiteralArray(ExprList values, TypeExpr elemType = null) : base(null) { ElemType = elemType; Values = values; }
internal MemVarDecl(Token t, Expr[] asub, TypeExpr a, Expr i) : base(t, asub, a, i) { }