File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -699,10 +699,27 @@ pub const Target = struct {
699699 .spirv64 = > .spirv64 ,
700700 };
701701 }
702+
703+ // re-implementing @tagName because @tagName is not null-terminated in the stage1 compiler
704+ fn tagName (value : anytype ) [:0 ]const u8 {
705+ const T = @TypeOf (value );
706+ const info = @typeInfo (T );
707+
708+ switch (info ) {
709+ .Enum = > | enum_info | {
710+ comptime var names : [enum_info .fields .len ][:0 ]const u8 = undefined ;
711+ inline for (enum_info .fields ) | field , i | {
712+ names [i ] = field .name ++ [0 :0 ]u8 {};
713+ }
714+ return names [@enumToInt (value )];
715+ },
716+ else = > @compileError ("tagName does no support type " ++ @typeName (T ) ++ "." ),
717+ }
718+ }
702719 pub fn string (self : TargetAbi ) ? [:0 ]const u8 {
703720 switch (self ) {
704- .riscv32 = > | abi | return @ tagName (abi ),
705- .riscv64 = > | abi | return @ tagName (abi ),
721+ .riscv32 = > | abi | return tagName (abi ),
722+ .riscv64 = > | abi | return tagName (abi ),
706723 else = > return null ,
707724 }
708725 }
You can’t perform that action at this time.
0 commit comments