Add AST::PointerVisitor - #4079
Conversation
|
If we want to use this for |
|
Maybe add something like |
|
Note that we'd also need some way to expand inner attributes which might be a little more difficult. I'd like to use this visitor for ExpandVisitor as well but it's proving a little difficult |
9c57f7a to
c883208
Compare
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.
|
actually I don't think we need anything with inner attributes, but we need to think about this since expanding multiple children may also delete nodes. for now I have something working where ExpandVisitor inherits from this so let's just keep it simple and see how we can improve it later on |
This adds a new visitor for visiting unique_ptr members and possibly reseating them, for example when desugaring a
while-letloop to a regularloopexpression.I think we could use this for
ExpandVisitorbut 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,ReseatVisitorandExternalVisitor. other ideas welcome