In addition to what Jesper said, the walk pass does a variety of lowerings and optimizations on the ast. For example, it rewrites the builtin `new` to a runtime call, rewrites switches to a tree of `if` statements, etc.
On Monday, July 20, 2020 at 2:11:08 AM UTC-7 jesper.lou...@gmail.com wrote: > From a quick glance that might be wrong: > > It looks like the walk function visits an abstract syntax tree (AST) and > performs checks for the statics part of the compiler. E.g., it finds unused > variables and functions, type-illegal statements and so on. The term "walk" > is used as in that it "walks over the tree and visits each node". The > purpose is likely to set up the AST in a state where it is well-typed. This > simplifies later stages of the compiler as it can assume certain > well-formed principles of the AST structure. > > On Mon, Jul 20, 2020 at 4:39 AM xie cui <cuiw...@gmail.com> wrote: > >> the go tool compile will call walk, what 's effect of this call? >> >> https://github.com/golang/go/blob/master/src/cmd/compile/internal/gc/walk.go#L20 >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/golang-nuts/6a65acad-3756-4d77-bf16-23be1a1f9055n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/golang-nuts/6a65acad-3756-4d77-bf16-23be1a1f9055n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > > > -- > J. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/4633f65b-b966-484e-b2cb-2b0d0366df20n%40googlegroups.com.