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