-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global table to maintain list of function names #2
Comments
Keeping a list of function names wont help if the function we are dealing with is defined in a class that we havent seen yet.If at all we want to do so, instead of creating a global table in a file which imports everything why dont we just create a new python file with a table for keeping track of the fn names? |
Do we really need the global table? Let all the function names of that particular class and class name be defined in the class_scope of the symbol table.Whenever we need to access the function outside of the class, it's object will be declared as lets say field OtherClass obj; . Since this obj is treated as a variable of type OtherClass, whenever you call a function obj.MethodName(), it will be printed as typeOf(obj).MethodName in vm. And anyways if you want to do this for checking correctness of code, this won't help unless you include all in-built functions in the symbol table. |
Oh wait why dont we create this class with 2 tables, one for function names that have been defined and those not defined yet (every time we see a function def, we remove the name if it exists from the second table) so after we see all the files, if the second table is non empty we throw an error? |
I just wanted to know if this has any utility apart from checking for correctness? |
so the above mentioned way covers correctness of code too |
no utility i guess just to ensure correctness of code |
yeah but we will never encounter the declaration of in-built functions, so they will always be left in second table |
no we will enounter them when we read the other files. |
the in-built functions are supplied directly as vm files |
oh those we can manually add right? and we can add a parameter saying inbuilt functions? |
yeah that will do |
okay so i ll create the .py file with the class.. |
So the .py file has 2 tables and the first one is already filled with the inbuilt function names. |
yeah.. I ll add the .py file with the class and functions definitions (at the least) before 2 today.. |
@Rag1 - you can now modify JackAnalyzer to add the global table to maintain list of function names across all files.
The text was updated successfully, but these errors were encountered: