Steps towards tracking scopes for identifiers.

- Identifiers refer now to the language entity (Object)
	  that they denote. At the moment this is at best an
	  approximation.

	- Initial data structures for language entities (Objects)
          and expression types (Type) independent of the actual
	  type notations.

	- Initial support for declaring and looking up identifiers.

	- Updated various dependent files and added support functions.

	- Extensively tested to avoid breakage. This is an AST change.

R=rsc
CC=golang-dev, rog
https://golang.org/cl/189080
This commit is contained in:
Robert Griesemer 2010-01-15 13:27:45 -08:00
parent 67237c0f11
commit 01b4f2dd23
23 changed files with 250 additions and 252 deletions

View file

@ -559,7 +559,7 @@ func (c *typeConv) Type(dtype dwarf.Type) *Type {
t.Go = name // publish before recursive calls
switch dt.Kind {
case "union", "class":
c.typedef[name.Value] = c.Opaque(t.Size)
c.typedef[name.Name()] = c.Opaque(t.Size)
if t.C == "" {
t.C = fmt.Sprintf("typeof(unsigned char[%d])", t.Size)
}
@ -569,7 +569,7 @@ func (c *typeConv) Type(dtype dwarf.Type) *Type {
t.C = csyntax
}
t.Align = align
c.typedef[name.Value] = g
c.typedef[name.Name()] = g
}
case *dwarf.TypedefType:
@ -588,8 +588,8 @@ func (c *typeConv) Type(dtype dwarf.Type) *Type {
sub := c.Type(dt.Type)
t.Size = sub.Size
t.Align = sub.Align
if _, ok := c.typedef[name.Value]; !ok {
c.typedef[name.Value] = sub.Go
if _, ok := c.typedef[name.Name()]; !ok {
c.typedef[name.Name()] = sub.Go
}
case *dwarf.UcharType:
@ -633,7 +633,7 @@ func (c *typeConv) Type(dtype dwarf.Type) *Type {
}
s = strings.Join(strings.Split(s, " ", 0), "") // strip spaces
name := c.Ident("_C_" + s)
c.typedef[name.Value] = t.Go
c.typedef[name.Name()] = t.Go
t.Go = name
}
}
@ -710,7 +710,7 @@ func (c *typeConv) FuncType(dtype *dwarf.FuncType) *FuncType {
}
// Identifier
func (c *typeConv) Ident(s string) *ast.Ident { return &ast.Ident{Value: s} }
func (c *typeConv) Ident(s string) *ast.Ident { return ast.NewIdent(s) }
// Opaque type of n bytes.
func (c *typeConv) Opaque(n int64) ast.Expr {