Beispiel #1
0
        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
            });
        }
Beispiel #2
0
 internal static Expr Bound(Expr expr, TypeExpr type)
 {
     return(new AsTypeExpr(expr, type, null)
     {
         Symbol = type.Symbol, Datatype = type.Symbol as TypeSymbol
     });
 }
Beispiel #3
0
        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
            });
        }
Beispiel #4
0
 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;
 }
Beispiel #10
0
 internal SizeOfExpr(TypeExpr e, Token t) : base(t)
 {
     Type = e;
 }
Beispiel #11
0
 internal QualifiedNameExpr(TypeExpr e, NameExpr n) : base(n.Token, n.Name, n.Arity)
 {
     Expr = e; Member = n;
 }
Beispiel #12
0
 internal SwitchBlockType(Token t, Token n, TypeExpr type, Expr when, Stmt s) : base(t, s)
 {
     Name = n;  Type = type; When = when;
 }
Beispiel #13
0
 internal CtorCallExpr(TypeExpr e, ArgList a) : base(e, a)
 {
 }
Beispiel #14
0
 internal CatchBlock(Token t, Token name, TypeExpr type, Expr when, Stmt s) : base(t)
 {
     Name = name; Type = type; When = when; Stmt = s;
 }
Beispiel #15
0
 internal VarDecl(Token t, TypeExpr a) : this(t, t.Value, null, a, null)
 {
 }
Beispiel #16
0
 internal VarDecl(Token t, Expr[] asub, TypeExpr a, Expr i) : this(t, t.Value, asub, a, i)
 {
 }
Beispiel #17
0
 internal VarDecl(Token t, string n, Expr[] asub, TypeExpr a, Expr i) : base(t)
 {
     Name = n; ArraySub = asub; Type = a; Initializer = i;
 }
Beispiel #18
0
 internal LiteralArray(ExprList values, TypeExpr elemType = null) : base(null)
 {
     ElemType = elemType;  Values = values;
 }
Beispiel #19
0
 internal MemVarDecl(Token t, Expr[] asub, TypeExpr a, Expr i) : base(t, asub, a, i)
 {
 }