]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: replace calls to typecheck with transform functions
authorDan Scales <danscales@google.com>
Thu, 18 Mar 2021 21:36:39 +0000 (14:36 -0700)
committerDan Scales <danscales@google.com>
Tue, 23 Mar 2021 04:23:52 +0000 (04:23 +0000)
commit0265b6475f08f2c23a742132db87c357fcbfa458
treee436cb1c782b16ab3270c2d11f77765afdd9aa97
parentb8371d495bb291f61e4fa3ac1b84116c70ac1223
cmd/compile: replace calls to typecheck with transform functions

For additions, compares, and slices, create transform functions that do
just the transformations for those nodes by the typecheck package (given
that the code has been fully typechecked by types2). For nodes that have
no args with typeparams, we call these transform functions directly in
noder2. But for nodes that have args with typeparams, we have to delay
and call the tranform functions during stenciling, since we don't know
the specific types involved.

We indicate that a node still needs transformation by setting Typecheck
to a new value 3. This value means the current type of the node has been
set (via types2), but the node may still need transformation.

Had to export typcheck.IsCmp and typecheck.Assignop from the typecheck
package.

Added new tests list2.go (required delaying compare typecheck/transform
because of != compare in checkList) and adder.go (requires delaying add
typecheck/transform, since it can do addition for numbers or strings).

There are several more transformation functions needed for expressions
(indexing, calls, etc.) and several more complicated ones needed for
statements (mainly various kinds of assignments).

Change-Id: I7d89d13a4108308ea0304a4b815ab60b40c59b0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/303091
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/ir/node.go
src/cmd/compile/internal/noder/expr.go
src/cmd/compile/internal/noder/helpers.go
src/cmd/compile/internal/noder/stencil.go
src/cmd/compile/internal/typecheck/expr.go
src/cmd/compile/internal/typecheck/stmt.go
src/cmd/compile/internal/typecheck/subr.go
src/cmd/compile/internal/typecheck/typecheck.go
test/typeparam/adder.go [new file with mode: 0644]
test/typeparam/list2.go [new file with mode: 0644]