rename register for IsNull opcode

Now it has the same name as NotNull, so it is easier to write macros
This commit is contained in:
Glauber Costa
2025-01-31 19:09:01 -05:00
parent 7e8b190b9a
commit f300d2c8e8
5 changed files with 8 additions and 8 deletions

View File

@@ -448,7 +448,7 @@ pub fn translate_condition_expr(
let cur_reg = program.alloc_register();
translate_expr(program, Some(referenced_tables), expr, cur_reg, resolver)?;
program.emit_insn(Insn::IsNull {
src: cur_reg,
reg: cur_reg,
target_pc: condition_metadata.jump_target_when_false,
});
}

View File

@@ -310,7 +310,7 @@ impl ProgramBuilder {
Insn::IdxGT { target_pc, .. } => {
resolve(target_pc, "IdxGT");
}
Insn::IsNull { src: _, target_pc } => {
Insn::IsNull { reg: _, target_pc } => {
resolve(target_pc, "IsNull");
}
_ => continue,

View File

@@ -1034,14 +1034,14 @@ pub fn insn_to_str(
0,
"".to_string(),
),
Insn::IsNull { src, target_pc } => (
Insn::IsNull { reg, target_pc } => (
"IsNull",
*src as i32,
*reg as i32,
target_pc.to_debug_int(),
0,
OwnedValue::build_text(Rc::new("".to_string())),
0,
format!("if (r[{}]==NULL) goto {}", src, target_pc.to_debug_int()),
format!("if (r[{}]==NULL) goto {}", reg, target_pc.to_debug_int()),
),
Insn::ParseSchema { db, where_clause } => (
"ParseSchema",

View File

@@ -510,7 +510,7 @@ pub enum Insn {
/// Check if the register is null.
IsNull {
/// Source register (P1).
src: usize,
reg: usize,
/// Jump to this PC if the register is null (P2).
target_pc: BranchOffset,

View File

@@ -2389,8 +2389,8 @@ impl Program {
cursors.get_mut(*cursor_id).unwrap().take();
state.pc += 1;
}
Insn::IsNull { src, target_pc } => {
if matches!(state.registers[*src], OwnedValue::Null) {
Insn::IsNull { reg, target_pc } => {
if matches!(state.registers[*reg], OwnedValue::Null) {
state.pc = target_pc.to_offset_int();
} else {
state.pc += 1;