Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

works for functions too

  • Loading branch information...
commit afd8326d39cb26e134523f8e2412d9cb313bd1af 1 parent e70254d
@Swizec authored
Showing with 37 additions and 3 deletions.
  1. +37 −3 pascal/src/compiler/frames/FrmEvaluator.java
View
40 pascal/src/compiler/frames/FrmEvaluator.java
@@ -19,8 +19,8 @@ public void visit(AbsAtomType acceptor) {
public void visit(AbsConstDecl acceptor) {
}
- @Override
- public void visit(AbsFunDecl acceptor) {
+ /* @Override
+ public void visit(AbsSub acceptor) {
FrmFrame frame = new FrmFrame(acceptor, SemDesc.getScope(acceptor));
sizeArgs = 0;
@@ -52,7 +52,7 @@ public void visit(AbsFunDecl acceptor) {
}
FrmDesc.setFrame(acceptor, frame);
- }
+ }*/
@Override
public void visit(AbsProgram acceptor) {
@@ -70,6 +70,40 @@ public void visit(AbsProgram acceptor) {
}
@Override
+ public void visit(AbsFunDecl acceptor) {
+ FrmFrame frame = new FrmFrame(acceptor, SemDesc.getScope(acceptor));
+ sizeArgs = 0;
+
+ for (AbsDecl decl : acceptor.pars.decls) {
+ if (decl instanceof AbsVarDecl) {
+ AbsVarDecl varDecl = (AbsVarDecl)decl;
+ FrmArgAccess access = new FrmArgAccess(varDecl, frame);
+ FrmDesc.setAccess(varDecl, access);
+ sizeArgs += 4;
+ }
+ }
+ for (AbsDecl decl : acceptor.decls.decls) {
+ if (decl instanceof AbsVarDecl) {
+ AbsVarDecl varDecl = (AbsVarDecl)decl;
+ FrmLocAccess access = new FrmLocAccess(varDecl, frame);
+ frame.locVars.add(access);
+ FrmDesc.setAccess(varDecl, access);
+ }
+ decl.accept(this);
+ }
+
+ isAnyCall = false;
+ acceptor.stmt.accept(this);
+ frame.sizeArgs = sizeArgs;
+
+ if (isAnyCall) {
+ frame.sizeArgs += 4;
+ }
+
+ FrmDesc.setFrame(acceptor, frame);
+ }
+
+ @Override
public void visit(AbsProcDecl acceptor) {
FrmFrame frame = new FrmFrame(acceptor, SemDesc.getScope(acceptor));
sizeArgs = 0;
Please sign in to comment.
Something went wrong with that request. Please try again.