Skip to content

Add base class for all AST nodes#9408

Merged
dlang-bot merged 1 commit intodlang:masterfrom
jacob-carlborg:ast-node-base-class
Mar 13, 2019
Merged

Add base class for all AST nodes#9408
dlang-bot merged 1 commit intodlang:masterfrom
jacob-carlborg:ast-node-base-class

Conversation

@jacob-carlborg
Copy link
Copy Markdown
Contributor

This is useful to be able to handle all AST nodes the same way, i.e. in an array. Common code for all AST nodes can also be placed here.

@dlang-bot
Copy link
Copy Markdown
Contributor

Thanks for your pull request and interest in making D better, @jacob-carlborg! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the annotated coverage diff directly on GitHub with CodeCov's browser extension
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + dmd#9408"

@jacob-carlborg jacob-carlborg force-pushed the ast-node-base-class branch 2 times, most recently from 029fbb6 to 2dc0072 Compare March 3, 2019 15:09
@jacob-carlborg jacob-carlborg added the Review:Blocking Other Work review and pulling should be a priority label Mar 3, 2019
@jacob-carlborg
Copy link
Copy Markdown
Contributor Author

Blocks #9409.

@WalterBright
Copy link
Copy Markdown
Member

I don't understand. The root object is already RootObject. Why add another layer?

@jacob-carlborg
Copy link
Copy Markdown
Contributor Author

I don't understand. The root object is already RootObject. Why add another layer?

I thought RootObject was the base class for all classes, regardless if the class is part of the AST or not. Only classes that are part of the AST should inherit from ASTNode.

As you can see I've added the accept method to ASTNode, if that where to be added to RootObject instead, the dmd.root package would need to import the visitor module. I would have guessed that the dmd.root should not import anything from outside of that package.

This is useful to be able to handle all AST nodes the same way, i.e.
in an array. Common code for all AST nodes can also be placed here.
@dlang-bot dlang-bot merged commit 769f95a into dlang:master Mar 13, 2019
@jacob-carlborg jacob-carlborg deleted the ast-node-base-class branch March 23, 2019 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merge:auto-merge Review:Blocking Other Work review and pulling should be a priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants