diff options
author | Jeffrey Overbey | 2011-04-21 15:48:54 +0000 |
---|---|---|
committer | Jeffrey Overbey | 2011-04-21 15:48:54 +0000 |
commit | 4d51cce7a201c5061bdb45a75e4fb15ef2bff1d3 (patch) | |
tree | edbe61f28ffcd8d530f24d9751f0889665246422 | |
parent | ba1d8979f2913079d41c2a9cd3b0a5d09fb1fb65 (diff) | |
download | org.eclipse.photran-4d51cce7a201c5061bdb45a75e4fb15ef2bff1d3.tar.gz org.eclipse.photran-4d51cce7a201c5061bdb45a75e4fb15ef2bff1d3.tar.xz org.eclipse.photran-4d51cce7a201c5061bdb45a75e4fb15ef2bff1d3.zip |
Added named scope lookup methodsv201104221706v201104211942
-rw-r--r-- | org.eclipse.rephraserengine.core/src/org/eclipse/rephraserengine/core/analysis/symtab/SymbolTable.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/org.eclipse.rephraserengine.core/src/org/eclipse/rephraserengine/core/analysis/symtab/SymbolTable.java b/org.eclipse.rephraserengine.core/src/org/eclipse/rephraserengine/core/analysis/symtab/SymbolTable.java index 3650d7e7..59e08972 100644 --- a/org.eclipse.rephraserengine.core/src/org/eclipse/rephraserengine/core/analysis/symtab/SymbolTable.java +++ b/org.eclipse.rephraserengine.core/src/org/eclipse/rephraserengine/core/analysis/symtab/SymbolTable.java @@ -318,6 +318,41 @@ public class SymbolTable<N, S> else return parent.outermostScope(); } + + /** + * Returns the symbol table corresponding to the given named scope. + * + * @return the symbol table associated with the named scope <code>scopeName</code>, or + * <code>null</code> iff no such named scope exists + * + * @since 3.0 + */ + public SymbolTable<N, S> getNamedScope(String scopeName) + { + if (namedScopes != null) + return namedScopes.get(scopeName); + else + return null; + } + + /** + * Returns the nested symbol table found by traversing successively deeper named scopes, using + * the given sequence of scope names. + * + * @return the symbol table corresponding to + * <code>getNamedScope(scopeNames[0]).getNamedScope(scopeNames[1]).getNamedScope(scopeNames[2])</code> + * ..., or <code>null</code> iff no such named scope exists + * + * @since 3.0 + */ + public SymbolTable<N, S> getNestedNamedScope(String... scopeNames) + { + SymbolTable<N, S> result = this; + for (String scopeName : scopeNames) + if (!scopeName.trim().equals("") && result != null) //$NON-NLS-1$ + result = result.getNamedScope(scopeName); + return result; + } @Override public String toString() { |