Exemplo n.º 1
0
 public InListExpr(Expr expr, List <Expr> inlist, bool hasNot)
 {
     hasNot_ = hasNot;
     children_.Add(expr); children_.AddRange(inlist);
     type_ = new BoolType();
     Debug.Assert(Clone().Equals(this));
 }
Exemplo n.º 2
0
        public override void Bind(BindContext context)
        {
            base.Bind(context);

            // derive return type
            Debug.Assert(lchild_().type_ != null && rchild_().type_ != null);
            switch (op_)
            {
            case "+":
            case "-":
            case "*":
            case "/":
            case "||":
                // notice that CoerseType() may change l/r underneath
                type_ = ColumnType.CoerseType(op_, lchild_(), rchild_());
                break;

            case ">":
            case ">=":
            case "<":
            case "<=":
                if (TypeBase.IsNumberType(lchild_().type_))
                {
                    ColumnType.CoerseType(op_, lchild_(), rchild_());
                }
                else if (TypeBase.OnlyOneIsStringType(lchild_().type_, rchild_().type_))
                {
                    throw new SemanticAnalyzeException("no implicit conversion of character type values");
                }
                type_ = new BoolType();
                break;

            case "=":
            case "<>":
            case "!=":
                if (TypeBase.IsNumberType(lchild_().type_))
                {
                    ColumnType.CoerseType(op_, lchild_(), rchild_());
                }
                else if (TypeBase.OnlyOneIsStringType(lchild_().type_, rchild_().type_))
                {
                    throw new SemanticAnalyzeException("no implicit conversion of character type values");
                }
                type_ = new BoolType();
                break;

            case " and ":
            case " or ":
            case "like":
            case "not like":
            case "in":
            case "is":
            case "is not":
                type_ = new BoolType();
                break;

            default:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 3
0
 public override void Bind(BindContext context)
 {
     base.Bind(context);
     expr_().Bind(context);
     if (query_.selection_.Count != 1)
     {
         throw new SemanticAnalyzeException("subquery must return only one column");
     }
     type_ = new BoolType();
     markBounded();
 }
Exemplo n.º 4
0
        public override void Bind(BindContext context)
        {
            base.Bind(context);

            // derive return type
            Debug.Assert(l_().type_ != null && r_().type_ != null);
            switch (op_)
            {
            case "+":
            case "-":
            case "*":
            case "/":
            case "||":
                // notice that CoerseType() may change l/r underneath
                type_ = ColumnType.CoerseType(op_, l_(), r_());
                break;

            case ">":
            case ">=":
            case "<":
            case "<=":
            case "=":
            case "<>":
            case "!=":
            case " and ":
            case " or ":
            case "like":
            case "not like":
            case "in":
            case "is":
            case "is not":
                type_ = new BoolType();
                break;

            default:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 5
0
        protected void bindQuery(BindContext context)
        {
            // subquery id is global, so accumulating at top
            subqueryid_ = ++context.TopContext().globalSubqCounter_;

            // query will use a new query context inside
            var mycontext = query_.Bind(context);

            Debug.Assert(query_.parent_ == mycontext.parent_?.stmt_);

            // verify column count after bound because SelStar expansion
            if (!(this is ScalarSubqueryExpr))
            {
                type_ = new BoolType();
            }
            else
            {
                if (query_.selection_.Count != 1)
                {
                    throw new SemanticAnalyzeException("subquery must return only one column");
                }
                type_ = query_.selection_[0].type_;
            }
        }
Exemplo n.º 6
0
 public override void Bind(BindContext context)
 {
     base.Bind(context);
     type_ = new BoolType();
     markBounded();
 }
Exemplo n.º 7
0
 public LogicAndOrExpr(Expr l, Expr r, string op) : base(l, r, op)
 {
     Debug.Assert(op.Equals(" and ") || op.Equals(" or "));
     type_ = new BoolType(); Debug.Assert(Clone().Equals(this));
     Debug.Assert(this.IsBoolean());
 }