go.tools/ssa: doc tweaks + a sanity check.

R=gri
CC=golang-dev
https://golang.org/cl/14454053
This commit is contained in:
Alan Donovan 2013-10-09 12:47:30 -04:00
parent 2299ac6bf3
commit e590cdbdf8
4 changed files with 13 additions and 5 deletions

View File

@ -16,7 +16,7 @@
// //
// The level of abstraction of the SSA form is intentionally close to // The level of abstraction of the SSA form is intentionally close to
// the source language to facilitate construction of source analysis // the source language to facilitate construction of source analysis
// tools. It is not primarily intended for machine code generation. // tools. It is not intended for machine code generation.
// //
// All looping, branching and switching constructs are replaced with // All looping, branching and switching constructs are replaced with
// unstructured control flow. We may add higher-level control flow // unstructured control flow. We may add higher-level control flow

View File

@ -368,8 +368,9 @@ func (f *Function) removeNilBlocks() {
} }
// SetDebugMode sets the debug mode for package pkg. If true, all its // SetDebugMode sets the debug mode for package pkg. If true, all its
// functions will include full debug info. This greatly increases // functions will include full debug info. This greatly increases the
// the size of the instruction stream. // size of the instruction stream, and causes Functions to depend upon
// the ASTs, potentially keeping them live in memory for longer.
// //
func (pkg *Package) SetDebugMode(debug bool) { func (pkg *Package) SetDebugMode(debug bool) {
// TODO(adonovan): do we want ast.File granularity? // TODO(adonovan): do we want ast.File granularity?

View File

@ -368,6 +368,11 @@ func (s *sanity) checkFunction(fn *Function) bool {
s.checkBlock(b, i) s.checkBlock(b, i)
} }
s.block = nil s.block = nil
for i, anon := range fn.AnonFuncs {
if anon.Enclosing != fn {
s.errorf("AnonFuncs[%d]=%s but %s.Enclosing=%s", i, anon, anon, anon.Enclosing)
}
}
s.fn = nil s.fn = nil
return !s.insane return !s.insane
} }

View File

@ -1147,8 +1147,10 @@ type MapUpdate struct {
// //
// DebugRef is a pseudo-instruction: it has no dynamic effect. // DebugRef is a pseudo-instruction: it has no dynamic effect.
// //
// Pos() returns Expr.Pos(), the position of the source-level // Pos() returns Expr.Pos(), the start position of the source-level
// expression. // expression. This is not the same as the "designated" token as
// documented at Value.Pos(). e.g. CallExpr.Pos() does not return the
// position of the ("designated") Lparen token.
// //
// Object() returns the source-level (var/const/func) object denoted // Object() returns the source-level (var/const/func) object denoted
// by Expr if it is an *ast.Ident; otherwise it is nil. // by Expr if it is an *ast.Ident; otherwise it is nil.