[dev.regabi] cmd/compile: introduce cmd/compile/internal/base [generated]

Move Flag, Debug, Ctxt, Exit, and error messages to
new package cmd/compile/internal/base.

These are the core functionality that everything in gc uses
and which otherwise prevent splitting any other code
out of gc into different packages.

A minor milestone: the compiler source code
no longer contains the string "yy".

[git-generate]
cd src/cmd/compile/internal/gc
rf '
        mv atExit AtExit
        mv Ctxt atExitFuncs AtExit Exit base.go

        mv lineno Pos
        mv linestr FmtPos
        mv flusherrors FlushErrors
        mv yyerror Errorf
        mv yyerrorl ErrorfAt
        mv yyerrorv ErrorfVers
        mv noder.yyerrorpos noder.errorAt
        mv Warnl WarnfAt
        mv errorexit ErrorExit

        mv base.go debug.go flag.go print.go cmd/compile/internal/base
'

: # update comments
sed -i '' 's/yyerrorl/ErrorfAt/g; s/yyerror/Errorf/g' *.go

: # bootstrap.go is not built by default so invisible to rf
sed -i '' 's/Fatalf/base.Fatalf/' bootstrap.go
goimports -w bootstrap.go

: # update cmd/dist to add internal/base
cd ../../../dist
sed -i '' '/internal.amd64/a\
	"cmd/compile/internal/base",
' buildtool.go
gofmt -w buildtool.go

Change-Id: I59903c7084222d6eaee38823fd222159ba24a31a
Reviewed-on: https://go-review.googlesource.com/c/go/+/272250
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Russ Cox 2020-11-19 20:49:23 -05:00
parent eb3086e5a8
commit 26b66fd60b
67 changed files with 1626 additions and 1542 deletions

View file

@ -4,6 +4,8 @@
package gc
import "cmd/compile/internal/base"
// evalunsafe evaluates a package unsafe operation and returns the result.
func evalunsafe(n *Node) int64 {
switch n.Op {
@ -23,7 +25,7 @@ func evalunsafe(n *Node) int64 {
case OOFFSETOF:
// must be a selector.
if n.Left.Op != OXDOT {
yyerror("invalid expression %v", n)
base.Errorf("invalid expression %v", n)
return 0
}
@ -41,10 +43,10 @@ func evalunsafe(n *Node) int64 {
case ODOT, ODOTPTR:
break
case OCALLPART:
yyerror("invalid expression %v: argument is a method value", n)
base.Errorf("invalid expression %v: argument is a method value", n)
return 0
default:
yyerror("invalid expression %v", n)
base.Errorf("invalid expression %v", n)
return 0
}
@ -57,7 +59,7 @@ func evalunsafe(n *Node) int64 {
// but accessing f must not otherwise involve
// indirection via embedded pointer types.
if r.Left != sbase {
yyerror("invalid expression %v: selector implies indirection of embedded %v", n, r.Left)
base.Errorf("invalid expression %v: selector implies indirection of embedded %v", n, r.Left)
return 0
}
fallthrough
@ -65,12 +67,12 @@ func evalunsafe(n *Node) int64 {
v += r.Xoffset
default:
Dump("unsafenmagic", n.Left)
Fatalf("impossible %#v node after dot insertion", r.Op)
base.Fatalf("impossible %#v node after dot insertion", r.Op)
}
}
return v
}
Fatalf("unexpected op %v", n.Op)
base.Fatalf("unexpected op %v", n.Op)
return 0
}