1
0
mirror of https://github.com/golang/go synced 2024-11-22 21:50:03 -07:00

cmd/compile/internal/typecheck: remove DeclContext

The last use of this was removed in go.dev/cl/518757.

Change-Id: I41ddc9601bfa7e553b83c4c5a055104b2044d5d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/520610
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Matthew Dempsky 2023-08-17 23:28:32 -07:00 committed by Gopher Robot
parent 09b03117b0
commit 4089b6a5b1
5 changed files with 5 additions and 33 deletions

View File

@ -16,7 +16,6 @@ import (
"cmd/compile/internal/objw"
"cmd/compile/internal/ssagen"
"cmd/compile/internal/staticinit"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/compile/internal/walk"
"cmd/internal/obj"
@ -105,11 +104,9 @@ func prepareFunc(fn *ir.Func) {
// Calculate parameter offsets.
types.CalcSize(fn.Type())
typecheck.DeclContext = ir.PAUTO
ir.CurFunc = fn
walk.Walk(fn)
ir.CurFunc = nil // enforce no further uses of CurFunc
typecheck.DeclContext = ir.PEXTERN
}
// compileFunctions compiles all functions in compilequeue.

View File

@ -114,7 +114,6 @@ func MakeTask() {
if ni != 0 {
// Make an init._ function.
base.Pos = base.AutogeneratedPos
typecheck.DeclContext = ir.PEXTERN
name := noder.Renameinit()
fnInit := typecheck.DeclFunc(name, nil, nil, nil)

View File

@ -141,7 +141,6 @@ func hashFunc(t *types.Type) *ir.Func {
}
base.Pos = base.AutogeneratedPos // less confusing than end of input
typecheck.DeclContext = ir.PEXTERN
// func sym(p *T, h uintptr) uintptr
args := []*ir.Field{
@ -367,7 +366,6 @@ func eqFunc(t *types.Type) *ir.Func {
return sym.Def.(*ir.Name).Func
}
base.Pos = base.AutogeneratedPos // less confusing than end of input
typecheck.DeclContext = ir.PEXTERN
// func sym(p, q *T) bool
fn := typecheck.DeclFunc(sym, nil,

View File

@ -237,11 +237,9 @@ func makeABIWrapper(f *ir.Func, wrapperABI obj.ABI) {
// Q: is this needed?
savepos := base.Pos
savedclcontext := typecheck.DeclContext
savedcurfn := ir.CurFunc
base.Pos = base.AutogeneratedPos
typecheck.DeclContext = ir.PEXTERN
// At the moment we don't support wrapping a method, we'd need machinery
// below to handle the receiver. Panic if we see this scenario.
@ -329,7 +327,6 @@ func makeABIWrapper(f *ir.Func, wrapperABI obj.ABI) {
// Restore previous context.
base.Pos = savepos
typecheck.DeclContext = savedclcontext
ir.CurFunc = savedcurfn
}

View File

@ -15,11 +15,13 @@ import (
"cmd/internal/src"
)
var DeclContext ir.Class = ir.PEXTERN // PEXTERN/PAUTO
var funcStack []*ir.Func // stack of previous values of ir.CurFunc
func DeclFunc(sym *types.Sym, recv *ir.Field, params, results []*ir.Field) *ir.Func {
fn := ir.NewFunc(base.Pos, base.Pos, sym, nil)
StartFuncBody(fn)
funcStack = append(funcStack, ir.CurFunc)
ir.CurFunc = fn
var recv1 *types.Field
if recv != nil {
@ -38,25 +40,11 @@ func DeclFunc(sym *types.Sym, recv *ir.Field, params, results []*ir.Field) *ir.F
return fn
}
// declare the function proper
// and declare the arguments.
// called in extern-declaration context
// returns in auto-declaration context.
func StartFuncBody(fn *ir.Func) {
// change the declaration context from extern to auto
funcStack = append(funcStack, funcStackEnt{ir.CurFunc, DeclContext})
ir.CurFunc = fn
DeclContext = ir.PAUTO
}
// finish the body.
// called in auto-declaration context.
// returns in extern-declaration context.
func FinishFuncBody() {
// change the declaration context from auto to previous context
var e funcStackEnt
funcStack, e = funcStack[:len(funcStack)-1], funcStack[len(funcStack)-1]
ir.CurFunc, DeclContext = e.curfn, e.dclcontext
funcStack, ir.CurFunc = funcStack[:len(funcStack)-1], funcStack[len(funcStack)-1]
}
func CheckFuncStack() {
@ -83,13 +71,6 @@ func checkdupfields(what string, fss ...[]*types.Field) {
}
}
var funcStack []funcStackEnt // stack of previous values of ir.CurFunc/DeclContext
type funcStackEnt struct {
curfn *ir.Func
dclcontext ir.Class
}
func declareParams(fn *ir.Func, ctxt ir.Class, l []*ir.Field) []*types.Field {
fields := make([]*types.Field, len(l))
for i, n := range l {