Repository navigation
Conversation
hogoww
left a comment
There was a problem hiding this comment.
I doubled check about half the file so far, and indicated what's relevant for each file, to try to ease other people's review.
I'll finish a bit later
hogoww
left a comment
There was a problem hiding this comment.
Finished the triple checking.
I highlighted "important things", I hope it'll help.
I also caught a couple of difference in formatting that I'm gonna fix.
hogoww
left a comment
There was a problem hiding this comment.
- Updated the initial description, to try to make it clearer.
- Change the dependency between the
GDScriptParserandAnnotationNode - Updated all the review comments to reflect current state.
HolonProduction
left a comment
There was a problem hiding this comment.
As already mentioned I'm generally in favor of this change. At the moment GDScriptParser both holds parsing results (which are passed on to analyzer, compiler, etc.) and intermediate state relevant during parsing (which no other component should rely on). Holding them together doesn't make all that much sense.
- Keeping annotation functions in the parsers, is fine.
GDScriptParserstill owning the tree is also fine for now. This PR is about a structural split. The ownership split can come later.
Given the size of the patch we need to think a bit about git blame. To me the changes here can clearly be split into two categories:
- Refactoring (moving stuff, extracting functions)
- Qualifying (changing the qualification of things from
GDScriptParser(or no qualification) toAST/GDScriptAST.
The second kind is boring, trivial and self contained and touches a lot of complex code. As such I'd like to exclude those changes from git blame.
To achieve that you'll need to follow a strict commit structure:
- commit:
- Do refactoring changes (move stuff to
gdscript_ast.*) and extract the functions. - Create aliases for all the types in
GDScriptParser(e.gusing ClassNode = GDScriptAST::ClassNode;) - Already create the
using AST = GDScriptASTaliases.
- Do refactoring changes (move stuff to
- commit:
- Do all the qualification changes.
- commit:
- add the hash of the second commit to
.git-blame-ignore-revs - Remove the aliases from
GDScriptParser
- add the hash of the second commit to
With that structure the GDScriptParser -> AST changes won't appear in git blame, while the other refactoring things do. Doing the additional aliases in the analyzer ensures that each commit is well formed C++ which IMO is a good rule of thumb to follow.
(You don't need to rewrite all this stuff. You can just use git reset (WITHOUT --hard) to undo your commits and then redistribute the changes into new commits.)
If you want feel free to do the 1. commit as dedicated PR since applying changes with this commit structure might be annoying. For the stuff I already checked I don't expect many change requests (beyond what is included here). I haven't checked the code moved between the .h files yet though.
07babc6 to
76050db
Compare
…r qualifications update
…pear in git blame
|
While working on a different thing, I had a weird error. (Ref<Script>, Script wasn't defined, but that's in the template only, which wasn't needed to be resolved apparently, until i added some other irrelevant code). |
What problem(s) does this PR solve?
Additional information
@HolonProduction expressed their interest for this change that I had done in a discord post.
Currently, the references to GDScriptParser are everywhere in the compiler architecture.
Extracting the AST doesn't reduce much those dependencies at the moment, but it should in the future.
The AST is in the new directory module/gdscript/toolchain as suggested in this PR.
The diff is huge because nodes are everywhere in the GDScript files, but there are very few actual changes, and it's mostly renaming to the new namespace.
To try to ease the review:
I highlighted whether the file had only namespaces changes, and the actual semantic variations.
(Sorry there are multiple reviews github doesn't seem to allow edits (that I found), and it took me a couple of hours to check again every file in github's interface).
Cliffnotes:
This PR extracts from the
gdscript_parser.*files to thegdscript_ast.*files every node of the AST as well as the structsDataType,AnnotationInfo,ClassDocDataandMemberDocDatain the new namespaceGDScriptAST, reduced toASTin files using it heavily.Although
(Class|Member)DocDataare not strictly nodes, I think they make sense with the AST.DataTypemakes more sense in the AST than in the parser, but would make outside the AST too.See last point for
AnnotationInfodetails.Node that,
GDScriptASTis a class rather than a namespace (even though it has no state) because using a namespace would result in partial type errors, due to methods defined in the header.This PR extracts the TreePrinter from
gdscript_parser.*to thegdscript_ast.*files.The
TreePrinteris also currently outside theGDScriptASTclass.It's pretty independent already, and could be moved anywhere trivially, so it's a matter of deciding where it should be.
About the naming, @HolonProduction told me to use the
ASTalias like they started doing in this PR.There's a circular dependency between
AnnotationInfo,AnnotationActionandGDScriptParser.Current solution is to have
GDScriptParseras a friend ofGDScriptASTto keepAnnotationInfoprivate except from the parser (which is similar semantics to the current code).I removed a member function from
AnnotationNodeto reduce its dependency on the parser, as it doesn't seem to need the double dispatch.Having the annotation methods on
GDScriptParsercreates a dependency the AST in the AST, and maybe they shouldn't be there, but I don't know whether theGDScriptParserstate is required in these methods.I'm still untangling that part a bit, trying to find a better solution.
Please let me know if you think something else should be extracted.
Note
I'm fairly sure that
GDScriptParserholds information that should be somewhere in the AST (e.g., is_tool) but that should be tackled in a separate PR, as this is already a huge step.Edit: add a precision from Holon about naming.
Edit2: Try to clear up description, update some information.