RawGet returns an LValue associated with a given key without __index metamethod.
(key LValue)
| 249 | |
| 250 | // RawGet returns an LValue associated with a given key without __index metamethod. |
| 251 | func (tb *LTable) RawGet(key LValue) LValue { |
| 252 | switch v := key.(type) { |
| 253 | case LNumber: |
| 254 | if isArrayKey(v) { |
| 255 | if tb.array == nil { |
| 256 | return LNil |
| 257 | } |
| 258 | index := int(v) - 1 |
| 259 | if index >= len(tb.array) { |
| 260 | return LNil |
| 261 | } |
| 262 | return tb.array[index] |
| 263 | } |
| 264 | case LString: |
| 265 | if tb.strdict == nil { |
| 266 | return LNil |
| 267 | } |
| 268 | if ret, ok := tb.strdict[string(v)]; ok { |
| 269 | return ret |
| 270 | } |
| 271 | return LNil |
| 272 | } |
| 273 | if tb.dict == nil { |
| 274 | return LNil |
| 275 | } |
| 276 | if v, ok := tb.dict[key]; ok { |
| 277 | return v |
| 278 | } |
| 279 | return LNil |
| 280 | } |
| 281 | |
| 282 | // RawGetInt returns an LValue at position `key` without __index metamethod. |
| 283 | func (tb *LTable) RawGetInt(key int) LValue { |