MCPcopy Index your code
hub / github.com/Shopify/go-lua / objectLength

Method objectLength

vm.go:71–86  ·  view source on GitHub ↗
(v value)

Source from the content-addressed store, hash-verified

69}
70
71func (l *State) objectLength(v value) value {
72 var tm value
73 switch v := v.(type) {
74 case *table:
75 if tm = l.fastTagMethod(v.metaTable, tmLen); tm == nil {
76 return float64(v.length())
77 }
78 case string:
79 return float64(len(v))
80 default:
81 if tm = l.tagMethodByObject(v, tmLen); tm == nil {
82 l.typeError(v, "get length of")
83 }
84 }
85 return l.callTagMethod(tm, v, v)
86}
87
88func (l *State) equalTagMethod(mt1, mt2 *table, event tm) value {
89 if tm1 := l.fastTagMethod(mt1, event); tm1 == nil { // no metamethod

Callers 3

LengthMethod · 0.95
executeSwitchMethod · 0.95
initFunction · 0.80

Calls 5

fastTagMethodMethod · 0.95
tagMethodByObjectMethod · 0.95
typeErrorMethod · 0.95
callTagMethodMethod · 0.95
lengthMethod · 0.80

Tested by

no test coverage detected