summaryrefslogtreecommitdiff
path: root/vm
diff options
context:
space:
mode:
authorMarc Vertes <mvertes@free.fr>2025-12-03 15:28:18 +0100
committerMarc Vertes <mvertes@free.fr>2025-12-03 15:28:18 +0100
commit90284c5bedc5ab7bb442b34ef470744578dcd266 (patch)
tree09f28c2092ed28b0bbcedb15fccd6fb0846e64d2 /vm
parent3d64f909cfb55d8886ac4b4839a98f8f6cdc98e7 (diff)
feat: support literal struct expressions with keyed elements
Diffstat (limited to 'vm')
-rw-r--r--vm/type.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/vm/type.go b/vm/type.go
index 5f91eee..782aa28 100644
--- a/vm/type.go
+++ b/vm/type.go
@@ -94,3 +94,13 @@ 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 {
+ for _, f := range reflect.VisibleFields(t.Rtype) {
+ if f.Name == name {
+ return f.Index
+ }
+ }
+ return nil
+}