aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2023-08-17 23:28:32 -0700
committerGopher Robot <gobot@golang.org>2023-08-18 22:39:00 +0000
commit4089b6a5b13282a2fd3d1ec5b1a2d67825c5e6b2 (patch)
treefff29bb072ba39bc9bf237872afdcc517a8beabd /src
parent09b03117b056c9d84c018f55910ffccc29976e4b (diff)
downloadgo-4089b6a5b13282a2fd3d1ec5b1a2d67825c5e6b2.tar.xz
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>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/gc/compile.go3
-rw-r--r--src/cmd/compile/internal/pkginit/init.go1
-rw-r--r--src/cmd/compile/internal/reflectdata/alg.go2
-rw-r--r--src/cmd/compile/internal/ssagen/abi.go3
-rw-r--r--src/cmd/compile/internal/typecheck/dcl.go29
5 files changed, 5 insertions, 33 deletions
diff --git a/src/cmd/compile/internal/gc/compile.go b/src/cmd/compile/internal/gc/compile.go
index 47cc71df1e..a2ffed7b00 100644
--- a/src/cmd/compile/internal/gc/compile.go
+++ b/src/cmd/compile/internal/gc/compile.go
@@ -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.
diff --git a/src/cmd/compile/internal/pkginit/init.go b/src/cmd/compile/internal/pkginit/init.go
index 3b7efba434..daf26150a4 100644
--- a/src/cmd/compile/internal/pkginit/init.go
+++ b/src/cmd/compile/internal/pkginit/init.go
@@ -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)
diff --git a/src/cmd/compile/internal/reflectdata/alg.go b/src/cmd/compile/internal/reflectdata/alg.go
index 27ecbe9380..d46b0cd360 100644
--- a/src/cmd/compile/internal/reflectdata/alg.go
+++ b/src/cmd/compile/internal/reflectdata/alg.go
@@ -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,
diff --git a/src/cmd/compile/internal/ssagen/abi.go b/src/cmd/compile/internal/ssagen/abi.go
index a1ed4c124c..6a6171a0ed 100644
--- a/src/cmd/compile/internal/ssagen/abi.go
+++ b/src/cmd/compile/internal/ssagen/abi.go
@@ -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
}
diff --git a/src/cmd/compile/internal/typecheck/dcl.go b/src/cmd/compile/internal/typecheck/dcl.go
index 7e4ba4fd58..47b975e3b4 100644
--- a/src/cmd/compile/internal/typecheck/dcl.go
+++ b/src/cmd/compile/internal/typecheck/dcl.go
@@ -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 {