]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/typecheck: remove DeclContext
authorMatthew Dempsky <mdempsky@google.com>
Fri, 18 Aug 2023 06:28:32 +0000 (23:28 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 18 Aug 2023 22:39:00 +0000 (22:39 +0000)
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>

src/cmd/compile/internal/gc/compile.go
src/cmd/compile/internal/pkginit/init.go
src/cmd/compile/internal/reflectdata/alg.go
src/cmd/compile/internal/ssagen/abi.go
src/cmd/compile/internal/typecheck/dcl.go

index 47cc71df1e2e6df949592152c05f3651c3d1ac06..a2ffed7b00882cba94f6e8191ed1293c33262418 100644 (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.
index 3b7efba434550c9249704ffff2c755ff5ae74c03..daf26150a406e7c2704021a8702d00e8cadb782a 100644 (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)
 
index 27ecbe93802f2d015ee42ecc5cb0d3b5eaf9cbb6..d46b0cd360c5c2d2efa36703e81b339b943f6863 100644 (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,
index a1ed4c124c9a5cd5e00b23db30f960a69ea8a63c..6a6171a0ed652ca73ecfb8358c29f6d105076355 100644 (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
 }
 
index 7e4ba4fd58b679a50a25fadb711eb12473b05c2d..47b975e3b41b98af5d18975c3550dd80cef20f34 100644 (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 {