Skip to content

Commit

Permalink
ginkgo: allow doc comments in opcode macro
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacWoods committed Jan 9, 2025
1 parent 4d768cf commit 12fc172
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ginkgo/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ use core::{cmp, fmt};
use std::collections::BTreeMap;

macro_rules! opcodes {
{ $($opcode:literal => $name:ident $(,)*)* } => {
{ $($(#[$($attrss:meta)*])* $opcode:literal => $name:ident $(,)*)* } => {
#[derive(Clone, Copy, PartialEq, Debug)]
#[repr(u8)]
pub enum Opcode {
$(
$(#[$($attrss)*])*
$name = $opcode,
)*
}
Expand All @@ -29,13 +30,16 @@ macro_rules! opcodes {

opcodes! {
0 => Return,
/// Push a constant onto the stack. Followed by a single-byte operand which is the index into the chunk's constant table.
1 => Constant,
2 => Negate,
3 => Add,
4 => Subtract,
5 => Multiply,
6 => Divide,
/// Push a `true` boolean value onto the stack.
7 => True,
/// Push a `false` boolean value onto the stack.
8 => False,
9 => BitwiseAnd,
10 => BitwiseOr,
Expand Down Expand Up @@ -400,3 +404,4 @@ impl cmp::PartialOrd for Value {
}
}
}
}

0 comments on commit 12fc172

Please sign in to comment.