MCPcopy Create free account
hub / github.com/yuin/gopher-lua / metatable

Method metatable

_state.go:875–899  ·  view source on GitHub ↗
(lvalue LValue, rawget bool)

Source from the content-addressed store, hash-verified

873}
874
875func (ls *LState) metatable(lvalue LValue, rawget bool) LValue {
876 var metatable LValue = LNil
877 switch obj := lvalue.(type) {
878 case *LTable:
879 metatable = obj.Metatable
880 case *LUserData:
881 metatable = obj.Metatable
882 default:
883 if table, ok := ls.G.builtinMts[int(obj.Type())]; ok {
884 metatable = table
885 }
886 }
887
888 if !rawget && metatable != LNil {
889 oldmt := metatable
890 if tb, ok := metatable.(*LTable); ok {
891 metatable = tb.RawGetString("__metatable")
892 if metatable == LNil {
893 metatable = oldmt
894 }
895 }
896 }
897
898 return metatable
899}
900
901func (ls *LState) metaOp1(lvalue LValue, event string) LValue {
902 if mt := ls.metatable(lvalue, true); mt != LNil {

Callers 3

metaOp1Method · 0.95
metaOp2Method · 0.95
GetMetatableMethod · 0.95

Calls 2

RawGetStringMethod · 0.80
TypeMethod · 0.65

Tested by

no test coverage detected