Feature/split serialize#2460
Open
aleksisch wants to merge 2 commits intoGaijinEntertainment:masterfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors AST expression serialization by removing per-node serialize(AstSerializer&) virtual methods from Expression subclasses and replacing them with a visitor-based serialization path driven by a new Expression::dispatch(Visitor&) shim.
Changes:
- Replace
Expression::serialize/ExprXxx::serializewithExpression::dispatch/ExprXxx::dispatchand route expression serialization throughSerializeVisitor. - Add
src/ast/ast_dispatch.cppimplementingdispatchfor expression classes. - Wire the new dispatch TU into the build and update headers accordingly.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/builtin/module_builtin_ast_serialize.cpp | Moves expression serialization into SerializeVisitor and updates AstSerializer::operator<<(ExpressionPtr&) to use dispatch. |
| src/ast/ast_dispatch.cpp | Adds per-class dispatch shims to call the correct Visitor::preVisit(...) overloads. |
| include/daScript/ast/ast_expressions.h | Replaces serialize overrides with dispatch declarations for expression types. |
| include/daScript/ast/ast.h | Replaces Expression::serialize with Expression::dispatch and forward-declares Visitor. |
| CMakeLists.txt | Adds src/ast/ast_dispatch.cpp to AST_SRC. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c9af88f to
cfd618d
Compare
Now we can reuse visitor to just visit one node, not recursively. It will be used in following commit to extract serialize from Expression.
Ast should not know anything about serialization. Now serializer is separate visitor declared in src/builtin/module_builtin_ast_serialize.cpp
cfd618d to
c6385f9
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| void SerializeVisitor::preVisitExpression ( Expression * expr ) { | ||
| serializeBase(expr); |
| ser << macro; | ||
| ser.serializePointer(inFunction); | ||
| void SerializeVisitor::preVisit ( ExprLooksLikeCall * expr ) { | ||
| serializeLooksLikeCall(expr); |
This file contains hidden or 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
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.