Skip to content
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

Open
SilverSoldier opened this issue Nov 9, 2016 · 14 comments
Open

Global table to maintain list of function names #2

SilverSoldier opened this issue Nov 9, 2016 · 14 comments

Comments

@SilverSoldier
Copy link
Collaborator

@Rag1 - you can now modify JackAnalyzer to add the global table to maintain list of function names across all files.

@Rag1
Copy link
Collaborator

Rag1 commented Nov 9, 2016

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?

@jahnvi12
Copy link
Owner

jahnvi12 commented Nov 9, 2016

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.

@Rag1
Copy link
Collaborator

Rag1 commented Nov 9, 2016

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?

@jahnvi12
Copy link
Owner

jahnvi12 commented Nov 9, 2016

I just wanted to know if this has any utility apart from checking for correctness?

@Rag1
Copy link
Collaborator

Rag1 commented Nov 9, 2016

so the above mentioned way covers correctness of code too

@Rag1
Copy link
Collaborator

Rag1 commented Nov 9, 2016

no utility i guess just to ensure correctness of code

@jahnvi12
Copy link
Owner

jahnvi12 commented Nov 9, 2016

yeah but we will never encounter the declaration of in-built functions, so they will always be left in second table

@Rag1
Copy link
Collaborator

Rag1 commented Nov 9, 2016

no we will enounter them when we read the other files.

@jahnvi12
Copy link
Owner

jahnvi12 commented Nov 9, 2016

the in-built functions are supplied directly as vm files

@Rag1
Copy link
Collaborator

Rag1 commented Nov 9, 2016

oh those we can manually add right? and we can add a parameter saying inbuilt functions?

@jahnvi12
Copy link
Owner

jahnvi12 commented Nov 9, 2016

yeah that will do

@Rag1
Copy link
Collaborator

Rag1 commented Nov 9, 2016

okay so i ll create the .py file with the class..

@SilverSoldier
Copy link
Collaborator Author

So the .py file has 2 tables and the first one is already filled with the inbuilt function names.
And Compilation Engine imports it?

@Rag1
Copy link
Collaborator

Rag1 commented Nov 9, 2016

yeah.. I ll add the .py file with the class and functions definitions (at the least) before 2 today..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants