mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.typeparams] cmd/compile: add stenciling of simple generic functions
Allow full compilation and running of simple programs with generic functions by stenciling on the fly the needed generic functions. Deal with some simple derived types based on type params. Include a few new typeparam tests min.go and add.go which involve fully compiling and running simple generic code. Change-Id: Ifc2a64ecacdbd860faaeee800e2ef49ffef9df5e Reviewed-on: https://go-review.googlesource.com/c/go/+/289630 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>
This commit is contained in:
parent
f37b0c6c12
commit
dcb5e0392e
5 changed files with 380 additions and 0 deletions
|
|
@ -186,6 +186,21 @@ Outer:
|
|||
return false
|
||||
})
|
||||
}
|
||||
|
||||
// Create any needed stencils of generic functions
|
||||
g.stencil()
|
||||
|
||||
// For now, remove all generic functions from g.target.Decl, since they
|
||||
// have been used for stenciling, but don't compile. TODO: We will
|
||||
// eventually export any exportable generic functions.
|
||||
j := 0
|
||||
for i, decl := range g.target.Decls {
|
||||
if decl.Op() != ir.ODCLFUNC || decl.Type().NumTParams() == 0 {
|
||||
g.target.Decls[j] = g.target.Decls[i]
|
||||
j++
|
||||
}
|
||||
}
|
||||
g.target.Decls = g.target.Decls[:j]
|
||||
}
|
||||
|
||||
func (g *irgen) unhandled(what string, p poser) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue