NewState creates a new thread running in a new, independent state. http://www.lua.org/manual/5.2/manual.html#lua_newstate
()
| 454 | // |
| 455 | // http://www.lua.org/manual/5.2/manual.html#lua_newstate |
| 456 | func NewState() *State { |
| 457 | v := float64(VersionNumber) |
| 458 | l := &State{allowHook: true, error: nil, nonYieldableCallCount: 1} |
| 459 | g := &globalState{mainThread: l, registry: newTable(), version: &v, memoryErrorMessage: "not enough memory"} |
| 460 | l.global = g |
| 461 | l.initializeStack() |
| 462 | g.registry.putAtInt(RegistryIndexMainThread, l) |
| 463 | g.registry.putAtInt(RegistryIndexGlobals, newTable()) |
| 464 | copy(g.tagMethodNames[:], eventNames) |
| 465 | return l |
| 466 | } |
| 467 | |
| 468 | func apiCheckStackIndex(index int, v value) { |
| 469 | if apiCheck && (v == none || isPseudoIndex(index)) { |