summaryrefslogtreecommitdiff
path: root/vm/type.go
diff options
context:
space:
mode:
Diffstat (limited to 'vm/type.go')
-rw-r--r--vm/type.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/vm/type.go b/vm/type.go
index 644c106..3a8d901 100644
--- a/vm/type.go
+++ b/vm/type.go
@@ -104,3 +104,13 @@ func (t *Type) FieldIndex(name string) []int {
}
return nil
}
+
+// FieldType returns the type of struct field name.
+func (t *Type) FieldType(name string) *Type {
+ for _, f := range reflect.VisibleFields(t.Rtype) {
+ if f.Name == name {
+ return &Type{Name: f.Name, PkgPath: f.PkgPath, Rtype: f.Type}
+ }
+ }
+ return nil
+}