From afff6a80cd58f7787efa1398f7c8cbdce8989323 Mon Sep 17 00:00:00 2001 From: geno Date: Sun, 30 Jun 2024 13:36:37 +0200 Subject: fixed warnings, better formatting, final added where possible --- src/semanticanalysis/SymbolTable.java | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/semanticanalysis/SymbolTable.java') 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> symbolTable; - private ArrayList offset; + private final ArrayList> symbolTable; + private final ArrayList offset; public SymbolTable() { - this.symbolTable = new ArrayList>(); - this.offset = new ArrayList(); + 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 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); -- cgit v1.2.3-18-g5258