about summary refs log tree commit diff stats
path: root/src/notes
blob: ade61bf5ee0b6c9e0b75c390bf3e7133edd37531 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Main thread combines a thread state and the global state
typedef struct LG {
  lua_State l;
  global_State g;
} LG;

lua_State:
  &{Value; int tt} stack, stack_last, base, top
  GCObject* next
  byte tt  # type == THREAD

Lua's stack vs globals: https://lucasklassmann.com/blog/2019-02-02-how-to-embeddeding-lua-in-c/#exposing-a-simple-variable
More info on the stack: https://www.lua.org/pil/24.2.html



# T[k] = v

## Approach 1:
  -- initial { ... T ... }
  push k
  push v
  settable index(T)
  -- final { ... T ... }

## Approach 2 (if k is a string):
  push v
  setfield index(T), k