diff options
author | Iru Cai <mytbk920423@gmail.com> | 2014-11-22 17:07:40 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2014-11-22 17:07:40 +0800 |
commit | 257e30fdea1698dbaa61e165c50a965369dbf026 (patch) | |
tree | a41297d4d2fc09b13acced5b5d93d60b75244508 | |
parent | 1032ae89a9e30183ff65de2952a43813ac7835c0 (diff) | |
download | minijava-257e30fdea1698dbaa61e165c50a965369dbf026.tar.xz |
fix error
-rw-r--r-- | src/spiglet/visitor/GenKangaVisitor.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/spiglet/visitor/GenKangaVisitor.java b/src/spiglet/visitor/GenKangaVisitor.java index dbd5ae1..b4beb6c 100644 --- a/src/spiglet/visitor/GenKangaVisitor.java +++ b/src/spiglet/visitor/GenKangaVisitor.java @@ -34,6 +34,7 @@ import spiglet.syntaxtree.Temp; * order. Your visitors may extend this class. */ public class GenKangaVisitor extends GJDepthFirst<SpgSym, SpgSym> { + String lastlb; // // User-generated visitor methods below @@ -92,7 +93,10 @@ public class GenKangaVisitor extends GJDepthFirst<SpgSym, SpgSym> { * | PrintStmt() */ public SpgSym visit(Stmt n, SpgSym argu) { - n.f0.accept(this, argu); + SpgProc p = (SpgProc)argu; + n.f0.accept(this, p); + p.statements.lastElement().lb = lastlb; + lastlb = null; return null; } @@ -219,7 +223,7 @@ public class GenKangaVisitor extends GJDepthFirst<SpgSym, SpgSym> { // argu should be SpgProc SpgProc p = (SpgProc)argu; n.f1.accept(this, p); - p.retexp = (SpgSimpExpr)n.f3.accept(this, argu); + p.retexp = (SpgSimpExpr)n.f3.accept(this, null); return null; } @@ -315,8 +319,7 @@ public class GenKangaVisitor extends GJDepthFirst<SpgSym, SpgSym> { e.s = n.f0.tokenImage; if (argu!=null) { // should be a procedure - SpgProc p = (SpgProc)argu; - p.statements.lastElement().lb = e.s; + lastlb = e.s; } return e; } |