SymbolTable Class, no startClass()?

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

SymbolTable Class, no startClass()?

peterxu422
Why is there no startClass() method specified in the API for the SymbolTable class? Doesn't a new classScope need to be created each time a new class is created so that it can keep track of its own fields and statics?
Reply | Threaded
Open this post in threaded view
|

Re: SymbolTable Class, no startClass()?

cadet1620
Administrator
peterxu422 wrote
Why is there no startClass() method specified in the API for the SymbolTable class? Doesn't a new classScope need to be created each time a new class is created so that it can keep track of its own fields and statics?
In the book recommended design, a new CompilationEngine is constructed for each file processed. One of the objects in the CompilationEngine is a SymbolTable, so each file starts with an empty SymbolTable. Since the Jack language spec says there can be only one class per file, the SymbolTable never needs to change to a different class scope.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: SymbolTable Class, no startClass()?

ybakos
In reply to this post by peterxu422
In addition, keep in mind that the suggested API is merely a starting point. If you prefer the semantics of a startClass method, then go for it!