mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-23 00:45:37 +01:00
core/vdbe: Move Insn implementation close to struct definition
This commit is contained in:
@@ -816,6 +816,176 @@ pub enum Insn {
|
||||
},
|
||||
}
|
||||
|
||||
impl Insn {
|
||||
pub fn to_function(&self) -> InsnFunction {
|
||||
match self {
|
||||
Insn::Init { .. } => execute::op_init,
|
||||
|
||||
Insn::Null { .. } => execute::op_null,
|
||||
|
||||
Insn::NullRow { .. } => execute::op_null_row,
|
||||
|
||||
Insn::Add { .. } => execute::op_add,
|
||||
|
||||
Insn::Subtract { .. } => execute::op_subtract,
|
||||
|
||||
Insn::Multiply { .. } => execute::op_multiply,
|
||||
|
||||
Insn::Divide { .. } => execute::op_divide,
|
||||
|
||||
Insn::Compare { .. } => execute::op_compare,
|
||||
Insn::BitAnd { .. } => execute::op_bit_and,
|
||||
|
||||
Insn::BitOr { .. } => execute::op_bit_or,
|
||||
|
||||
Insn::BitNot { .. } => execute::op_bit_not,
|
||||
|
||||
Insn::Checkpoint { .. } => execute::op_checkpoint,
|
||||
Insn::Remainder { .. } => execute::op_remainder,
|
||||
|
||||
Insn::Jump { .. } => execute::op_jump,
|
||||
Insn::Move { .. } => execute::op_move,
|
||||
Insn::IfPos { .. } => execute::op_if_pos,
|
||||
Insn::NotNull { .. } => execute::op_not_null,
|
||||
|
||||
Insn::Eq { .. } => execute::op_eq,
|
||||
Insn::Ne { .. } => execute::op_ne,
|
||||
Insn::Lt { .. } => execute::op_lt,
|
||||
Insn::Le { .. } => execute::op_le,
|
||||
Insn::Gt { .. } => execute::op_gt,
|
||||
Insn::Ge { .. } => execute::op_ge,
|
||||
Insn::If { .. } => execute::op_if,
|
||||
Insn::IfNot { .. } => execute::op_if_not,
|
||||
Insn::OpenReadAsync { .. } => execute::op_open_read_async,
|
||||
Insn::OpenReadAwait => execute::op_open_read_await,
|
||||
|
||||
Insn::VOpenAsync { .. } => execute::op_vopen_async,
|
||||
|
||||
Insn::VOpenAwait => execute::op_vopen_await,
|
||||
|
||||
Insn::VCreate { .. } => execute::op_vcreate,
|
||||
Insn::VFilter { .. } => execute::op_vfilter,
|
||||
Insn::VColumn { .. } => execute::op_vcolumn,
|
||||
Insn::VUpdate { .. } => execute::op_vupdate,
|
||||
Insn::VNext { .. } => execute::op_vnext,
|
||||
Insn::OpenPseudo { .. } => execute::op_open_pseudo,
|
||||
Insn::RewindAsync { .. } => execute::op_rewind_async,
|
||||
|
||||
Insn::RewindAwait { .. } => execute::op_rewind_await,
|
||||
Insn::LastAsync { .. } => execute::op_last_async,
|
||||
|
||||
Insn::LastAwait { .. } => execute::op_last_await,
|
||||
Insn::Column { .. } => execute::op_column,
|
||||
Insn::TypeCheck { .. } => execute::op_type_check,
|
||||
Insn::MakeRecord { .. } => execute::op_make_record,
|
||||
Insn::ResultRow { .. } => execute::op_result_row,
|
||||
|
||||
Insn::NextAsync { .. } => execute::op_next_async,
|
||||
|
||||
Insn::NextAwait { .. } => execute::op_next_await,
|
||||
Insn::PrevAsync { .. } => execute::op_prev_async,
|
||||
|
||||
Insn::PrevAwait { .. } => execute::op_prev_await,
|
||||
Insn::Halt { .. } => execute::op_halt,
|
||||
Insn::Transaction { .. } => execute::op_transaction,
|
||||
|
||||
Insn::AutoCommit { .. } => execute::op_auto_commit,
|
||||
Insn::Goto { .. } => execute::op_goto,
|
||||
|
||||
Insn::Gosub { .. } => execute::op_gosub,
|
||||
Insn::Return { .. } => execute::op_return,
|
||||
|
||||
Insn::Integer { .. } => execute::op_integer,
|
||||
|
||||
Insn::Real { .. } => execute::op_real,
|
||||
|
||||
Insn::RealAffinity { .. } => execute::op_real_affinity,
|
||||
|
||||
Insn::String8 { .. } => execute::op_string8,
|
||||
|
||||
Insn::Blob { .. } => execute::op_blob,
|
||||
|
||||
Insn::RowId { .. } => execute::op_row_id,
|
||||
|
||||
Insn::SeekRowid { .. } => execute::op_seek_rowid,
|
||||
Insn::DeferredSeek { .. } => execute::op_deferred_seek,
|
||||
Insn::SeekGE { .. } => execute::op_seek,
|
||||
Insn::SeekGT { .. } => execute::op_seek,
|
||||
Insn::SeekLE { .. } => execute::op_seek,
|
||||
Insn::SeekLT { .. } => execute::op_seek,
|
||||
Insn::SeekEnd { .. } => execute::op_seek_end,
|
||||
Insn::IdxGE { .. } => execute::op_idx_ge,
|
||||
Insn::IdxGT { .. } => execute::op_idx_gt,
|
||||
Insn::IdxLE { .. } => execute::op_idx_le,
|
||||
Insn::IdxLT { .. } => execute::op_idx_lt,
|
||||
Insn::DecrJumpZero { .. } => execute::op_decr_jump_zero,
|
||||
|
||||
Insn::AggStep { .. } => execute::op_agg_step,
|
||||
Insn::AggFinal { .. } => execute::op_agg_final,
|
||||
|
||||
Insn::SorterOpen { .. } => execute::op_sorter_open,
|
||||
Insn::SorterInsert { .. } => execute::op_sorter_insert,
|
||||
Insn::SorterSort { .. } => execute::op_sorter_sort,
|
||||
Insn::SorterData { .. } => execute::op_sorter_data,
|
||||
Insn::SorterNext { .. } => execute::op_sorter_next,
|
||||
Insn::Function { .. } => execute::op_function,
|
||||
Insn::InitCoroutine { .. } => execute::op_init_coroutine,
|
||||
Insn::EndCoroutine { .. } => execute::op_end_coroutine,
|
||||
|
||||
Insn::Yield { .. } => execute::op_yield,
|
||||
Insn::InsertAsync { .. } => execute::op_insert_async,
|
||||
Insn::InsertAwait { .. } => execute::op_insert_await,
|
||||
Insn::IdxInsertAsync { .. } => execute::op_idx_insert_async,
|
||||
Insn::IdxInsertAwait { .. } => execute::op_idx_insert_await,
|
||||
Insn::DeleteAsync { .. } => execute::op_delete_async,
|
||||
|
||||
Insn::DeleteAwait { .. } => execute::op_delete_await,
|
||||
|
||||
Insn::NewRowid { .. } => execute::op_new_rowid,
|
||||
Insn::MustBeInt { .. } => execute::op_must_be_int,
|
||||
|
||||
Insn::SoftNull { .. } => execute::op_soft_null,
|
||||
|
||||
Insn::NotExists { .. } => execute::op_not_exists,
|
||||
Insn::OffsetLimit { .. } => execute::op_offset_limit,
|
||||
Insn::OpenWriteAsync { .. } => execute::op_open_write_async,
|
||||
Insn::OpenWriteAwait { .. } => execute::op_open_write_await,
|
||||
|
||||
Insn::Copy { .. } => execute::op_copy,
|
||||
Insn::CreateBtree { .. } => execute::op_create_btree,
|
||||
|
||||
Insn::Destroy { .. } => execute::op_destroy,
|
||||
Insn::DropTable { .. } => execute::op_drop_table,
|
||||
Insn::Close { .. } => execute::op_close,
|
||||
|
||||
Insn::IsNull { .. } => execute::op_is_null,
|
||||
|
||||
Insn::ParseSchema { .. } => execute::op_parse_schema,
|
||||
|
||||
Insn::ShiftRight { .. } => execute::op_shift_right,
|
||||
|
||||
Insn::ShiftLeft { .. } => execute::op_shift_left,
|
||||
|
||||
Insn::Variable { .. } => execute::op_variable,
|
||||
|
||||
Insn::ZeroOrNull { .. } => execute::op_zero_or_null,
|
||||
|
||||
Insn::Not { .. } => execute::op_not,
|
||||
|
||||
Insn::Concat { .. } => execute::op_concat,
|
||||
|
||||
Insn::And { .. } => execute::op_and,
|
||||
|
||||
Insn::Or { .. } => execute::op_or,
|
||||
|
||||
Insn::Noop => execute::op_noop,
|
||||
Insn::PageCount { .. } => execute::op_page_count,
|
||||
|
||||
Insn::ReadCookie { .. } => execute::op_read_cookie,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Add remaining cookies.
|
||||
#[derive(Description, Debug, Clone, Copy)]
|
||||
pub enum Cookie {
|
||||
@@ -1250,176 +1420,6 @@ pub fn exec_or(lhs: &OwnedValue, rhs: &OwnedValue) -> OwnedValue {
|
||||
}
|
||||
}
|
||||
|
||||
impl Insn {
|
||||
pub fn to_function(&self) -> InsnFunction {
|
||||
match self {
|
||||
Insn::Init { .. } => execute::op_init,
|
||||
|
||||
Insn::Null { .. } => execute::op_null,
|
||||
|
||||
Insn::NullRow { .. } => execute::op_null_row,
|
||||
|
||||
Insn::Add { .. } => execute::op_add,
|
||||
|
||||
Insn::Subtract { .. } => execute::op_subtract,
|
||||
|
||||
Insn::Multiply { .. } => execute::op_multiply,
|
||||
|
||||
Insn::Divide { .. } => execute::op_divide,
|
||||
|
||||
Insn::Compare { .. } => execute::op_compare,
|
||||
Insn::BitAnd { .. } => execute::op_bit_and,
|
||||
|
||||
Insn::BitOr { .. } => execute::op_bit_or,
|
||||
|
||||
Insn::BitNot { .. } => execute::op_bit_not,
|
||||
|
||||
Insn::Checkpoint { .. } => execute::op_checkpoint,
|
||||
Insn::Remainder { .. } => execute::op_remainder,
|
||||
|
||||
Insn::Jump { .. } => execute::op_jump,
|
||||
Insn::Move { .. } => execute::op_move,
|
||||
Insn::IfPos { .. } => execute::op_if_pos,
|
||||
Insn::NotNull { .. } => execute::op_not_null,
|
||||
|
||||
Insn::Eq { .. } => execute::op_eq,
|
||||
Insn::Ne { .. } => execute::op_ne,
|
||||
Insn::Lt { .. } => execute::op_lt,
|
||||
Insn::Le { .. } => execute::op_le,
|
||||
Insn::Gt { .. } => execute::op_gt,
|
||||
Insn::Ge { .. } => execute::op_ge,
|
||||
Insn::If { .. } => execute::op_if,
|
||||
Insn::IfNot { .. } => execute::op_if_not,
|
||||
Insn::OpenReadAsync { .. } => execute::op_open_read_async,
|
||||
Insn::OpenReadAwait => execute::op_open_read_await,
|
||||
|
||||
Insn::VOpenAsync { .. } => execute::op_vopen_async,
|
||||
|
||||
Insn::VOpenAwait => execute::op_vopen_await,
|
||||
|
||||
Insn::VCreate { .. } => execute::op_vcreate,
|
||||
Insn::VFilter { .. } => execute::op_vfilter,
|
||||
Insn::VColumn { .. } => execute::op_vcolumn,
|
||||
Insn::VUpdate { .. } => execute::op_vupdate,
|
||||
Insn::VNext { .. } => execute::op_vnext,
|
||||
Insn::OpenPseudo { .. } => execute::op_open_pseudo,
|
||||
Insn::RewindAsync { .. } => execute::op_rewind_async,
|
||||
|
||||
Insn::RewindAwait { .. } => execute::op_rewind_await,
|
||||
Insn::LastAsync { .. } => execute::op_last_async,
|
||||
|
||||
Insn::LastAwait { .. } => execute::op_last_await,
|
||||
Insn::Column { .. } => execute::op_column,
|
||||
Insn::TypeCheck { .. } => execute::op_type_check,
|
||||
Insn::MakeRecord { .. } => execute::op_make_record,
|
||||
Insn::ResultRow { .. } => execute::op_result_row,
|
||||
|
||||
Insn::NextAsync { .. } => execute::op_next_async,
|
||||
|
||||
Insn::NextAwait { .. } => execute::op_next_await,
|
||||
Insn::PrevAsync { .. } => execute::op_prev_async,
|
||||
|
||||
Insn::PrevAwait { .. } => execute::op_prev_await,
|
||||
Insn::Halt { .. } => execute::op_halt,
|
||||
Insn::Transaction { .. } => execute::op_transaction,
|
||||
|
||||
Insn::AutoCommit { .. } => execute::op_auto_commit,
|
||||
Insn::Goto { .. } => execute::op_goto,
|
||||
|
||||
Insn::Gosub { .. } => execute::op_gosub,
|
||||
Insn::Return { .. } => execute::op_return,
|
||||
|
||||
Insn::Integer { .. } => execute::op_integer,
|
||||
|
||||
Insn::Real { .. } => execute::op_real,
|
||||
|
||||
Insn::RealAffinity { .. } => execute::op_real_affinity,
|
||||
|
||||
Insn::String8 { .. } => execute::op_string8,
|
||||
|
||||
Insn::Blob { .. } => execute::op_blob,
|
||||
|
||||
Insn::RowId { .. } => execute::op_row_id,
|
||||
|
||||
Insn::SeekRowid { .. } => execute::op_seek_rowid,
|
||||
Insn::DeferredSeek { .. } => execute::op_deferred_seek,
|
||||
Insn::SeekGE { .. } => execute::op_seek,
|
||||
Insn::SeekGT { .. } => execute::op_seek,
|
||||
Insn::SeekLE { .. } => execute::op_seek,
|
||||
Insn::SeekLT { .. } => execute::op_seek,
|
||||
Insn::SeekEnd { .. } => execute::op_seek_end,
|
||||
Insn::IdxGE { .. } => execute::op_idx_ge,
|
||||
Insn::IdxGT { .. } => execute::op_idx_gt,
|
||||
Insn::IdxLE { .. } => execute::op_idx_le,
|
||||
Insn::IdxLT { .. } => execute::op_idx_lt,
|
||||
Insn::DecrJumpZero { .. } => execute::op_decr_jump_zero,
|
||||
|
||||
Insn::AggStep { .. } => execute::op_agg_step,
|
||||
Insn::AggFinal { .. } => execute::op_agg_final,
|
||||
|
||||
Insn::SorterOpen { .. } => execute::op_sorter_open,
|
||||
Insn::SorterInsert { .. } => execute::op_sorter_insert,
|
||||
Insn::SorterSort { .. } => execute::op_sorter_sort,
|
||||
Insn::SorterData { .. } => execute::op_sorter_data,
|
||||
Insn::SorterNext { .. } => execute::op_sorter_next,
|
||||
Insn::Function { .. } => execute::op_function,
|
||||
Insn::InitCoroutine { .. } => execute::op_init_coroutine,
|
||||
Insn::EndCoroutine { .. } => execute::op_end_coroutine,
|
||||
|
||||
Insn::Yield { .. } => execute::op_yield,
|
||||
Insn::InsertAsync { .. } => execute::op_insert_async,
|
||||
Insn::InsertAwait { .. } => execute::op_insert_await,
|
||||
Insn::IdxInsertAsync { .. } => execute::op_idx_insert_async,
|
||||
Insn::IdxInsertAwait { .. } => execute::op_idx_insert_await,
|
||||
Insn::DeleteAsync { .. } => execute::op_delete_async,
|
||||
|
||||
Insn::DeleteAwait { .. } => execute::op_delete_await,
|
||||
|
||||
Insn::NewRowid { .. } => execute::op_new_rowid,
|
||||
Insn::MustBeInt { .. } => execute::op_must_be_int,
|
||||
|
||||
Insn::SoftNull { .. } => execute::op_soft_null,
|
||||
|
||||
Insn::NotExists { .. } => execute::op_not_exists,
|
||||
Insn::OffsetLimit { .. } => execute::op_offset_limit,
|
||||
Insn::OpenWriteAsync { .. } => execute::op_open_write_async,
|
||||
Insn::OpenWriteAwait { .. } => execute::op_open_write_await,
|
||||
|
||||
Insn::Copy { .. } => execute::op_copy,
|
||||
Insn::CreateBtree { .. } => execute::op_create_btree,
|
||||
|
||||
Insn::Destroy { .. } => execute::op_destroy,
|
||||
Insn::DropTable { .. } => execute::op_drop_table,
|
||||
Insn::Close { .. } => execute::op_close,
|
||||
|
||||
Insn::IsNull { .. } => execute::op_is_null,
|
||||
|
||||
Insn::ParseSchema { .. } => execute::op_parse_schema,
|
||||
|
||||
Insn::ShiftRight { .. } => execute::op_shift_right,
|
||||
|
||||
Insn::ShiftLeft { .. } => execute::op_shift_left,
|
||||
|
||||
Insn::Variable { .. } => execute::op_variable,
|
||||
|
||||
Insn::ZeroOrNull { .. } => execute::op_zero_or_null,
|
||||
|
||||
Insn::Not { .. } => execute::op_not,
|
||||
|
||||
Insn::Concat { .. } => execute::op_concat,
|
||||
|
||||
Insn::And { .. } => execute::op_and,
|
||||
|
||||
Insn::Or { .. } => execute::op_or,
|
||||
|
||||
Insn::Noop => execute::op_noop,
|
||||
Insn::PageCount { .. } => execute::op_page_count,
|
||||
|
||||
Insn::ReadCookie { .. } => execute::op_read_cookie,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
|
||||
Reference in New Issue
Block a user