]> Cypherpunks.ru repositories - gostls13.git/commit
[dev.regabi] cmd/compile: split out package typecheck [generated]
authorRuss Cox <rsc@golang.org>
Wed, 23 Dec 2020 05:41:49 +0000 (00:41 -0500)
committerRuss Cox <rsc@golang.org>
Wed, 23 Dec 2020 06:38:26 +0000 (06:38 +0000)
commitb9693d7627089204e6c2448f543c3512d86dae70
tree0f869f5abb58568525f47d330e93ef36e1467bf2
parentdac0de3748cc816352da56f516506f80c33db4a5
[dev.regabi] cmd/compile: split out package typecheck [generated]

This commit splits the typechecking logic into its own package,
the first of a sequence of CLs to break package gc into more
manageable units.

[git-generate]
cd src/cmd/compile/internal/gc
rf '
# The binary import/export has to be part of typechecking,
# because we load inlined function bodies lazily, but "exporter"
# should not be. Move that out of bexport.go.
mv exporter exporter.markObject exporter.markType export.go

# Use the typechecking helpers, so that the calls left behind
# in package gc do not need access to ctxExpr etc.
ex {
import "cmd/compile/internal/ir"

# TODO(rsc): Should not be necessary.
avoid TypecheckExpr
avoid TypecheckStmt
avoid TypecheckExprs
avoid TypecheckStmts
avoid TypecheckAssignExpr
avoid TypecheckCallee

var n ir.Node
var ns []ir.Node
typecheck(n, ctxExpr) -> TypecheckExpr(n)
typecheck(n, ctxStmt) -> TypecheckStmt(n)
typecheckslice(ns, ctxExpr) -> TypecheckExprs(ns)
typecheckslice(ns, ctxStmt) -> TypecheckStmts(ns)
typecheck(n, ctxExpr|ctxAssign) -> TypecheckAssignExpr(n)
typecheck(n, ctxExpr|ctxCallee) -> TypecheckCallee(n)
}

# Move some typechecking API to typecheck.
mv syslook LookupRuntime
mv substArgTypes SubstArgTypes
mv LookupRuntime SubstArgTypes syms.go

mv conv Conv
mv convnop ConvNop
mv Conv ConvNop typecheck.go

mv colasdefn AssignDefn
mv colasname assignableName

mv Target target.go

mv initname autoexport exportsym dcl.go
mv exportsym Export

# Export API to be called from outside typecheck.
# The ones with "Typecheck" prefixes will be renamed later to drop the prefix.
mv adddot AddImplicitDots
mv assignconv AssignConv
mv expandmeth CalcMethods
mv capturevarscomplete CaptureVarsComplete
mv checkMapKeys CheckMapKeys
mv checkreturn CheckReturn
mv dclcontext DeclContext
mv dclfunc DeclFunc
mv declare Declare
mv dotImportRefs DotImportRefs
mv declImporter DeclImporter
mv variter DeclVars
mv defaultlit DefaultLit
mv evalConst EvalConst
mv expandInline ImportBody
mv finishUniverse declareUniverse
mv funcbody FinishFuncBody
mv funchdr StartFuncBody
mv indexconst IndexConst
mv initTodo InitTodoFunc
mv lookup Lookup
mv resolve Resolve
mv lookupN LookupNum
mv nodAddr NodAddr
mv nodAddrAt NodAddrAt
mv nodnil NodNil
mv origBoolConst OrigBool
mv origConst OrigConst
mv origIntConst OrigInt
mv redeclare Redeclared
mv tostruct NewStructType
mv functype NewFuncType
mv methodfunc NewMethodType
mv structargs NewFuncParams
mv temp Temp
mv tempAt TempAt
mv typecheckok TypecheckAllowed
mv typecheck _typecheck # make room for typecheck pkg
mv typecheckinl TypecheckImportedBody
mv typecheckFunc TypecheckFunc
mv iimport ReadImports
mv iexport WriteExports
mv sysfunc LookupRuntimeFunc
mv sysvar LookupRuntimeVar

# Move function constructors to typecheck.
mv mkdotargslice MakeDotArgs
mv fixVariadicCall FixVariadicCall
mv closureType ClosureType
mv partialCallType PartialCallType
mv capturevars CaptureVars
mv MakeDotArgs FixVariadicCall ClosureType PartialCallType CaptureVars typecheckclosure func.go

mv autolabel AutoLabel
mv AutoLabel syms.go

mv Dlist dlist
mv Symlink symlink

mv \
AssignDefn assignableName \
AssignConv \
CaptureVarsComplete \
DeclContext \
DeclFunc \
DeclImporter \
DeclVars \
Declare \
DotImportRefs \
Export \
InitTodoFunc \
Lookup \
LookupNum \
LookupRuntimeFunc \
LookupRuntimeVar \
NewFuncParams \
NewName \
NodAddr \
NodAddrAt \
NodNil \
Redeclared \
StartFuncBody \
FinishFuncBody \
TypecheckImportedBody \
AddImplicitDots \
CalcMethods \
CheckFuncStack \
NewFuncType \
NewMethodType \
NewStructType \
TypecheckAllowed \
Temp \
TempAt \
adddot1 \
dotlist \
addmethod \
assignconvfn \
assignop \
autotmpname \
autoexport \
bexport.go \
checkdupfields \
checkembeddedtype \
closurename \
convertop \
declare_typegen \
decldepth \
dlist \
dotpath \
expand0 \
expand1 \
expandDecl \
fakeRecvField \
fnpkg \
funcStack \
funcStackEnt \
funcarg \
funcarg2 \
funcargs \
funcargs2 \
globClosgen \
ifacelookdot \
implements \
importalias \
importconst \
importfunc \
importobj \
importsym \
importtype \
importvar \
inimport \
initname \
isptrto \
loadsys \
lookdot0 \
lookdot1 \
makepartialcall \
okfor \
okforlen \
operandType \
slist \
symlink \
tointerface \
typeSet \
typeSet.add \
typeSetEntry \
typecheckExprSwitch \
typecheckTypeSwitch \
typecheckpartialcall \
typecheckrange \
typecheckrangeExpr \
typecheckselect \
typecheckswitch \
vargen \
builtin.go \
builtin_test.go \
const.go \
func.go \
iexport.go \
iimport.go \
mapfile_mmap.go \
syms.go \
target.go \
typecheck.go \
unsafe.go \
universe.go \
cmd/compile/internal/typecheck
'
rm gen.go types.go types_acc.go

sed -i '' 's/package gc/package typecheck/' mapfile_read.go mkbuiltin.go
mv mapfile_read.go ../typecheck # not part of default build
mv mkbuiltin.go ../typecheck # package main helper
mv builtin ../typecheck

cd ../typecheck
mv dcl.go dcl1.go
mv typecheck.go typecheck1.go
mv universe.go universe1.go
rf '
# Sweep some small files into larger ones.
# "mv sym... file1.go file.go" (after the mv file1.go file.go above)
# lets us insert sym... at the top of file.go.
mv okfor okforeq universe1.go universe.go
mv DeclContext vargen dcl1.go Temp TempAt autotmpname NewMethodType dcl.go
mv InitTodoFunc inimport decldepth TypecheckAllowed typecheck1.go typecheck.go
mv inl.go closure.go func.go
mv range.go select.go swt.go stmt.go
mv Lookup loadsys LookupRuntimeFunc LookupRuntimeVar syms.go
mv unsafe.go const.go

mv TypecheckAssignExpr AssignExpr
mv TypecheckExpr Expr
mv TypecheckStmt Stmt
mv TypecheckExprs Exprs
mv TypecheckStmts Stmts
mv TypecheckCall Call
mv TypecheckCallee Callee
mv _typecheck check
mv TypecheckFunc Func
mv TypecheckFuncBody FuncBody
mv TypecheckImports AllImportedBodies
mv TypecheckImportedBody ImportedBody
mv TypecheckInit Init
mv TypecheckPackage Package
'
rm gen.go go.go init.go main.go reflect.go

Change-Id: Iea6a7aaf6407d690670ec58aeb36cc0b280f80b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/279236
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
50 files changed:
src/cmd/compile/internal/gc/abiutils_test.go
src/cmd/compile/internal/gc/abiutilsaux_test.go
src/cmd/compile/internal/gc/alg.go
src/cmd/compile/internal/gc/bexport.go [deleted file]
src/cmd/compile/internal/gc/builtin.go [deleted file]
src/cmd/compile/internal/gc/closure.go
src/cmd/compile/internal/gc/dcl.go
src/cmd/compile/internal/gc/embed.go
src/cmd/compile/internal/gc/escape.go
src/cmd/compile/internal/gc/export.go
src/cmd/compile/internal/gc/gen.go [deleted file]
src/cmd/compile/internal/gc/go.go
src/cmd/compile/internal/gc/gsubr.go
src/cmd/compile/internal/gc/init.go
src/cmd/compile/internal/gc/inl.go
src/cmd/compile/internal/gc/main.go
src/cmd/compile/internal/gc/noder.go
src/cmd/compile/internal/gc/obj.go
src/cmd/compile/internal/gc/order.go
src/cmd/compile/internal/gc/pgen.go
src/cmd/compile/internal/gc/pgen_test.go
src/cmd/compile/internal/gc/range.go
src/cmd/compile/internal/gc/reflect.go
src/cmd/compile/internal/gc/select.go
src/cmd/compile/internal/gc/sinit.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/gc/subr.go
src/cmd/compile/internal/gc/swt.go
src/cmd/compile/internal/gc/types_acc.go [deleted file]
src/cmd/compile/internal/gc/unsafe.go [deleted file]
src/cmd/compile/internal/gc/walk.go
src/cmd/compile/internal/typecheck/bexport.go [new file with mode: 0644]
src/cmd/compile/internal/typecheck/builtin.go [new file with mode: 0644]
src/cmd/compile/internal/typecheck/builtin/runtime.go [moved from src/cmd/compile/internal/gc/builtin/runtime.go with 100% similarity]
src/cmd/compile/internal/typecheck/builtin_test.go [moved from src/cmd/compile/internal/gc/builtin_test.go with 97% similarity]
src/cmd/compile/internal/typecheck/const.go [moved from src/cmd/compile/internal/gc/const.go with 85% similarity]
src/cmd/compile/internal/typecheck/dcl.go [new file with mode: 0644]
src/cmd/compile/internal/typecheck/export.go [new file with mode: 0644]
src/cmd/compile/internal/typecheck/func.go [new file with mode: 0644]
src/cmd/compile/internal/typecheck/iexport.go [moved from src/cmd/compile/internal/gc/iexport.go with 99% similarity]
src/cmd/compile/internal/typecheck/iimport.go [moved from src/cmd/compile/internal/gc/iimport.go with 97% similarity]
src/cmd/compile/internal/typecheck/mapfile_mmap.go [moved from src/cmd/compile/internal/gc/mapfile_mmap.go with 98% similarity]
src/cmd/compile/internal/typecheck/mapfile_read.go [moved from src/cmd/compile/internal/gc/mapfile_read.go with 96% similarity]
src/cmd/compile/internal/typecheck/mkbuiltin.go [moved from src/cmd/compile/internal/gc/mkbuiltin.go with 99% similarity]
src/cmd/compile/internal/typecheck/stmt.go [new file with mode: 0644]
src/cmd/compile/internal/typecheck/subr.go [new file with mode: 0644]
src/cmd/compile/internal/typecheck/syms.go [new file with mode: 0644]
src/cmd/compile/internal/typecheck/target.go [moved from src/cmd/compile/internal/gc/types.go with 51% similarity]
src/cmd/compile/internal/typecheck/typecheck.go [moved from src/cmd/compile/internal/gc/typecheck.go with 92% similarity]
src/cmd/compile/internal/typecheck/universe.go [moved from src/cmd/compile/internal/gc/universe.go with 93% similarity]