(lvalue LValue, rawget bool)
| 973 | } |
| 974 | |
| 975 | func (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 | |
| 1001 | func (ls *LState) metaOp1(lvalue LValue, event string) LValue { |
| 1002 | if mt := ls.metatable(lvalue, true); mt != LNil { |
no test coverage detected