Skip to content

Conversation

@BackTrackCRoot
Copy link

@BackTrackCRoot BackTrackCRoot commented Dec 9, 2025

Support for replacing the current node during Visitor traversal.


While using it, I wanted to edit the tree to deobfuscate Lua code, but it seems editing functionality is not supported—only traversal is allowed. Of course, it's also possible that I'm not using it correctly. If that's the case, please close this issue. Currently, the code runs well in my project, though I’m not sure if there are any unknown bugs.

class NumberVisitor(ast.ASTReplaceVisitor):
    def visit_Number(self, node):
        # Replace all Number types with a Number type of value 123. Of course, other types can be returned here, or conditional filtering can be applied.
        return ast.Number(123)
        # If it is not necessary to replace the current one
        # return None

Support for replacing the current node during Visitor traversal.
@BackTrackCRoot

This comment was marked as resolved.

BackTrackCRoot

This comment was marked as abuse.

@boolangery
Copy link
Owner

Thanks I'm looking how I can integrate this feature in a more generic way into the existing visitor, I'll keep you updated. But for now you can use your implem directly in your code there is no blocker right?

@BackTrackCRoot
Copy link
Author

BackTrackCRoot commented Dec 11, 2025

Thank you very much! The code is currently working fine in my project without any blocking issues. Looking forward to hearing good news.
Additionally, I have resolved the issue regarding the incomplete type matching and have already updated it.

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