Update to current version of Go library.
[platform/upstream/gcc.git] / libgo / go / go / typechecker / universe.go
1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package typechecker
6
7 import "go/ast"
8
9 // TODO(gri) should this be in package ast?
10
11 // The Universe scope contains all predeclared identifiers.
12 var Universe *ast.Scope
13
14
15 func def(obj *ast.Object) {
16         alt := Universe.Insert(obj)
17         if alt != obj {
18                 panic("object declared twice")
19         }
20 }
21
22
23 func init() {
24         Universe = ast.NewScope(nil)
25
26         // basic types
27         for n, name := range BasicTypes {
28                 typ := NewType(Basic)
29                 typ.N = n
30                 obj := ast.NewObj(ast.Typ, name)
31                 obj.Type = typ
32                 typ.Obj = obj
33                 def(obj)
34         }
35
36         // built-in functions
37         // TODO(gri) implement this
38 }