Scope problems

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Scope problems

pikachu
I have implemented the scope using a boolean, false for class and true for method.
However, I have problems figuring out what is seen by each scope.
In the examples, there are field variables in the methods.
Should the method scope include field variables, or is there something else that already puts that in?

Pikachu
Reply | Threaded
Open this post in threaded view
|

Re: Scope problems

cadet1620
Administrator
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