diff options
Diffstat (limited to 'src/semanticanalysis/SymbolTable.java')
-rw-r--r-- | src/semanticanalysis/SymbolTable.java | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/semanticanalysis/SymbolTable.java b/src/semanticanalysis/SymbolTable.java index db9649c..b620af7 100644 --- a/src/semanticanalysis/SymbolTable.java +++ b/src/semanticanalysis/SymbolTable.java @@ -1,8 +1,8 @@ package semanticanalysis; +import ast.types.*; import java.util.ArrayList; import java.util.HashMap; -import ast.types.*; /** * Class representing a symbol table. It's a list of hash table symbol table. We @@ -11,12 +11,12 @@ import ast.types.*; */ public class SymbolTable { - private ArrayList<HashMap<String, STentry>> symbolTable; - private ArrayList<Integer> offset; + private final ArrayList<HashMap<String, STentry>> symbolTable; + private final ArrayList<Integer> offset; public SymbolTable() { - this.symbolTable = new ArrayList<HashMap<String, STentry>>(); - this.offset = new ArrayList<Integer>(); + this.symbolTable = new ArrayList(); + this.offset = new ArrayList(); } /** @@ -96,7 +96,7 @@ public class SymbolTable { */ public boolean top_lookup(String id) { int n = symbolTable.size() - 1; - STentry T = null; + STentry T; HashMap<String, STentry> H = symbolTable.get(n); T = H.get(id); return (T != null); @@ -125,14 +125,6 @@ public class SymbolTable { // We always increment the offset by 1 otherwise we need ad-hoc bytecode // operations - // FIXME: wtf is that? - // if (type.getClass().equals((new BoolType()).getClass())) { - // offs = offs + 1; - // } else if (type.getClass().equals((new IntType()).getClass())) { - // offs = offs + 1; - // } else { - // offs = offs + 1; - // } offs = offs + 1; this.offset.add(offs); |