The exported Server becomes handlerServer, and part of Presentation
now. Presentation is also now an http.Handler with its own
internal mux (a detail, which might go away).
main.go becomes ever simpler.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/11505043
ssa:
- Prog.CreatePackages inlined into all callers.
- Prog.CreatePackage is now exposed; idempotent; and checks for errors.
- '*address' not 'address' now implements lvalue (since it's 6 words).
- removed types.Method case from createMemberFromObject.
importer:
- added importer.PackageInfo.String method.
- simplifed importer.PackageInfo by putting types.Info in it.
- removed obsolete precondition from IsType.
R=gri
CC=golang-dev
https://golang.org/cl/11408045
Allmost all uses of go/types that wanted the type
information computed, installed callback functions
that stored the information in maps. Most of the
time this is the only thing that could be done because
there is no guarantee that types are completely set
up before the end of type-checking.
This CL removes the respective Context callbacks in favor
of corresponding maps that collect the desired information
on demand, grouped together in an optional Info struct.
R=adonovan
CC=golang-dev
https://golang.org/cl/11530044
cmd/godoc/godoc.go is now merged into main.go, which is now
only 530 lines.
App Engine mode is still broken, but should be easy to fix up.
(just needs a global *godoc.Presentation created in init)
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/11498044
- fixed method set computation
- lazily compute it for a type on demand
- lazy allocation of various temporary maps
Also:
- removed Interface.IsEmpty, Scope.IsEmpty
(these convenience functions didn't carry their weight)
- cosmetic changes
Next:
- consolidate various lookup APIs
- use lazily computed method sets for various checks
instead of individual lookups
R=adonovan
CC=golang-dev
https://golang.org/cl/11385044
The plan for godoc:
- Copy godoc source from the core repo to go.tools (this CL).
- Break godoc into several packages inside go.tools, leaving a package
main that merely sets up a local file system, interprets the command
line, and otherwise delegates the heavy-lifting to the new packages.
- Remove godoc from the core repo.
- Update cmd/go to install this godoc binary in $GOROOT/bin.
- Update misc/dist to include godoc when building binary distributions.
R=bradfitz
CC=golang-dev
https://golang.org/cl/11408043
(Motivation: "Literal" is a syntactic property, not a semantic one.)
Also: delete a "TODO: opt" that the lifting pass already does for us.
R=gri
CC=golang-dev
https://golang.org/cl/11351043
- removed a number of obsolete TODO(gri) comments.
- bring ssa.DefaultType back into sync with types.defaultType.
- re-enable types.Package.Path()!="" assertion.
- use Path() (not reflect pointer) in sort routine.
- make interp.checkInterface use types.MissingMethod.
- un-export ssa.MakeId function.
- inline pointer() into all callers, and delete.
- enable two more interp_tests: $GOROOT/test/{method3,cmp}.go
- add links to bugs to other interp_tests.
- add runtime.NumCPU to ssa/interp/externals.go
R=gri
CC=golang-dev
https://golang.org/cl/11353043
- now represent ...T parameter type as []T (rather than T)
- simplified call checking
- added missing check and test for x... arguments (x must be slice)
This CL will temporarily break ssa and ssa/interp.
R=adonovan, axwalk
CC=golang-dev
https://golang.org/cl/11317043
Details:
- added support for complex numbers as distinct from floats:
%[efg] allows complex; %b does not.
- %p: only Signature, Map, Chan, Slice, unsafe.Pointer allowed.
- %s: allow []byte.
- allow a verb to match map[K]V and []T if it matches K/V/T,
e.g. %d now matches []int. i.e. matching is recursive.
- use go/types' constant folding. literal() is gone.
- group cases together.
Added tests.
R=gri, r
CC=golang-dev
https://golang.org/cl/10895043
This CL adds three new functions to determine the SSA Value
for a given syntactic var, func or const object:
Program.{Const,Func,Var}Value.
Since constants and functions are immutable, the first
two only need a types.Object; but each distinct
reference to a var may return a distinct Value, so the third
requires an ast.Ident parameter too.
Debug information for local vars is encoded in the
instruction stream in the form of DebugRef instructions,
which are a no-op but relate their operand to a particular
ident in the AST. The beauty of this approach is that it
naturally stays consistent during optimisation passes
(e.g. lifting) without additional bookkeeping.
DebugRef instructions are only generated if the DebugMode
builder flag is set; I plan to make the policy more fine-
grained (per function).
DebugRef instructions are inserted for:
- expr(Ident) for rvalue idents
- address.store() for idents that update an lvalue
- address.address() for idents that take address of lvalue
(this new method replaces all uses of lval.(address).addr)
- expr() for all constant expressions
- local ValueSpecs with implicit zero initialization (no RHS)
(this case doesn't call store() or address())
To ensure we don't forget to emit debug info for uses of Idents,
we must use the lvalue mechanism consistently. (Previously,
many simple cases had effectively inlined these functions.)
Similarly setCallFunc no longer inlines expr(Ident).
Also:
- Program.Value() has been inlined & specialized.
- Program.Package() has moved nearer the new lookup functions.
- refactoring: funcSyntax has lost paramFields, resultFields;
gained funcType, which provides access to both.
- add package-level constants to Package.values map.
- opt: don't call localValueSpec for constants.
(The resulting code is always optimised away.)
There are a number of comments asking whether Literals
should have positions. Will address in a follow-up.
Added tests of all interesting cases.
R=gri
CC=golang-dev
https://golang.org/cl/11259044
Objects:
- provide IsExported, SameName, uniqueName methods
- clean up a lot of dependent code
Scopes:
- don't add children to Universe scope (!)
- document Node, WriteTo
Types:
- remove Deref in favor of internal function deref
ssa, ssa/interp:
- introduced local deref, adjusted code
- fixed some "Underlying" bugs (pun intended)
R=adonovan
CC=golang-dev
https://golang.org/cl/11232043
Eval and EvalNode permit the evaluation of an expression
or type literal string (or AST node in case of EvalNode)
within a given context (package and scope).
Also:
- track nested (children) scopes for all scopes
- provide a mechanism to iterate over nested scopes
- permit recursive printing of scopes
TODO: more tests
R=adonovan
CC=golang-dev
https://golang.org/cl/10748044
Tested implictly since its simply calling the
internal isAssignableTo which is used in every
assignment when testing the std library.
R=adonovan
CC=golang-dev
https://golang.org/cl/11189043
This exposed a bug: we weren't creating Functions for methods
of imported named types.
Also:
- simplification: 'candidate' no longer contains 'concrete *Function'.
We look this up on demand.
NB: this CL contains a copy of CL 10935047 (use of typemap);
will submit/sync/resolve soon.
R=gri
CC=golang-dev
https://golang.org/cl/11051043
Yields a ~20% improvement in SSA construction time.
Also: better names for promotion wrapper functions.
R=gri
CC=golang-dev
https://golang.org/cl/11050043
go/types.Type has an equivalence relation (IsIdentical) that
is not consistent with the equivalence relation implemented by
Go's == operator for Types. Therefore extra work is required
to build a map whose keys are types. This package does that
work.
Has simple unit test. More tests might be good.
R=gri
CC=golang-dev
https://golang.org/cl/9649044
This requires a little more tree rewriting to put a block around the if of an "else if".
More tests too.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/11042045