Esempio n. 1
0
  public VarAddress locate(String name, int fromUpstair, boolean force, int line, int column) {

    // local var/const
    for (; fromUpstair < stairStack.size(); fromUpstair++) {
      VarAddress address = stairStack.peek(fromUpstair).locate(name);
      if (address != null) {
        return address;
      }
    }

    // global var/const
    final GlobalManager globalMgr = this.globalManager;
    final int index = globalMgr.getGlobalIndex(name);
    if (index >= 0) {
      return global(index);
    }
    if (globalMgr.hasConst(name)) {
      return constValue(globalMgr.getConst(name));
    }

    // failed
    if (force) {
      throw new ParseException("Can't locate vars: ".concat(name), line, column);
    }
    // assign at root
    return context(root.assignVar(name, line, column));
  }
Esempio n. 2
0
 public VarAddress locateAtUpstair(String name, int upstair, int line, int column) {
   VarAddress address = stairStack.peek(upstair).locate(name);
   if (address != null) {
     return address;
   }
   throw new ParseException("Can't locate vars: ".concat(name), line, column);
 }
Esempio n. 3
0
 public int assignVariant(String name, int line, int column) {
   return stairStack.peek().assignVar(name, line, column);
 }
Esempio n. 4
0
 public void assignConst(String name, Object value, int line, int column) {
   stairStack.peek().assignConst(name, value, line, column);
 }
Esempio n. 5
0
 public void push() {
   push(stairStack.peek().id);
 }