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(); }
public void visit(AbsVarDecl acceptor) { // Lokalna spremenljivka. // Parametre obdelamo pri AbsFunDecl. // Komponente obdelamo pri AbsRecType. Frame frame = frms.peek(); SemType type = TypeResolver.getType(acceptor.name); int offset = frame.addVariable(type.size()); Access access = new Access(frame.level, offset); setAccess(acceptor, access); acceptor.type.accept(this); }
public void visit(AbsFunCall acceptor) { Frame frame = frms.peek(); frame.ensureOutArgsSize(acceptor.args.exprs.size() * 4 + 4); for (AbsExpr arg : acceptor.args.exprs) arg.accept(this); }
public FrameResolver() { mainFrame = new Frame("", 0); frms = new Stack<Frame>(); frms.push(mainFrame); }