(obj LValue, mt LValue)
| 2122 | } |
| 2123 | |
| 2124 | func (ls *LState) SetMetatable(obj LValue, mt LValue) { |
| 2125 | switch mt.(type) { |
| 2126 | case *LNilType, *LTable: |
| 2127 | default: |
| 2128 | ls.RaiseError("metatable must be a table or nil, but got %v", mt.Type().String()) |
| 2129 | } |
| 2130 | |
| 2131 | switch v := obj.(type) { |
| 2132 | case *LTable: |
| 2133 | v.Metatable = mt |
| 2134 | case *LUserData: |
| 2135 | v.Metatable = mt |
| 2136 | default: |
| 2137 | ls.G.builtinMts[int(obj.Type())] = mt |
| 2138 | } |
| 2139 | } |
| 2140 | |
| 2141 | /* }}} */ |
| 2142 |