Can the compiler generate bytecode from the AST in a single pass?

This post was a result of my looking at the now-obsolete peephole.c, and the ugly machinations it has to do to already generated bytecode. I’m glad to see that this work is now replaced by ast_opt.c, so I don’t have this objection any longer.
However, I wonder if there are other passes the compiler makes to existing bytecode that makes other corrections. If so, then shouldn’t these corrections also be made at the AST level?
I suggest that, if not already in existence, there should be a design principle that all manipulations to the compiled code be done at the AST level, and then it will be
converted to bytecode from the AST in a single operation, and not have to modify that bytecode later.
Comments, anyone?

FYI: Instead of asking in said place if this is a good place to post your question and titling your post as such, and then asking your question anyway, just ask your question and give your post an appropriate title so people know what it is asking—its one post either way which can always be moved somewhere else, and the latter keeps things shorter and more focused and the topic more obvious without having to click through to your whole post to understand what you are asking, which will both get you more/better answers and use less of others’ time.

I retitled it to something more appropriate and descriptive, as best as I was able to tell from re-reading your post several times. Feel free to modify it further if I did not adequately capture your intent, though you may want to modify your post content as well to be more clear about what you are asking. Thanks.

Thanks for the help. In the future, I’ll make posts to what I think would be the right discussion and let someone like you move it if need be.
I’ll edit my original post to simplify it.

1 Like