setGlobal method

void setGlobal(
  1. dynamic key
)

Pops a value from the stack and sets the global at key to it.

This is equivalent to:

state.pushGlobalTable();
state.push(key);
state.dup(-3); // Get value from what was previously top of stack
state.tableSet();
state.pop(2); // Pop both the global table and original value

Implementation

void setGlobal(dynamic key) {
  pushGlobalTable();
  push(key);
  dup(-3);
  tableSet();
  pop(2);
}