The way I handle scope is that I have a
SymbolTable object,
class_symbols, to which I add all class defined symbols (statics and fields).
When I encounter a subroutine definition, I allocate a new SymbolTable object, sub_symbols, to which I add all subroutine defined symbols (arguments and vars). At the end of the subroutine I deallocate sub_symbols.
When searching for a symbol, first I search in sub_symbols, and if the symbol is not found, then I search in class_symbols.
--Mark