Skip to content

Add AST::PointerVisitor #4079

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

CohenArthur
Copy link
Member

This adds a new visitor for visiting unique_ptr members and possibly reseating them, for example when desugaring a while-let loop to a regular loop expression.

I think we could use this for ExpandVisitor but it's not as easy since we also do cfg stripping in there, which may remove elements from vectors.

Also, I'm not sure if the name is right - I was debating between PointerVisitor, ReseatVisitor and ExternalVisitor. other ideas welcome

gcc/rust/ChangeLog:

	* Make-lang.in: Compile it.
	* ast/rust-builtin-ast-nodes.h: Add missing methods for getting pointers.
	* ast/rust-expr.h: Likewise.
	* ast/rust-item.h: Likewise.
	* ast/rust-path.h: Likewise.
	* ast/rust-pattern.h: Likewise.
	* ast/rust-type.h: Likewise.
	* ast/rust-ast-pointer-visitor.cc: New file.
	* ast/rust-ast-pointer-visitor.h: New file.
gcc/rust/ChangeLog:

	* ast/rust-expression-yeast.cc (ExpressionYeast::dispatch): Rename to...
	(ExpressionYeast::reseat): ...this.
	(ExpressionYeast::visit): Remove.
	* ast/rust-expression-yeast.h: Inherit from PointerVisitor, override reseat instead
	of declaring dispatch.
@powerboat9
Copy link
Collaborator

If we want to use this for ExpandVisitor (which I think would be a good idea) it'd have to have support for replacing nodes with 0 <= N other nodes, instead of just doing 1->1 mappings

@powerboat9
Copy link
Collaborator

Maybe add something like virtual void reseat_multi (std::vector<std::unique_ptr<AST::Expr>> &vec) {}?

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

Successfully merging this pull request may close these issues.

2 participants