1
0
mirror of https://github.com/golang/go synced 2024-10-01 16:38:34 -06:00
Commit Graph

12 Commits

Author SHA1 Message Date
Alan Donovan
713699d8ad go.tools: add copyright messages to source files.
R=r
CC=golang-dev
https://golang.org/cl/13305043
2013-08-27 18:49:13 -04:00
Alan Donovan
99ac9493e1 go.types/ssa: add back Signature.Recv to interface method wrappers.
It is needed after all, as I discovered in the pointer analysis.
(ssa needs more API test coverage.)

Also:
- sanity: remove debugging cruft
- promote: don't redundantly include the function's
  own name in its Synthetic string.
- print: IntuitiveMethodSet utility fixes a bug in the
  printing logic (for interface types, mset(*T) is empty).
  The function is also used by the Oracle.

R=crawshaw
CC=golang-dev
https://golang.org/cl/13116043
2013-08-20 14:50:13 -04:00
Alan Donovan
7072253af5 go.tools/ssa: fixes, cleanups, cosmetic tweaks.
Fix bug: the Signature for an interface method wrapper
erroneously had a non-nil receiver.

Function:
- Set Pkg field non-nil even for wrappers.
  It is equal to that of the wrapped function.
  Only wrappers of error.Error
  (and its embeddings in other interfaces) may have nil.
  Sanity checker now asserts this.
- FullName() now uses .Synthetic field to discriminate
  synthetic methods, not Pkg==nil.
- Fullname() uses new relType() utility to print receiver type
  name unqualified if it belongs to the same package.
  (Alloc.String also uses relType utility.)

CallCommon:
- Description(): fix switch logic broken when we
  eliminated the Recv field.
- better docs.

R=david.crawshaw, crawshaw, gri
CC=golang-dev
https://golang.org/cl/13057043
2013-08-19 15:38:30 -04:00
Alan Donovan
61a33ecd43 go.tools/go/types: fix: the type of a method value should not have a reciever
e.g.
type T int
func (T) f() {}
var t T
_ = t.f  // method value: should have signature "func()", no receiver

Also:
- ssa: add sanity check that helped diagnose this.

R=gri
CC=golang-dev
https://golang.org/cl/12283043
2013-08-01 15:38:41 -04:00
Alan Donovan
732dbe9ff8 go.tools/ssa: s/Literal/Const/g, s/Constant/NamedConst/g
(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
2013-07-16 13:50:08 -04:00
Alan Donovan
55d678e697 go.tools/ssa: add debug information for all ast.Idents.
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
2013-07-15 13:56:46 -04:00
Alan Donovan
bc1f724aa4 go.tools/ssa: Member.Object() returns typechecker object for package members.
Also:
- {Must,}SanityCheck un-exported.  Added sanityCheckPackage.

R=gri
CC=golang-dev
https://golang.org/cl/11174043
2013-07-11 14:12:30 -04:00
Alan Donovan
8846992823 go.tools/ssa: avoid redundant uint64 conversion of right operand of <<, >>.
Also: add sanity check that no Instruction yields a Value of 'untyped' type.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/11011043
2013-07-08 17:33:51 -04:00
Alan Donovan
8097dad724 go.tools/ssa: Select now returns received values by tuple, not interface.
Before, all values received on some channel by Select would
flow to an empty interface, creating a spurious confluence for
flow analyses.  Now, the tuple returned by Select has one
component for each 'receive' case.

Also, fixes:
- Removed workarounds for now-fixed typechecker bug in FuncLit+TypeAssert.
- sanity check that all Value Instructions have non-nil Type().
- Convert: document and sanity-check that at least one of the types is basic.

Also, other things to help clients:
- Define CallInstruction interface: common parts of Call, Go, Defer.
- Add CallCommon.Signature() method.
- Literal.Pos() is now populated.

R=gri
CC=golang-dev
https://golang.org/cl/10505043
2013-06-24 14:15:13 -04:00
Alan Donovan
341a07a3aa go.tools/ssa: small changes accumulated during gri's vacation. :)
Method sets:
- Simplify CallCommon.
  Avoid the implicit copy when calling a T method on a *T
  receiver.  This simplifies clients.  Instead we generate
  "indirection wrapper" functions that do this (like gc does).
  New invariant:
  m's receiver type is exactly T for all m in MethodSet(T)
- MakeInterface no longer holds the concrete type's MethodSet.
  We can defer its computation this way.
- ssa.Type now just wraps a types.TypeName object.
  MethodSets are computed as needed, not eagerly.

Position info:
- new CanonicalPos utility maps ast.Expr to canonical
  token.Pos, as returned by {Instruction,Value}.Pos() methods.
- Don't set posn for implicit operations (e.g. varargs array alloc)
- Set position info for ChangeInterface and Slice instructions.

Cosmetic:
- add Member.Token() method
- simplify isPointer
- Omit words "interface", "slice" when printing MakeInterface,
  MakeSlice; the type is enough.
- Comments on PathEnclosingInterval.
- Remove Function.FullName() where implicit String() suffices.

Also:
- Exposed NewLiteral to clients.
- Added ssa.Instruction.Parent() *Function
  Added ssa.BasicBlock.Parent() *Function.
  Added Sanity checks for above.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/10166045
2013-06-13 14:43:35 -04:00
Rob Pike
87334f402b go.tools: bring up to date
Repo was copied from old point.  Bad r.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/9504043
2013-05-17 14:02:47 -07:00
Rob Pike
83f21b9226 go.tools: add missing files ssa/*.go
R=golang-dev, adonovan
CC=golang-dev
https://golang.org/cl/9500043
2013-05-17 13:25:48 -07:00