diff options
author | Iru Cai <mytbk920423@gmail.com> | 2014-10-09 21:27:22 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2014-10-09 21:27:22 +0800 |
commit | 0f1c5cf0bc56cbbc990d4f57ced59c518a5cc114 (patch) | |
tree | 82b10e0081811b3b9261c8344dde388ec6b876b9 /src/minijava/visitor/BuildSymbolTableVisitor.java | |
parent | 07c5fd6cb477f7a561aad6128d93d4dab5d7e8cc (diff) | |
download | minijava-0f1c5cf0bc56cbbc990d4f57ced59c518a5cc114.tar.xz |
Update debugging support
Diffstat (limited to 'src/minijava/visitor/BuildSymbolTableVisitor.java')
-rw-r--r-- | src/minijava/visitor/BuildSymbolTableVisitor.java | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/minijava/visitor/BuildSymbolTableVisitor.java b/src/minijava/visitor/BuildSymbolTableVisitor.java index ecc1a06..1a09957 100644 --- a/src/minijava/visitor/BuildSymbolTableVisitor.java +++ b/src/minijava/visitor/BuildSymbolTableVisitor.java @@ -114,14 +114,15 @@ public class BuildSymbolTableVisitor extends GJDepthFirst<MType, MType> { n.f2.accept(this, argu); n.f3.accept(this, argu); n.f4.accept(this, argu); - n.f5.accept(this, argu); - n.f6.accept(this, argu); - n.f7.accept(this, argu); - n.f8.accept(this, argu); - n.f9.accept(this, argu); - n.f10.accept(this, argu); - // main的参数,待处理 - n.f11.accept(this, argu); + + // 往main class中添加main方法 + MMethod main_method = new MMethod("main", "void", n.f6.beginLine, n.f6.beginColumn); + MIdentifier argid = (MIdentifier) n.f11.accept(this, argu); + MVariable param = new MVariable(argid.getName(), "String[]", + argid.getLine(), argid.getColumn()); + main_method.addParam(param); + m_class.insertMethod(main_method); + n.f12.accept(this, argu); n.f13.accept(this, argu); // printStatement @@ -224,8 +225,8 @@ public class BuildSymbolTableVisitor extends GJDepthFirst<MType, MType> { String var_name = n.f1.accept(this, argu).getName(); String type_name = n.f0.accept(this, argu).getName(); // debug - System.out.println("Variable: \'" + var_name + "\' from class/method " + m_class.getName()); - System.out.println("It has type: " + type_name); + // System.out.println("Variable: \'" + var_name + "\' from class/method " + m_class.getName()); + // System.out.println("It has type: " + type_name); // 建立并插入变量 MVariable var = new MVariable(var_name, type_name, n.f1.f0.beginLine, n.f1.f0.beginColumn); |