コード例 #1
0
 public void visit(AbsFunDecl acceptor) {
   Frame frame = frms.peek();
   Frame newFrame = new Frame(acceptor.name.identifier.getLexeme(), frame.level + 1);
   setFrame(acceptor, newFrame);
   frms.push(newFrame);
   int offset = +4;
   for (AbsDecl decl : acceptor.pars.decls) {
     AbsVarDecl varDecl = (AbsVarDecl) decl;
     Access access = new Access(frame.level + 1, offset);
     offset += 4;
     setAccess(varDecl, access);
   }
   acceptor.type.accept(this);
   acceptor.expr.accept(this);
   frms.pop();
 }
コード例 #2
0
  public FrameResolver() {
    mainFrame = new Frame("", 0);

    frms = new Stack<Frame>();
    frms.push(mainFrame);
  }