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

An expression. More...

#include <AST.hpp>

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

Public Member Functions

 Expr (Token tok)
 
 Expr (Token tok, const Type *type)
 
virtual ~Expr ()
 
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.
 
virtual bool is_constant () const =0
 Returns true iff this Expr is constant, i.e.
 
virtual bool can_be_null () const =0
 Returns true iff this Expr is nullable, i.e.
 
virtual bool contains_free_variables () const =0
 Returns true iff this Expr contains a free variable.
 
virtual bool contains_bound_variables () const =0
 Returns true iff this Expr contains a bound variable.
 
virtual uint64_t hash () const =0
 Computes a hash of this, considering only syntactic properties.
 
virtual bool operator== (const Expr &other) const =0
 Returns true iff other is syntactically equal to this.
 
bool operator!= (const Expr &other) const
 Returns false iff other is syntactically equal to this.
 
virtual void accept (ASTExprVisitor &v)=0
 
virtual void accept (ConstASTExprVisitor &v) const =0
 
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.
 

Friends

struct Sema
 
struct GetCorrelationInfo
 
std::ostream &M_EXPORT operator<< (std::ostream &out, const Expr &e)
 
M_LCOV_EXCL_START friend std::string to_string (const Expr &e)
 

Detailed Description

An expression.

Definition at line 38 of file AST.hpp.

Constructor & Destructor Documentation

◆ Expr() [1/2]

m::ast::Expr::Expr ( Token  tok)
inlineexplicit

Definition at line 53 of file AST.hpp.

◆ Expr() [2/2]

m::ast::Expr::Expr ( Token  tok,
const Type type 
)
inline

Definition at line 54 of file AST.hpp.

◆ ~Expr()

virtual m::ast::Expr::~Expr ( )
inlinevirtual

Definition at line 55 of file AST.hpp.

Member Function Documentation

◆ accept() [1/2]

virtual void m::ast::Expr::accept ( ASTExprVisitor v)
pure virtual

◆ accept() [2/2]

virtual void m::ast::Expr::accept ( ConstASTExprVisitor v) const
pure virtual

◆ can_be_null()

virtual bool m::ast::Expr::can_be_null ( ) const
pure virtual

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

may evaluate to NULL at runtime.

Implemented in m::ast::ErrorExpr, m::ast::Designator, m::ast::Constant, m::ast::FnApplicationExpr, m::ast::UnaryExpr, m::ast::BinaryExpr, and m::ast::QueryExpr.

◆ contains_bound_variables()

virtual bool m::ast::Expr::contains_bound_variables ( ) const
pure virtual

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.

Implemented in m::ast::ErrorExpr, m::ast::Designator, m::ast::Constant, m::ast::FnApplicationExpr, m::ast::UnaryExpr, m::ast::BinaryExpr, and m::ast::QueryExpr.

◆ contains_free_variables()

virtual bool m::ast::Expr::contains_free_variables ( ) const
pure virtual

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.

Implemented in m::ast::ErrorExpr, m::ast::Designator, m::ast::Constant, m::ast::FnApplicationExpr, m::ast::UnaryExpr, m::ast::BinaryExpr, and m::ast::QueryExpr.

◆ dot()

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

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

Referenced by dot().

◆ dump() [1/2]

void Expr::dump ( ) const

Definition at line 235 of file AST.cpp.

References dump().

Referenced by dump().

◆ dump() [2/2]

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

Definition at line 229 of file AST.cpp.

◆ get_required()

Schema Expr::get_required ( ) const

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
inline

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

Definition at line 63 of file AST.hpp.

◆ hash()

virtual uint64_t m::ast::Expr::hash ( ) const
pure virtual

Computes a hash of this, considering only syntactic properties.

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

Implemented in m::ast::ErrorExpr, m::ast::Designator, m::ast::Constant, m::ast::FnApplicationExpr, m::ast::UnaryExpr, m::ast::BinaryExpr, and m::ast::QueryExpr.

Referenced by std::hash< m::ast::Expr >::operator()(), and std::hash< m::cnf::Predicate >::operator()().

◆ is_constant()

virtual bool m::ast::Expr::is_constant ( ) const
pure virtual

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

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

Implemented in m::ast::ErrorExpr, m::ast::Designator, m::ast::Constant, m::ast::FnApplicationExpr, m::ast::UnaryExpr, m::ast::BinaryExpr, and m::ast::QueryExpr.

◆ operator!=()

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

Returns false iff other is syntactically equal to this.

Definition at line 85 of file AST.hpp.

◆ operator==()

virtual bool m::ast::Expr::operator== ( const Expr other) const
pure virtual

Returns true iff other is syntactically equal to this.

Implemented in m::ast::ErrorExpr, m::ast::Designator, m::ast::Constant, m::ast::FnApplicationExpr, m::ast::UnaryExpr, m::ast::BinaryExpr, and m::ast::QueryExpr.

◆ type() [1/2]

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

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)
inline

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

Referenced by type().

Friends And Related Function Documentation

◆ GetCorrelationInfo

friend struct GetCorrelationInfo
friend

Definition at line 41 of file AST.hpp.

◆ operator<<

std::ostream &M_EXPORT operator<< ( std::ostream &  out,
const Expr e 
)
friend

◆ Sema

friend struct Sema
friend

Definition at line 40 of file AST.hpp.

◆ to_string

M_LCOV_EXCL_START friend std::string to_string ( const Expr e)
friend

Definition at line 103 of file AST.hpp.

Field Documentation

◆ is_correlated_

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

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

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
private

‍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: