From f07fc0178831432b68f1b9bd6c96b257aa2e9abe Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Thu, 4 Dec 2025 13:28:22 +0100 Subject: chore: move symbol types and functions in its own package. --- vm/type.go | 4 ++-- vm/vm.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'vm') diff --git a/vm/type.go b/vm/type.go index 782aa28..644c106 100644 --- a/vm/type.go +++ b/vm/type.go @@ -95,8 +95,8 @@ func StructOf(fields []*Type) *Type { return &Type{Rtype: reflect.StructOf(rf)} } -// FieldNameIndex returns the index of struct field name. -func (t *Type) FieldNameIndex(name string) []int { +// FieldIndex returns the index of struct field name. +func (t *Type) FieldIndex(name string) []int { for _, f := range reflect.VisibleFields(t.Rtype) { if f.Name == name { return f.Index diff --git a/vm/vm.go b/vm/vm.go index d035226..6472156 100644 --- a/vm/vm.go +++ b/vm/vm.go @@ -69,7 +69,7 @@ type Instruction struct { } func (i Instruction) String() (s string) { - s = fmt.Sprintf("%4d: %v", i.Pos, i.Op) + s = fmt.Sprintf("%3d: %v", i.Pos, i.Op) var sb strings.Builder for _, a := range i.Arg { sb.WriteString(fmt.Sprintf(" %v", a)) @@ -100,7 +100,7 @@ func (m *Machine) Run() (err error) { sp = len(mem) // stack pointer c := m.code[ip] if debug { - log.Printf("ip:%-4d sp:%-4d fp:%-4d op:[%-18v] mem:%v\n", ip, sp, fp, c, Vstring(mem)) + log.Printf("ip:%-3d sp:%-3d fp:%-3d op:[%-20v] mem:%v\n", ip, sp, fp, c, Vstring(mem)) } ic++ switch c.Op { -- cgit v1.2.3