mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
Public Member Functions | Data Fields | Private Attributes
m::ast::Constant Struct Reference

A constant: a string literal or a numeric constant. More...

#include <AST.hpp>

Inheritance diagram for m::ast::Constant:
[legend]
Collaboration diagram for m::ast::Constant:
[legend]

Public Member Functions

 Constant (Token tok)
 
bool is_constant () const override
 Returns true iff this Expr is constant, i.e.
 
bool can_be_null () const override
 Returns true iff this Expr is nullable, i.e.
 
bool contains_free_variables () const override
 Returns true iff this Expr contains a free variable.
 
bool contains_bound_variables () const override
 Returns true iff this Expr contains a bound variable.
 
uint64_t hash () const override
 Computes a hash of this, considering only syntactic properties.
 
bool operator== (const Expr &other) const override
 Returns true iff other is syntactically equal to this.
 
void accept (ASTExprVisitor &v) override
 
void accept (ConstASTExprVisitor &v) const override
 
bool is_null () const
 
bool is_bool () const
 
bool is_number () const
 
bool is_integer () const
 
bool is_float () const
 
bool is_string () const
 
bool is_date () const
 
bool is_datetime () const
 
const Typetype () const
 Returns the Type of this Expr.
 
void type (const Type *type)
 Sets the Type of this Expr.
 
bool has_type () const
 Returns true iff this Expr has been assigned a Type, most likely by Sema.
 
bool operator!= (const Expr &other) const
 Returns false iff other is syntactically equal to this.
 
Schema get_required () const
 Returns a Schema instance containing all required definitions.
 
void dot (std::ostream &out) const
 Writes a Graphivz dot representation of this Expr to out.
 
M_LCOV_EXCL_STOP void dump (std::ostream &out) const
 
void dump () const
 

Data Fields

Token tok
 the token of the expression; serves as an anchor to locate the expression in the source
 

Private Attributes

const Typetype_ = nullptr
 

‍the type of an expression, determined by the semantic analysis


 
bool is_correlated_ = false
 Whether this Expr is correlated within its query, i.e.
 

Detailed Description

A constant: a string literal or a numeric constant.

Definition at line 212 of file AST.hpp.

Constructor & Destructor Documentation

◆ Constant()

m::ast::Constant::Constant ( Token  tok)
inline

Definition at line 214 of file AST.hpp.

Member Function Documentation

◆ accept() [1/2]

void m::ast::Constant::accept ( ASTExprVisitor v)
overridevirtual

Implements m::ast::Expr.

◆ accept() [2/2]

void m::ast::Constant::accept ( ConstASTExprVisitor v) const
overridevirtual

Implements m::ast::Expr.

◆ can_be_null()

bool m::ast::Constant::can_be_null ( ) const
inlineoverridevirtual

Returns true iff this Expr is nullable, i.e.

may evaluate to NULL at runtime.

Implements m::ast::Expr.

Definition at line 217 of file AST.hpp.

◆ contains_bound_variables()

bool m::ast::Constant::contains_bound_variables ( ) const
inlineoverridevirtual

Returns true iff this Expr contains a bound variable.

A bound variable is a Designator that is bound to an Attribute or another Expr within the query.

Implements m::ast::Expr.

Definition at line 219 of file AST.hpp.

◆ contains_free_variables()

bool m::ast::Constant::contains_free_variables ( ) const
inlineoverridevirtual

Returns true iff this Expr contains a free variable.

A free variable is a Designator that is not bound to an Attribute or another Expr within the query but defined by an outer, enclosing statement.

Implements m::ast::Expr.

Definition at line 218 of file AST.hpp.

◆ dot()

void Expr::dot ( std::ostream &  out) const
inherited

Writes a Graphivz dot representation of this Expr to out.

Used to render ASTs with Graphivz.

Definition at line 205 of file AST.cpp.

References m::ast::Expr::dot().

Referenced by m::ast::Expr::dot().

◆ dump() [1/2]

void Expr::dump ( ) const
inherited

Definition at line 235 of file AST.cpp.

References m::ast::Expr::dump().

Referenced by m::ast::Expr::dump().

◆ dump() [2/2]

M_LCOV_EXCL_START void Expr::dump ( std::ostream &  out) const
inherited

Definition at line 229 of file AST.cpp.

◆ get_required()

Schema Expr::get_required ( ) const
inherited

Returns a Schema instance containing all required definitions.

Recursively traverses the Expr to find all Designators. Note, that FnApplicationExprs require special handling: a FnApplicationExpr that is an aggregation is stringified to a Schema::Identifier and not processed further recursively. The reason for this special treatment is that aggregations are performed during grouping and the aggregate value is referenced by the stringified expression (or alias, if given).

Definition at line 145 of file AST.cpp.

References m::Schema::add(), m::Catalog::Get(), m::Schema::has(), id, m::Catalog::pool(), and m::visit().

◆ has_type()

bool m::ast::Expr::has_type ( ) const
inlineinherited

Returns true iff this Expr has been assigned a Type, most likely by Sema.

Definition at line 63 of file AST.hpp.

◆ hash()

uint64_t Constant::hash ( ) const
overridevirtual

Computes a hash of this, considering only syntactic properties.

Other properties are ignored, e.g. type or designator target.

Implements m::ast::Expr.

Definition at line 50 of file AST.cpp.

References m::ast::Token::text, and m::ast::Expr::tok.

◆ is_bool()

bool m::ast::Constant::is_bool ( ) const
inline

Definition at line 229 of file AST.hpp.

◆ is_constant()

bool m::ast::Constant::is_constant ( ) const
inlineoverridevirtual

Returns true iff this Expr is constant, i.e.

consists only of constants and can be evaluated at compilation time.

Implements m::ast::Expr.

Definition at line 216 of file AST.hpp.

◆ is_date()

bool m::ast::Constant::is_date ( ) const
inline

Definition at line 234 of file AST.hpp.

◆ is_datetime()

bool m::ast::Constant::is_datetime ( ) const
inline

Definition at line 235 of file AST.hpp.

◆ is_float()

bool m::ast::Constant::is_float ( ) const
inline

Definition at line 232 of file AST.hpp.

◆ is_integer()

bool m::ast::Constant::is_integer ( ) const
inline

Definition at line 231 of file AST.hpp.

◆ is_null()

bool m::ast::Constant::is_null ( ) const
inline

Definition at line 228 of file AST.hpp.

◆ is_number()

bool m::ast::Constant::is_number ( ) const
inline

Definition at line 230 of file AST.hpp.

◆ is_string()

bool m::ast::Constant::is_string ( ) const
inline

Definition at line 233 of file AST.hpp.

◆ operator!=()

bool m::ast::Expr::operator!= ( const Expr other) const
inlineinherited

Returns false iff other is syntactically equal to this.

Definition at line 85 of file AST.hpp.

◆ operator==()

bool Constant::operator== ( const Expr other) const
overridevirtual

Returns true iff other is syntactically equal to this.

Implements m::ast::Expr.

Definition at line 98 of file AST.cpp.

References m::ast::Token::text, and m::ast::Expr::tok.

◆ type() [1/2]

const Type * m::ast::Expr::type ( ) const
inlineinherited

Returns the Type of this Expr.

Assumes that the Expr has been assigned a Type by the Sema.

Definition at line 58 of file AST.hpp.

References M_notnull.

Referenced by m::ast::Sema::create_designator(), m::ast::UnaryExpr::hash(), m::ast::BinaryExpr::hash(), index_scan_codegen_compilation(), m::wasm::ExprCompiler::operator()(), and WeighExpr::operator()().

◆ type() [2/2]

void m::ast::Expr::type ( const Type type)
inlineinherited

Sets the Type of this Expr.

Should be used when constructing an Expr outside of the Sema. Should not be called to replace an already assigned type.

Definition at line 61 of file AST.hpp.

References M_insist, and m::ast::Expr::type().

Referenced by m::ast::Expr::type().

Field Documentation

◆ is_correlated_

bool m::ast::Expr::is_correlated_ = false
privateinherited

Whether this Expr is correlated within its query, i.e.

whether this Expr contains free variables that are bound by an outside query.

Definition at line 50 of file AST.hpp.

◆ tok

Token m::ast::Expr::tok
inherited

the token of the expression; serves as an anchor to locate the expression in the source

Definition at line 43 of file AST.hpp.

Referenced by m::ast::Sema::create_designator(), hash(), m::Interpreter::M_OPERATOR_LIST(), and operator==().

◆ type_

const Type* m::ast::Expr::type_ = nullptr
privateinherited

‍the type of an expression, determined by the semantic analysis

Definition at line 47 of file AST.hpp.


The documentation for this struct was generated from the following files: