From 1a9c22d1219eb0239417db16c9fe96eea3ced2fe Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Fri, 14 Nov 2025 13:47:51 +0100 Subject: fix: refactor VM instruction type Use custom types for VM instructions. More idiomatic code for tracing. --- vm/op_string.go | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 vm/op_string.go (limited to 'vm/op_string.go') diff --git a/vm/op_string.go b/vm/op_string.go new file mode 100644 index 0000000..ef3f3ee --- /dev/null +++ b/vm/op_string.go @@ -0,0 +1,57 @@ +// Code generated by "stringer -type=Op"; DO NOT EDIT. + +package vm + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[Nop-0] + _ = x[Add-1] + _ = x[Addr-2] + _ = x[Assign-3] + _ = x[Fassign-4] + _ = x[Vassign-5] + _ = x[Call-6] + _ = x[Calli-7] + _ = x[CallX-8] + _ = x[Deref-9] + _ = x[Dup-10] + _ = x[Fdup-11] + _ = x[Equal-12] + _ = x[EqualSet-13] + _ = x[Exit-14] + _ = x[Field-15] + _ = x[Greater-16] + _ = x[Grow-17] + _ = x[Index-18] + _ = x[Jump-19] + _ = x[JumpTrue-20] + _ = x[JumpFalse-21] + _ = x[JumpSetTrue-22] + _ = x[JumpSetFalse-23] + _ = x[Lower-24] + _ = x[Loweri-25] + _ = x[Mul-26] + _ = x[New-27] + _ = x[Not-28] + _ = x[Pop-29] + _ = x[Push-30] + _ = x[Return-31] + _ = x[Sub-32] + _ = x[Subi-33] +} + +const _Op_name = "NopAddAddrAssignFassignVassignCallCalliCallXDerefDupFdupEqualEqualSetExitFieldGreaterGrowIndexJumpJumpTrueJumpFalseJumpSetTrueJumpSetFalseLowerLoweriMulNewNotPopPushReturnSubSubi" + +var _Op_index = [...]uint8{0, 3, 6, 10, 16, 23, 30, 34, 39, 44, 49, 52, 56, 61, 69, 73, 78, 85, 89, 94, 98, 106, 115, 126, 138, 143, 149, 152, 155, 158, 161, 165, 171, 174, 178} + +func (i Op) String() string { + idx := int(i) - 0 + if i < 0 || idx >= len(_Op_index)-1 { + return "Op(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _Op_name[_Op_index[idx]:_Op_index[idx+1]] +} -- cgit v1.2.3