1
0
mirror of https://github.com/golang/go synced 2024-09-28 18:14:29 -06:00
The Go programming language
Go to file
Russ Cox b9693d7627 [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>
2020-12-23 06:38:26 +00:00
.github .github: add link to questions in ISSUE_TEMPLATE 2020-01-06 17:05:31 +00:00
api api/go1.16: remove crypto/tls APIs that are moved to Go 1.17 2020-12-17 20:25:45 +00:00
doc crypto/tls: revert "add HandshakeContext method to Conn" 2020-12-17 20:04:25 +00:00
lib/time lib/time, time/tzdata: update tz data to 2020d 2020-10-24 21:42:44 +00:00
misc cmd/compile, runtime: use __msan_memmove for moving data, split msanread to fields 2020-12-03 15:40:11 +00:00
src [dev.regabi] cmd/compile: split out package typecheck [generated] 2020-12-23 06:38:26 +00:00
test [dev.regabi] all: merge master (c9fb4eb) into dev.regabi 2020-12-22 16:55:15 -05:00
.gitattributes all: treat all files as binary, but check in .bat with CRLF 2020-06-08 15:31:43 +00:00
.gitignore .gitignore: ignore src/cmd/dist/dist 2017-10-28 21:55:49 +00:00
AUTHORS A+C: add Kush Patel (corporate CLA for Hootsuite Inc) 2020-07-08 00:10:44 +00:00
codereview.cfg [dev.regabi] codereview.cfg: add config for dev.regabi 2020-12-22 21:02:04 +00:00
CONTRIBUTING.md all: restore changes from faulty merge/revert 2018-02-12 20:13:59 +00:00
CONTRIBUTORS CONTRIBUTORS: update for the Go 1.15 release 2020-08-10 21:51:48 +00:00
favicon.ico website: recreate 16px and 32px favicon 2016-08-25 15:43:32 +00:00
LICENSE
PATENTS
README.md README: linkify some paths 2018-06-06 18:07:01 +00:00
robots.txt
SECURITY.md SECURITY.md: update go versions 2019-09-26 15:34:57 +00:00

The Go Programming Language

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

Gopher image Gopher image by Renee French, licensed under Creative Commons 3.0 Attributions license.

Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.

Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.

Download and Install

Binary Distributions

Official binary distributions are available at https://golang.org/dl/.

After downloading a binary release, visit https://golang.org/doc/install or load doc/install.html in your web browser for installation instructions.

Install From Source

If a binary distribution is not available for your combination of operating system and architecture, visit https://golang.org/doc/install/source or load doc/install-source.html in your web browser for source installation instructions.

Contributing

Go is the work of thousands of contributors. We appreciate your help!

To contribute, please read the contribution guidelines: https://golang.org/doc/contribute.html

Note that the Go project uses the issue tracker for bug reports and proposals only. See https://golang.org/wiki/Questions for a list of places to ask questions about the Go language.