21template<
bool IsGlobal>
struct Buffer;
22template<
bool IsGlobal>
struct buffer_load_proxy_t;
23template<
bool IsGlobal>
struct buffer_store_proxy_t;
24template<
bool IsGlobal>
struct buffer_swap_proxy_t;
91template<
signed_
integral Base>
128 template<
signed_
integral To>
141 {
M_unreachable(
"modulo division on decimals is not defined"); }
149 if (this->scale_ == other.
scale_)
166 if (this->scale_ == other.
scale_)
183 uint32_t smaller_scale = this->
scale();
184 uint32_t higher_scale = other.
scale();
185 if (smaller_scale > higher_scale)
186 std::swap(smaller_scale, higher_scale);
187 M_insist(smaller_scale <= higher_scale);
189 return Decimal((this->
val() * other.
val()) / scaling_factor, higher_scale);
197 const uint32_t scale_res = std::max(this->
scale(), other.
scale());
199 return Decimal((this->
val() * scaling_factor) / other.
val(), scale_res);
248 return out <<
"Decimal: " <<
static_cast<const expr_type&
>(d) <<
", scale = " << d.
scale_;
251 void dump(std::ostream &out)
const { out << *
this << std::endl; }
259template<
typename Base>
266template<
typename Base>
273template<
typename Base>
280template<
typename Base>
302#define SQL_TYPES_SCALAR(X) \
312#define SQL_ADDR_TYPES_SCALAR(X) \
322#define SQL_TYPES(X) \
323 SQL_TYPES_SCALAR(X) \
350#define SQL_ADDR_TYPES(X) \
351 SQL_ADDR_TYPES_SCALAR(X) \
378#define ADD_EXPR_SQL_TYPE(TYPE) template<> struct is_sql_type<TYPE>{};
380#undef ADD_EXPR_SQL_TYPE
382#define ADD_EXPR_SQL_ADDR_TYPE(TYPE) template<> struct is_sql_addr_type<TYPE>{};
384#undef ADD_EXPR_SQL_ADDR_TYPE
394#define ADD_TYPE(TYPE) , TYPE
401#define ADD_TYPE(TYPE) , TYPE
409using SQL_boolean_t = std::variant<std::monostate, _Boolx1, _Boolx16, _Boolx32>;
419 []<sql_type
T>(
T actual) ->
void { actual.discard(); },
420 [](std::monostate) ->
void {
M_unreachable(
"invalid variant"); },
428 [](std::monostate) ->
void {
M_unreachable(
"invalid variant"); },
435 using type =
typename To::type;
439 [](
auto actual) ->
To requires requires { actual.template to<type, num_simd_lanes>(); } {
440 return actual.template to<type, num_simd_lanes>();
442 [](
NChar actual) ->
NChar requires std::same_as<To, NChar> {
445 [](
auto actual) ->
To requires (not
requires { actual.template to<type, num_simd_lanes>(); }) {
455 []<sql_type
T>(
const T &actual) ->
bool {
return actual.can_be_null(); },
456 [](std::monostate) ->
bool {
M_unreachable(
"invalid variant"); },
460template<std::
size_t L = 1>
464 []<sql_type
T>(
T actual) -> Bool<L>
requires requires { { actual.is_null() } -> std::same_as<Bool<L>>; } {
465 return actual.is_null();
467 []<sql_type
T>(
T actual) -> Bool<L>
requires (not
requires { { actual.is_null() } -> std::same_as<Bool<L>>; }) {
468 M_unreachable(
"invalid type for given number of SIMD lanes");
470 [](std::monostate) -> Bool<L> {
M_unreachable(
"invalid variant"); },
474template<std::
size_t L = 1>
478 []<sql_type
T>(
T actual) -> Bool<L>
requires requires { { actual.not_null() } -> std::same_as<Bool<L>>; } {
479 return actual.not_null();
481 []<sql_type
T>(
T actual) -> Bool<L>
requires (not
requires { { actual.not_null() } -> std::same_as<Bool<L>>; }) {
482 M_unreachable(
"invalid type for given number of SIMD lanes");
484 [](std::monostate) -> Bool<L> {
M_unreachable(
"invalid variant"); },
522 template<sql_
boolean_type T>
525 M_insist(std::holds_alternative<T>(result));
526 return *std::get_if<T>(&result);
530 using ConstASTExprVisitor::operator();
566 std::unordered_map<Schema::Identifier, SQL_t>
exprs_;
593 auto it =
exprs_.find(
id);
595 return std::holds_alternative<T>(it->second);
598 template<sql_addr_type T>
602 return std::holds_alternative<T>(it->second);
620 auto res =
exprs_.emplace(std::move(
id), std::forward<T>(
expr));
630 template<sql_addr_type T>
643 for (
auto &p : other.
exprs_) {
645 [](std::monostate) ->
void {
M_unreachable(
"invalid expression"); },
646 [
this, &p](
auto &e) ->
void { this->
add(p.first, e.clone()); },
651 [](std::monostate) ->
void {
M_unreachable(
"invalid expression"); },
652 [
this, &p](
auto &e) ->
void { this->
add_addr(p.first, e.clone()); },
658 this->exprs_.merge(other.exprs_);
659 M_insist(other.exprs_.empty(),
"duplicate ID not moved from other to this");
660 this->expr_addrs_.merge(other.expr_addrs_);
661 M_insist(other.expr_addrs_.empty(),
"duplicate ID not moved from other to this");
666 auto it =
exprs_.find(
id);
668 auto nh =
exprs_.extract(it);
669 return std::move(nh.mapped());
674 auto it =
exprs_.find(
id);
676 auto nh =
exprs_.extract(it);
677 M_insist(std::holds_alternative<T>(nh.mapped()));
678 return *std::get_if<T>(&nh.mapped());
686 return std::move(nh.mapped());
689 template<sql_addr_type T>
694 M_insist(std::holds_alternative<T>(nh.mapped()));
695 return *std::get_if<T>(&nh.mapped());
700 auto it =
exprs_.find(
id);
703 [](
auto &e) ->
SQL_t {
return e.clone(); },
710 auto it =
exprs_.find(
id);
712 M_insist(std::holds_alternative<T>(it->second));
713 return std::get_if<T>(&it->second)->clone();
721 [](
auto &e) ->
SQL_addr_t {
return e.clone(); },
726 template<sql_addr_type T>
730 M_insist(std::holds_alternative<T>(it->second));
731 return std::get_if<T>(&it->second)->clone();
744 return C.
compile(std::forward<T>(t));
747 template<
typename T,
typename U>
751 return C.
compile<
T>(std::forward<U>(u));
761 [](std::monostate) ->
void {
M_unreachable(
"invalid predicate"); },
762 [
this]<
sql_boolean_type T>(
T &&e) ->
void { this->add_predicate<T>(std::forward<T>(e)); },
763 }, std::forward<SQL_boolean_t>(pred));
766 template<sql_
boolean_type T>
769 auto old = extract_predicate<T>();
786 template<sql_
boolean_type T>
800 M_unreachable(
"cannot access an undefined or already extracted predicate");
806 template<sql_
boolean_type T>
813 void dump(std::ostream &out)
const;
858 std::unordered_map<const char*, std::pair<uint32_t, NChar>>
literals_;
869#ifdef M_ENABLE_SANITY_FIELDS
873 p.second.second.discard();
919 std::piecewise_construct,
920 std::forward_as_tuple(literal),
921 std::forward_as_tuple(ptr,
NChar(
Ptr<Charx1>(U32x1(ptr)),
false, strlen(literal) + 1,
true))
929 return it->second.first;
935 return it->second.second.clone();
985template<VariableKind Kind>
986std::tuple<Block, Block, Block>
1003template<VariableKind Kind>
1004std::tuple<Block, Block, Block>
1020template<VariableKind Kind>
1021std::tuple<Block, Block, Block>
1050template<
bool IsGlobal>
1059 friend struct Buffer<true>;
1068template<
bool IsGlobal>
1073 using param_t = std::optional<std::reference_wrapper<const Schema>>;
1111 if constexpr (IsGlobal) {
1120 if constexpr (IsGlobal) {
1205template<
bool IsGlobal>
1208 friend struct Buffer<IsGlobal>;
1211 std::reference_wrapper<const Buffer<IsGlobal>>
buffer_;
1236 buffer_.get().schema(), tuple_id);
1241template<
bool IsGlobal>
1244 friend struct Buffer<IsGlobal>;
1247 std::reference_wrapper<const Buffer<IsGlobal>>
buffer_;
1266 static Schema empty_schema;
1269 buffer_.get().schema(), tuple_id);
1274template<
bool IsGlobal>
1277 friend struct Buffer<IsGlobal>;
1280 std::reference_wrapper<const Buffer<IsGlobal>>
buffer_;
1315template<
typename T, std::
size_t L>
1319 *bytes ^= (-
value.template to<typename T::type>() xor *bytes.clone()) bitand
T(1 <<
n);
1322template<
typename T, std::
size_t L>
1326 *bytes ^= (-
value.template to<typename T::type>() xor *bytes.clone()) bitand
mask;
1341_I32x1
strncmp(NChar left, NChar right, U32x1 len,
bool reverse =
false);
1343_I32x1
strcmp(NChar left, NChar right,
bool reverse =
false);
1345_Boolx1
strncmp(NChar left, NChar right, U32x1 len,
cmp_op op,
bool reverse =
false);
1347_Boolx1
strcmp(NChar left, NChar right,
cmp_op op,
bool reverse =
false);
1367_Boolx1
like(NChar str, NChar pattern,
const char escape_char =
'\\');
1391 using type =
typename T::type;
1392 return (
value.clone() > type(0)).template to<type>() - (
value < type(0)).
template to<type>();
1402template<
bool Predicated>
1403I32x1
compare(
const Environment &env_left,
const Environment &env_right,
1404 const std::vector<SortingOperator::order_type> &order);
#define ADD_EXPR_SQL_ADDR_TYPE(TYPE)
#define SQL_ADDR_TYPES(X)
#define ADD_EXPR_SQL_TYPE(TYPE)
Global< U32x1 > size_
global backup for current size of buffer, default initialized to 0
std::optional< Global< U32x1 > > capacity_
global backup for dynamic capacity of infinite buffer, default initialized to 0
Global< Ptr< void > > base_address_
global backup for base address of buffer
#define M_unreachable(MSG)
_I32x1 strcmp(NChar left, NChar right, bool reverse=false)
Compares two strings left and right.
typename expr< T >::type expr_t
Convenience alias for expr.
_Boolx1 like_prefix(NChar str, const ThreadSafePooledString &pattern)
Checks whether the string str has the prefix pattern.
_Boolx1 like_contains(NChar str, const ThreadSafePooledString &pattern)
Checks whether the string str contains the pattern pattern.
_I32x1 strncmp(NChar left, NChar right, U32x1 len, bool reverse=false)
Compares two strings left and right.
std::variant< std::monostate #define ADD_TYPE(TYPE) SQL_TYPES(ADD_TYPE) > SQL_t
Ptr< Charx1 > strncpy(Ptr< Charx1 > dst, Ptr< Charx1 > src, U32x1 count)
Copies the contents of src to dst, but no more than count characters.
template I32x1 compare< true >(const Environment &, const Environment &, const std::vector< SortingOperator::order_type > &)
bool can_be_null(const SQL_t &variant)
Bool< L > not_null(SQL_t &variant)
T signum(T value)
Returns the signum of value, i.e.
typename detail::var_helper< T >::type Var
Local variable.
and arithmetically_combinable< T, U, L > auto operator/(PrimitiveExpr< U, L > other) -> PrimitiveExpr< common_type_t< T, U >, L >
Divides this by other.
std::tuple< Block, Block, Block > compile_store_sequential(const Schema &tuple_value_schema, const Schema &tuple_addr_schema, Ptr< void > base_address, const storage::DataLayout &layout, std::size_t num_simd_lanes, const Schema &layout_schema, Variable< uint32_t, Kind, false > &tuple_id)
Compiles the data layout layout containing tuples of schema layout_schema such that it sequentially s...
std::variant< std::monostate #define ADD_TYPE(TYPE) SQL_ADDR_TYPES(ADD_TYPE) > SQL_addr_t
std::tuple< Block, Block, Block > compile_store_sequential_single_pass(const Schema &tuple_value_schema, const Schema &tuple_addr_schema, Ptr< void > base_address, const storage::DataLayout &layout, std::size_t num_simd_lanes, const Schema &layout_schema, Variable< uint32_t, Kind, false > &tuple_id)
Compiles the data layout layout containing tuples of schema layout_schema such that it sequentially s...
void compile_load_point_access(const Schema &tuple_value_schema, const Schema &tuple_addr_schema, Ptr< void > base_address, const storage::DataLayout &layout, const Schema &layout_schema, U32x1 tuple_id)
Compiles the data layout layout starting at memory address base_address and containing tuples of sche...
template I32x1 compare< false >(const Environment &, const Environment &, const std::vector< SortingOperator::order_type > &)
and
Constructs a new PrimitiveExpr from a constant value.
PrimitiveExpr< U, M > convert()
void compile_store_point_access(const Schema &tuple_value_schema, const Schema &tuple_addr_schema, Ptr< void > base_address, const storage::DataLayout &layout, const Schema &layout_schema, U32x1 tuple_id)
Compiles the data layout layout starting at memory address base_address and containing tuples of sche...
typename detail::global_helper< T >::type Global
Global variable.
Bool< L > is_null(SQL_t &variant)
PrimitiveExpr operator-() and(L
_Boolx1 like(NChar str, NChar pattern, const char escape_char='\\')
Checks whether the string str matches the pattern pattern regarding SQL LIKE semantics using escape c...
std::tuple< Block, Block, Block > compile_load_sequential(const Schema &tuple_value_schema, const Schema &tuple_addr_schema, Ptr< void > base_address, const storage::DataLayout &layout, std::size_t num_simd_lanes, const Schema &layout_schema, Variable< uint32_t, Kind, false > &tuple_id)
Compiles the data layout layout containing tuples of schema layout_schema such that it sequentially l...
auto operator*(PrimitiveExpr< U, L > other) -> PrimitiveExpr< common_type_t< T, U >, L >
Multiplies this and other.
void discard()
Discards this.
PrimitiveExpr< uint64_t, L > L L L L U
_Boolx1 like_suffix(NChar str, const ThreadSafePooledString &pattern)
Checks whether the string str has the suffix pattern.
for(std::size_t idx=1;idx< num_vectors;++idx) res.emplace((vectors_[idx].bitmask()<< uint32_t(idx *vector_type return * res
std::variant< std::monostate, _Boolx1, _Boolx16, _Boolx32 > SQL_boolean_t
I32x1 compare(const Environment &env_left, const Environment &env_right, const std::vector< SortingOperator::order_type > &order)
Compares two tuples, which must be already loaded into the environments env_left and env_right,...
std::conditional_t< std::is_signed_v< T >, int16_t, uint16_t > To
std::pair<::wasm::Expression *, std::list< std::shared_ptr< Bit > > > move()
Moves the underlying Binaryen ::wasm::Expression and the referenced bits out of this.
PrimitiveExpr operator+()
cmp_op
comparison operations, e.g. for string comparison
static constexpr std::size_t num_simd_lanes
the number of SIMD lanes of the represented expression, i.e. 1 for scalar and at least 2 for vectori...
T M_EXPORT powi(const T base, const U exp)
Power function for integral types.
std::function< void(void)> pipeline_t
ThreadSafeStringPool::proxy_type ThreadSafePooledString
void M_EXPORT setbit(T *bytes, bool value, uint32_t n)
The type of character strings, both fixed length and varying length.
std::size_t length
the maximum length of the string in bytes
bool is_varying
true if varying, false otherwise; corresponds to Char(N) and Varchar(N)
uint64_t size() const override
Returns the number of bits required to store a sequence of length many characters.
An Identifier is composed of a name and an optional prefix.
A Schema represents a sequence of identifiers, optionally with a prefix, and their associated types.
This class represents types in the SQL type system.
A constant: a string literal or a numeric constant.
A query expression for nested queries.
A unary expression: "+e", "-e", "~e", "NOT e".
A CNF represents a conjunction of cnf::Clauses.
static setup_t Make_Without_Parent(base_t &&callback=base_t())
This is an interface for factories that compute particular DataLayouts for a given sequence of Types,...
Models how data is laid out in a linear address space.
bool is_finite() const
returns true iff this DataLayout lays out a finite sequence of tuples
static teardown_t Make_Without_Parent(base_t &&callback=base_t())
Buffers tuples by materializing them into memory.
buffer_load_proxy_t< IsGlobal > create_load_proxy(param_t tuple_value_schema=param_t(), param_t tuple_addr_schema=param_t()) const
Creates and returns a proxy object to load value tuples of schema tuple_value_schema (default: entire...
void execute_pipeline_inline(setup_t setup, pipeline_t pipeline, teardown_t teardown, param_t tuple_value_schema=param_t(), param_t tuple_addr_schema=param_t()) const
Emits code inline to execute the given pipeline pipeline for each value tuple of schema tuple_value_s...
void resume_pipeline(param_t tuple_value_schema=param_t(), param_t tuple_addr_schema=param_t()) const
Emits code into a separate function to resume the pipeline for each value tuple of schema tuple_value...
pipeline_t pipeline_
remaining actual pipeline
Buffer(Buffer &&)=default
teardown_t teardown_
remaining pipeline post-processing
std::reference_wrapper< const Schema > schema_
schema of buffer
std::optional< FunctionProxy< void(void *, uint32_t)> > resume_pipeline_
function to resume pipeline for entire buffer; expects base address and size of buffer as parameters
const storage::DataLayout & layout() const
Returns the layout of the buffer.
void execute_pipeline(setup_t setup, pipeline_t pipeline, teardown_t teardown, param_t tuple_value_schema=param_t(), param_t tuple_addr_schema=param_t()) const
Emits code into a separate function to execute the give pipeline pipeline for each value tuple of sch...
bool load_simdfied_
flag whether to load from the buffer in SIMDfied manner
const Schema & schema() const
Returns the schema of the buffer.
Ptr< void > base_address() const
Returns the base address of the buffer.
void setup_base_address()
Performs the setup of the local base address of this buffer by reading it from the global backup.
void consume()
Emits code to store the current tuple into the buffer.
void teardown_base_address()
Performs the teardown of the local base address of this buffer by destroying it but without storing i...
buffer_swap_proxy_t< IsGlobal > create_swap_proxy(param_t tuple_schema=param_t()) const
Creates and returns a proxy object to swap tuples of schema tuple_schema (default: entire tuples) in ...
std::optional< Var< Boolx1 > > first_iteration_
flag to indicate first loop iteration for infinite buffer
std::optional< Var< Ptr< void > > > base_address_
base address of buffer
std::optional< std::reference_wrapper< const Schema > > param_t
parameter type for proxy creation and pipeline resuming methods
void setup()
Performs the setup of all local variables of this buffer (by reading them from the global backups iff...
std::optional< Var< U32x1 > > size_
current size of buffer, default initialized to 0
storage::DataLayout layout_
data layout of buffer
std::optional< Var< U32x1 > > capacity_
dynamic capacity of infinite buffer, default initialized to 0
buffer_storage< IsGlobal > storage_
if IsGlobal, contains backups for base address, capacity, and size
setup_t setup_
remaining pipeline initializations
buffer_store_proxy_t< IsGlobal > create_store_proxy(param_t tuple_schema=param_t()) const
Creates and returns a proxy object to store tuples of schema tuple_schema (default: entire tuples) to...
void resume_pipeline_inline(param_t tuple_value_schema=param_t(), param_t tuple_addr_schema=param_t()) const
Emits code inline to resume the pipeline for each value tuple of schema tuple_value_schema (default: ...
void teardown()
Performs the teardown of all local variables of this buffer (by storing them into the global backups ...
U32x1 size() const
Returns the current size of the buffer.
Buffer(const Buffer &)=delete
Buffer & operator=(Buffer &&)=default
The Wasm CodeGenContext provides context information necessary for code generation.
uint32_t get_literal_raw_address(const char *literal) const
Returns the raw address at which literal is stored.
Scope scoped_environment(Environment env)
Creates a new Scope using the Environment env which is immediately used by the CodeGenContext.
void inc_num_tuples(U32x1 n=U32x1(1))
Increments the number of result tuples produced by n.
std::unordered_map< const char *, std::pair< uint32_t, NChar > > literals_
maps each literal to its address at which it is stored
U32x1 num_tuples() const
Returns the number of result tuples produced.
const Environment & env() const
Returns the current Environment.
std::size_t num_simd_lanes() const
Returns the number of SIMD lanes used.
NChar get_literal_address(const char *literal) const
Returns the address at which literal is stored.
std::size_t num_simd_lanes_preferred_
number of SIMD lanes currently preferred, i.e. 1 for scalar and at least 2 for vectorial values
std::size_t num_simd_lanes_preferred() const
Returns the number of SIMD lanes preferred by other operators.
static thread_local std::unique_ptr< CodeGenContext > the_context_
Global< U32x1 > num_tuples_
variable to hold the number of result tuples produced
void add_literal(const char *literal, uint32_t ptr)
Adds the string literal literal located at pointer offset ptr.
Environment & env()
Returns the current Environment.
CodeGenContext(const CodeGenContext &)=delete
void set_num_simd_lanes(std::size_t n)
Sets the number of SIMD lanes used to n.
std::size_t num_simd_lanes_
number of SIMD lanes currently used, i.e. 1 for scalar and at least 2 for vectorial values
void update_num_simd_lanes_preferred(std::size_t n)
Updates the number of SIMD lanes preferred by n.
Environment * env_
environment for locally bound identifiers
void set_num_tuples(U32x1 n)
Set the number of result tuples produced to n.
static CodeGenContext & Get()
Scope scoped_environment()
Creates a new, scoped Environment.
static Decimal Scaled(expr_type value, uint32_t scale)
Constructs a Decimal from a given value at the given scale.
Decimal operator/(Decimal other)
friend std::ostream & operator<<(std::ostream &out, const Decimal &d)
Decimal operator-(Decimal other)
and signed_integral< typename expr_t< T >::type > Decimal operator*(T &&other)
Decimal operator%(T &&)
Modulo division is not supported by Decimal type.
Decimal(expr_type value, uint32_t scale)
Constructs a Decimal from a given value at the given scale.
and signed_integral< typename expr_t< T >::type > Decimal operator-(T &&other)
Decimal operator>>(T &&)
Shift right is not supported by Decimal type.
and signed_integral< typename expr_t< T >::type > Decimal operator/(T &&other)
and signed_integral< typename expr_t< T >::type > Decimal operator+(T &&other)
Decimal rotl(T &&)
Shift right is not supported by Decimal type.
void dump(std::ostream &out) const
Decimal rotr(T &&)
Shift right is not supported by Decimal type.
Decimal(Base value, uint32_t scale)
Constructs a Decimal from a given value at the given scale.
Decimal operator*(Decimal other)
Decimal operator~()
Bitwise negation is not supported by Decimal type.
Decimal operator<<(T &&)
Shift left is not supported by Decimal type.
uint32_t scale_
the number of decimal digits right of the decimal point
Decimal operator+(Decimal other)
Binds Schema::Identifiers to Expr<T>s.
auto compile(T &&t) const
Compile t by delegating compilation to an ExprCompiler for this Environment.
T extract_predicate()
Returns the moved current predication predicate.
void add_addr(Schema::Identifier id, SQL_addr_t &&expr)
Adds a address mapping from id to expr.
SQL_t extract(const Schema::Identifier &id)
Returns the moved entry for identifier id.
void add_predicate(const cnf::CNF &cnf)
Adds the predicate compiled from the cnf::CNF cnf to the predication predicate.
void add(const Environment &other)
Copies all entries of other into this.
SQL_t operator[](const Schema::Identifier &id) const
Returns the copied entry for identifier id.
auto compile(U &&u) const
Compile t by delegating compilation to an ExprCompiler for this Environment.
void add_predicate(SQL_boolean_t &&pred)
Adds the predicate pred to the predication predicate.
Environment(const Environment &)=delete
bool predicated() const
Returns true iff this Environment uses predication.
void clear()
Clears this Environment.
void add(Schema::Identifier id, T &&expr)
Adds a mapping from id to expr.
SQL_boolean_t predicate_
optional predicate if predication is used
std::unordered_map< Schema::Identifier, SQL_t > exprs_
maps Schema::Identifiers to Expr<T>s that evaluate to the current expression
SQL_addr_t get_addr(const Schema::Identifier &id) const
Returns the copied address entry for identifier id.
T get_addr(const Schema::Identifier &id) const
Returns the copied address entry for identifier id.
bool empty() const
Returns true iff this Environment is empty.
void add_addr(Schema::Identifier id, T &&expr)
Adds a address mapping from id to expr.
T get(const Schema::Identifier &id) const
Returns the copied entry for identifier id.
SQL_t get(const Schema::Identifier &id) const
Returns the copied entry for identifier id.
std::unordered_map< Schema::Identifier, SQL_addr_t > expr_addrs_
maps Schema::Identifiers to Ptr<Expr<T>>s that evaluate to the address of the current expression
Environment(Environment &&)=default
bool has_addr(const Schema::Identifier &id) const
Returns true iff this Environment contains the address of id.
T extract_addr(const Schema::Identifier &id)
Returns the moved address entry for identifier id.
SQL_boolean_t extract_predicate()
Returns the moved current predication predicate.
bool has(const Schema::Identifier &id) const
Returns true iff this Environment contains id.
T extract(const Schema::Identifier &id)
Returns the moved entry for identifier id.
void add(Schema::Identifier id, SQL_t &&expr)
Adds a mapping from id to expr.
SQL_addr_t extract_addr(const Schema::Identifier &id)
Returns the moved address entry for identifier id.
void add(Environment &&other)
Moves all entries of other into this.
bool is(const Schema::Identifier &id) const
Returns true iff the entry for identifier id has sql_type
T get_predicate() const
Returns the copied current predication predicate.
void add_predicate(T &&pred)
Adds the predicate pred to the predication predicate.
SQL_boolean_t get_predicate() const
Returns the copied current predication predicate.
bool is_addr(Schema::Identifier id) const
Returns true iff the address entry for identifier id has sql_addr_type
Compiles AST expressions m::Expr to Wasm ASTs m::wasm::Expr<T>.
SQL_t intermediate_result_
current intermediate results during AST traversal and compilation
void operator()(const ast::ErrorExpr &) override
SQL_t compile(const m::ast::Expr &e)
Compiles a m::Expr e of statically unknown type to a SQL_t.
T compile(const cnf::CNF &cnf)
Compile a m::cnf::CNF cnf of statically known type to
T compile(const m::ast::Expr &e)
Compile a m::Expr e of statically known type to
ExprCompiler(const Environment &env)
const Environment & env_
the environment to use for resolving designators to Expr<T>s
A handle to create a Function and to create invocations of that function.
std::size_t length() const
bool guarantees_terminating_nul() const
NChar(Ptr< Charx1 > ptr, bool can_be_null, std::size_t length, bool guarantees_terminating_nul)
uint64_t size_in_bytes() const
const CharacterSequence * type_
Ptr< Charx1 > insist_not_null()
NChar(Ptr< Charx1 > ptr, bool can_be_null, const CharacterSequence *type)
Scope(const Scope &)=delete
Environment extract()
Ends this Scope by returning the currently active environment and setting the former one active again...
Environment * outer_
environment active before and after this Scopes lifetime
Environment inner_
environment active during this Scopes lifetime
Proxy to implement loads from a buffer.
std::reference_wrapper< const Buffer< IsGlobal > > buffer_
buffer to load from
buffer_load_proxy_t & operator=(buffer_load_proxy_t &&)=default
buffer_load_proxy_t(const buffer_load_proxy_t &)=delete
buffer_load_proxy_t(buffer_load_proxy_t &&)=default
buffer_load_proxy_t(const Buffer< IsGlobal > &buffer, const Schema &value_schema, const Schema &addr_schema)
std::reference_wrapper< const Schema > addr_schema_
address entries to load
void operator()(U32x1 tuple_id)
Loads tuple with ID tuple_id into the current environment.
std::reference_wrapper< const Schema > value_schema_
value entries to load
const Schema & addr_schema() const
Returns the address entries to load.
const Schema & value_schema() const
Returns the value entries to load.
Proxy to implement stores to a buffer.
buffer_store_proxy_t(const buffer_store_proxy_t &)=delete
void operator()(U32x1 tuple_id)
Stores values from the current environment to tuple with ID tuple_id.
buffer_store_proxy_t & operator=(buffer_store_proxy_t &&)=default
std::reference_wrapper< const Buffer< IsGlobal > > buffer_
buffer to store to
std::reference_wrapper< const Schema > schema_
entries to store
buffer_store_proxy_t(buffer_store_proxy_t &&)=default
buffer_store_proxy_t(const Buffer< IsGlobal > &buffer, const Schema &schema)
const Schema & schema() const
Returns the entries to store.
Proxy to implement swaps in a buffer.
const Schema & schema() const
Returns the entries to swap.
buffer_swap_proxy_t(const Buffer< IsGlobal > &buffer, const Schema &schema)
std::reference_wrapper< const Schema > schema_
entries to swap
void operator()(U32x1 first, U32x1 second)
Swaps tuples with IDs first and second.
std::reference_wrapper< const Buffer< IsGlobal > > buffer_
buffer in which swaps are performed
Helper type to deduce the Expr<U> type given a.