From 12fc17246645f0605faee867459ac4513d3cec01 Mon Sep 17 00:00:00 2001 From: Isaac Woods Date: Thu, 9 Jan 2025 16:51:04 +0000 Subject: [PATCH] `ginkgo`: allow doc comments in opcode macro --- ginkgo/src/vm.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ginkgo/src/vm.rs b/ginkgo/src/vm.rs index 9b36856444..8e1c6304de 100644 --- a/ginkgo/src/vm.rs +++ b/ginkgo/src/vm.rs @@ -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, )* } @@ -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, @@ -400,3 +404,4 @@ impl cmp::PartialOrd for Value { } } } +}