Skip to main content

define_opcodes

Macro define_opcodes 

Source
define_opcodes!() { /* proc-macro */ }
Expand description

Emit the VM opcode definitions from a centralized declarative table.

See the crate-level doc for syntax. Generated outputs:

  • pub enum Op { ... } (#[repr(u8)], Debug + Clone + Copy + Eq)
  • impl Op { const ALL: &[Self]; const COUNT: usize; fn from_byte(...) -> Option<Self> }
  • impl crate::vm::Vm { fn execute_op_sync(...); async fn execute_op_async(...) }
  • impl crate::chunk::Chunk { fn disassemble_op(...) }
  • One free pub(crate) fn <flag>(op: Op) -> bool per declared flag. The well-known flags reads_outer_name and adaptive_binary map to op_reads_outer_name and is_adaptive_binary_op respectively so existing call sites need no renames.