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