]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: create/use noder2 transform functions for more node types
authorDan Scales <danscales@google.com>
Tue, 23 Mar 2021 17:19:11 +0000 (10:19 -0700)
committerDan Scales <danscales@google.com>
Thu, 25 Mar 2021 00:06:23 +0000 (00:06 +0000)
commite7e0995cba1f57622f593ebd27d4d1a651666c4b
treee6be1b5449112b3a8a117901a4b8b160d9d5fa55
parent29ed12d4c7e61f6b4cc38d5b3d5eb885294f7878
cmd/compile:  create/use noder2 transform functions for more node types

Pull out the transformation part of the typechecking functions for:
 - assignment statements
 - return statements
 - send statements
 - select statements
 - type conversions
 - normal function/method calls
 - index operations

The transform functions are like the original typechecking functions,
but with all code removed related to:
  - Detecting compile-time errors (already done by types2)
  - Setting the actual type of existing nodes (already done based on
    info from types2)
  - Dealing with untyped constants

Moved all the transformation functions to a separate file, transform.go.

Continuing with the same pattern, we delay transforming a node if it has
any type params in its args, marking it with a typecheck flag of 3, and
do the actual transformation during stenciling.

Assignment statements are tricky, since their transformation must be
delayed if any of the left or right-hands-sides are delayed.

Still to do are:
 - selector expressions (OXDOT)
 - composite literal expressions (OCOMPLIT)
 - builtin function calls

Change-Id: Ie608cadbbc69b40db0067a5536cf707dd974aacc
Reviewed-on: https://go-review.googlesource.com/c/go/+/304049
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/noder/helpers.go
src/cmd/compile/internal/noder/stencil.go
src/cmd/compile/internal/noder/stmt.go
src/cmd/compile/internal/noder/transform.go [new file with mode: 0644]
src/cmd/compile/internal/noder/validate.go
src/cmd/compile/internal/typecheck/expr.go
src/cmd/compile/internal/typecheck/subr.go