MCPcopy Index your code
hub / github.com/yuin/gopher-lua / metatable

Method metatable

state.go:975–999  ·  view source on GitHub ↗
(lvalue LValue, rawget bool)

Source from the content-addressed store, hash-verified

973}
974
975func (ls *LState) metatable(lvalue LValue, rawget bool) LValue {
976 var metatable LValue = LNil
977 switch obj := lvalue.(type) {
978 case *LTable:
979 metatable = obj.Metatable
980 case *LUserData:
981 metatable = obj.Metatable
982 default:
983 if table, ok := ls.G.builtinMts[int(obj.Type())]; ok {
984 metatable = table
985 }
986 }
987
988 if !rawget && metatable != LNil {
989 oldmt := metatable
990 if tb, ok := metatable.(*LTable); ok {
991 metatable = tb.RawGetString("__metatable")
992 if metatable == LNil {
993 metatable = oldmt
994 }
995 }
996 }
997
998 return metatable
999}
1000
1001func (ls *LState) metaOp1(lvalue LValue, event string) LValue {
1002 if mt := ls.metatable(lvalue, true); mt != LNil {

Callers 4

metaOp1Method · 0.95
metaOp2Method · 0.95
GetMetatableMethod · 0.95
baseSetMetatableFunction · 0.45

Calls 2

RawGetStringMethod · 0.80
TypeMethod · 0.65

Tested by

no test coverage detected