File tree Expand file tree Collapse file tree
crates/compiler-core/src/bytecode Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,13 +33,20 @@ macro_rules! define_opcodes {
3333
3434 impl $opcode_name {
3535 #[ must_use]
36- pub const fn as_instruction( & self ) -> $instr_name {
36+ $opcode_vis const fn as_instruction( & self ) -> $instr_name {
3737 match self {
3838 $(
3939 Self :: $op_name => $instr_name:: $op_name $( { $arg_name: Arg :: marker( ) } ) ?,
4040 ) *
4141 }
4242 }
43+
44+ #[ must_use]
45+ $opcode_vis const fn name( & self ) -> & str {
46+ match self {
47+ $( Self :: $op_name => $op_display, ) *
48+ }
49+ }
4350 }
4451
4552 impl From <$opcode_name> for $instr_name {
@@ -70,9 +77,7 @@ macro_rules! define_opcodes {
7077
7178 impl :: core:: fmt:: Display for $opcode_name {
7279 fn fmt( & self , f: & mut :: core:: fmt:: Formatter <' _>) -> :: core:: fmt:: Result {
73- match self {
74- $( Self :: $op_name => write!( f, $op_display) , ) *
75- }
80+ write!( f, "{}" , self . name( ) )
7681 }
7782 }
7883
@@ -87,7 +92,7 @@ macro_rules! define_opcodes {
8792
8893 impl $instr_name {
8994 #[ must_use]
90- pub const fn opcode( & self ) -> $opcode_name {
95+ $instr_vis const fn opcode( & self ) -> $opcode_name {
9196 match self {
9297 $(
9398 Self :: $op_name $( { $arg_name: _ } ) ? => $opcode_name:: $op_name,
You can’t perform that action at this time.
0 commit comments