(lvalue LValue, rawget bool)
| 873 | } |
| 874 | |
| 875 | func (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 | |
| 901 | func (ls *LState) metaOp1(lvalue LValue, event string) LValue { |
| 902 | if mt := ls.metatable(lvalue, true); mt != LNil { |
no test coverage detected