SubstituteSymbolTable(SymbolTable original, int version, int maxId) { assert original.isSharedTable() && !original.isSystemTable(); assert (original.getVersion() != version || original.getMaxId() != maxId); myOriginalSymTab = original; myName = original.getName(); myVersion = version; myMaxId = maxId; }
@SuppressWarnings("unchecked") public Iterator<String> iterateDeclaredSymbolNames() { Iterator<String> originalIterator; if (myOriginalSymTab != null) { originalIterator = myOriginalSymTab.iterateDeclaredSymbolNames(); } else { originalIterator = Collections.EMPTY_LIST.iterator(); } return new SymbolIterator(originalIterator); }
public int findSymbol(String text) { int sid = UNKNOWN_SYMBOL_ID; if (myOriginalSymTab != null) { sid = myOriginalSymTab.findSymbol(text); if (sid > myMaxId) { sid = UNKNOWN_SYMBOL_ID; } } return sid; }
public SymbolToken find(String text) { SymbolToken tok = null; if (myOriginalSymTab != null) { tok = myOriginalSymTab.find(text); // If symbol token is found but its sid is beyond the correct max // id of the substitute, then return null, as it should not be // found at all. if (tok != null && tok.getSid() > myMaxId) { tok = null; } } return tok; }
public String findKnownSymbol(int id) { if (id > myMaxId || myOriginalSymTab == null) { return null; } return myOriginalSymTab.findKnownSymbol(id); }