-
Notifications
You must be signed in to change notification settings - Fork 1
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
Name resolution #23
Merged
Merged
Name resolution #23
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Merging recent Pipeline and workspace changes into this branch so I can use them
Cleaned up frontend and removed redundancies (InsRef and ExprRef). Improved parser errors and add some more syntax (extending a type). Added a directive for registering a C++ level function from runtime.h as a proto level function using function prototypes.
Decided to combine name resolution and type checking into one pass (SemanticAnalyzr)
Added bindings for C++ types along with other minor changes
After spending some time working on it, it is clear that I don't need to even evaluate the directives in 2 passes since I can resolve the types pretty easily during name resolution and type checking pass
Register will now work on a single prototype vs a whole block. I will add the ability to specify a whole block later as well as better error checking for what is being register (maybe in parser. or even in future partial evaluation pass)
Made some progress on Variable declarations and Struct declarations. Also added methods to make using symbol table a lot easier
- Added SourceRef to all nodes. - Got basic type checking and inference working for assignment statements and function bodies. - Replaced SemanticType with TypeReference object on ast nodes. - Also implemented basics for converting from a PIRType (which is the object in the symbol table which is referenced by TypeReference) to a TypeReference to get inference working.
For some reason, it has been working this whole time. The .combine() function had been wrong this whole time. It was not apparent to me that when you combine 2 source refs, start line and start col are perpetually bound together (as are end line and end col). It is obvious now, but.I was combining source references wrong this whole time. For example: ```rs fn returns_i8() i8 { // start line 0, start col 19 end line 0 end col 20 } // start line 1, start col 0, end line 1 end col 1 ``` Previously, when I combine these 2 Source Refs for the `{` and `}`, it would produce: start line 0 start col 0 (it has now misaligned the coordinates) end line 1 end col 20 (will throw an error for sure) This would select all of the text on line 0 and through an error on line 2 since it is only 1 character long but we require about 20 characters from it. 😆 To fix, just exploit the idea that line and col are always pair together. Start line and start col must come from the same object. With the fix, combining them gives: start line 0 start col 19 end line 1 end col 1 We have now gotten reference of the code block boundaries
This will allow comments be skipped over. I will need to rewrite the PIR to exclude comments. Formatting does not depend on any output from the analysis phase. This means once it passes, I can reformat the AST, which would already contain comments.
Ditching old PIR. Will eventually bring the array based technique to AST generated by parser. For now, I will focus on trying out the zig way of doing things. Cannot wait to have something I can write in zig
Added untyped IR and generation from basic AST. This will allow me run the code through a partial evaluator and have typed and type verified code by the end of the run. Fingers crossed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.