[go.tools] push by g...@golang.org - go.tools/ssa: print identifer location if not found in TypeInfo... on 2013-05-25 17:04 GMT

0 views
Skip to first unread message

g...@googlecode.com

unread,
May 25, 2013, 1:05:16 PM5/25/13
to golang-...@googlegroups.com
Revision: a7fc50329a08
Branch: default
Author: Robert Griesemer <g...@golang.org>
Date: Sat May 25 10:04:20 2013
Log: go.tools/ssa: print identifer location if not found in TypeInfo

R=adonovan, r
CC=golang-dev
https://codereview.appspot.com/9703044
http://code.google.com/p/go/source/detail?r=a7fc50329a08&repo=tools

Modified:
/ssa/builder.go
/ssa/typeinfo.go

=======================================
--- /ssa/builder.go Wed May 22 14:56:18 2013
+++ /ssa/builder.go Sat May 25 10:04:20 2013
@@ -2471,6 +2471,7 @@
//
func (b *Builder) typecheck(importPath string, files []*ast.File)
(*types.Package, *TypeInfo, error) {
info := &TypeInfo{
+ fset: b.Prog.Files,
types: make(map[ast.Expr]types.Type),
idents: make(map[*ast.Ident]types.Object),
constants: make(map[ast.Expr]*Literal),
=======================================
--- /ssa/typeinfo.go Fri May 17 14:02:47 2013
+++ /ssa/typeinfo.go Sat May 25 10:04:20 2013
@@ -7,11 +7,13 @@
"code.google.com/p/go.tools/go/types"
"fmt"
"go/ast"
+ "go/token"
)

// TypeInfo contains information provided by the type checker about
// the abstract syntax for a single package.
type TypeInfo struct {
+ fset *token.FileSet
types map[ast.Expr]types.Type // inferred types of expressions
constants map[ast.Expr]*Literal // values of constant expressions
idents map[*ast.Ident]types.Object // canonical type objects for named
entities
@@ -51,7 +53,7 @@
if obj, ok := info.idents[id]; ok {
return obj
}
- panic(fmt.Sprintf("no types.Object for ast.Ident %s @ %p", id.Name, id))
+ panic(fmt.Sprintf("no types.Object for ast.Ident %s @ %s", id.Name,
info.fset.Position(id.Pos())))
}

// IsType returns true iff expression e denotes a type.
Reply all
Reply to author
Forward
0 new messages