writeVariable method

void writeVariable(
  1. int varNum,
  2. int? value
)

Writes value to varNum either global or local.

Implementation

void writeVariable(int varNum, int? value) {
  assert(varNum >= 0 && varNum <= 0xff);
  if (varNum < 0 || varNum > 0xff) {
    log.warning("writeVariable expected range >= 0 and <=${0xff}, but got $varNum");
  }

  if (varNum > 0x0f) {
    mem.writeGlobal(varNum, value!);
    return;
  }

  if (varNum == 0x0) {
    stack.push(value!);
    return;
  }

  _writeLocal(varNum, value!);
}