readVariable method

int readVariable(
  1. int varNum
)

Implementation

int readVariable(int varNum) {
  assert(varNum >= 0 && varNum <= 0xff);

  if (varNum > 0x0f) {
    return mem.readGlobal(varNum);
  }
  if (varNum == 0x00) {
    return stack.pop();
  }
  return readLocal(varNum);
}