Ejemplo 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));
  }
Ejemplo n.º 2
0
 public void regist(GlobalManager manager) {
   manager.setConst(this.name, new LocalMethodDeclare());
 }