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

A designator. More...

#include <AST.hpp>

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

Public Types

using target_type = std::variant< std::monostate, const Expr *, const Attribute * >
 

Public Member Functions

 Designator (Token attr_name)
 
 Designator (Token dot, Token table_name, Token attr_name)
 
 Designator (Token dot, Token table_name, Token attr_name, const Type *type, target_type target)
 
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 Designator is a free variable.
 
bool contains_bound_variables () const override
 Returns false iff this Designator is a free variable.
 
unsigned binding_depth () const
 
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 has_explicit_table_name () const
 
bool is_identifier () const
 Returns true iff this Designator has no table name, neither explicitly nor implicitly (by sema).
 
bool has_table_name () const
 
ThreadSafePooledString get_table_name () const
 
const target_typetarget () 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 table_name
 
Token attr_name
 
Token tok
 the token of the expression; serves as an anchor to locate the expression in the source
 

Private Member Functions

void set_binding_depth (unsigned depth)
 Marks this Designator as free variable, i.e.
 
void decrease_binding_depth ()
 

Private Attributes

target_type target_
 the target that is referenced by this designator
 
unsigned binding_depth_ = 0
 at which level above this designator is bound; 0 for bound variables, ≥ 1 for free
 
ThreadSafePooledOptionalString unique_id_
 a unique ID created for Designators in nested queries (for decorrelation)
 
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.
 

Friends

struct Sema
 

Detailed Description

A designator.

Identifies an attribute, optionally preceeded by a table name, a named expression, or a function.

Definition at line 133 of file AST.hpp.

Member Typedef Documentation

◆ target_type

using m::ast::Designator::target_type = std::variant<std::monostate, const Expr*, const Attribute*>

Definition at line 137 of file AST.hpp.

Constructor & Destructor Documentation

◆ Designator() [1/3]

m::ast::Designator::Designator ( Token  attr_name)
inlineexplicit

Definition at line 146 of file AST.hpp.

◆ Designator() [2/3]

m::ast::Designator::Designator ( Token  dot,
Token  table_name,
Token  attr_name 
)
inline

Definition at line 152 of file AST.hpp.

◆ Designator() [3/3]

m::ast::Designator::Designator ( Token  dot,
Token  table_name,
Token  attr_name,
const Type type,
target_type  target 
)
inline

Definition at line 158 of file AST.hpp.

Member Function Documentation

◆ accept() [1/2]

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

Implements m::ast::Expr.

◆ accept() [2/2]

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

Implements m::ast::Expr.

◆ binding_depth()

unsigned m::ast::Designator::binding_depth ( ) const
inline

Definition at line 183 of file AST.hpp.

◆ can_be_null()

bool m::ast::Designator::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 170 of file AST.hpp.

◆ contains_bound_variables()

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

Returns false iff this Designator is a free variable.

Implements m::ast::Expr.

Definition at line 181 of file AST.hpp.

◆ contains_free_variables()

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

Returns true iff this Designator is a free variable.

Implements m::ast::Expr.

Definition at line 179 of file AST.hpp.

◆ decrease_binding_depth()

void m::ast::Designator::decrease_binding_depth ( )
inlineprivate

Definition at line 208 of file AST.hpp.

References M_insist.

◆ 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().

◆ get_table_name()

ThreadSafePooledString m::ast::Designator::get_table_name ( ) const
inline

Definition at line 197 of file AST.hpp.

References M_insist, and m::ast::Token::text.

Referenced by hash().

◆ has_explicit_table_name()

bool m::ast::Designator::has_explicit_table_name ( ) const
inline

Definition at line 192 of file AST.hpp.

◆ has_table_name()

bool m::ast::Designator::has_table_name ( ) const
inline

Definition at line 196 of file AST.hpp.

References m::ast::Token::text.

Referenced by hash(), and operator==().

◆ 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 Designator::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 40 of file AST.cpp.

References attr_name, get_table_name(), has_table_name(), and m::ast::Token::text.

◆ is_constant()

bool m::ast::Designator::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 165 of file AST.hpp.

◆ is_identifier()

bool m::ast::Designator::is_identifier ( ) const
inline

Returns true iff this Designator has no table name, neither explicitly nor implicitly (by sema).

Definition at line 194 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 Designator::operator== ( const Expr other) const
overridevirtual

Returns true iff other is syntactically equal to this.

Implements m::ast::Expr.

Definition at line 89 of file AST.cpp.

References m::and, attr_name, has_table_name(), table_name, and m::ast::Token::text.

◆ set_binding_depth()

void m::ast::Designator::set_binding_depth ( unsigned  depth)
inlineprivate

Marks this Designator as free variable, i.e.

not being bound by the query.

Definition at line 207 of file AST.hpp.

◆ target()

const target_type & m::ast::Designator::target ( ) const
inline

Definition at line 203 of file AST.hpp.

◆ 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().

Friends And Related Function Documentation

◆ Sema

friend struct Sema
friend

Definition at line 135 of file AST.hpp.

Field Documentation

◆ attr_name

Token m::ast::Designator::attr_name

Definition at line 139 of file AST.hpp.

Referenced by hash(), m::wasm::ExprCompiler::operator()(), and operator==().

◆ binding_depth_

unsigned m::ast::Designator::binding_depth_ = 0
private

at which level above this designator is bound; 0 for bound variables, ≥ 1 for free

Definition at line 142 of file AST.hpp.

◆ 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.

◆ table_name

Token m::ast::Designator::table_name

Definition at line 138 of file AST.hpp.

Referenced by m::wasm::ExprCompiler::operator()(), and operator==().

◆ target_

target_type m::ast::Designator::target_
private

the target that is referenced by this designator

Definition at line 141 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(), m::ast::Constant::hash(), m::Interpreter::M_OPERATOR_LIST(), and m::ast::Constant::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.

◆ unique_id_

ThreadSafePooledOptionalString m::ast::Designator::unique_id_
private

a unique ID created for Designators in nested queries (for decorrelation)

Definition at line 143 of file AST.hpp.


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