summaryrefslogtreecommitdiff
path: root/libgo/go/go/typechecker/universe.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/go/typechecker/universe.go')
-rw-r--r--libgo/go/go/typechecker/universe.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/libgo/go/go/typechecker/universe.go b/libgo/go/go/typechecker/universe.go
new file mode 100644
index 000000000..db950737f
--- /dev/null
+++ b/libgo/go/go/typechecker/universe.go
@@ -0,0 +1,38 @@
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package typechecker
+
+import "go/ast"
+
+// TODO(gri) should this be in package ast?
+
+// The Universe scope contains all predeclared identifiers.
+var Universe *ast.Scope
+
+
+func def(obj *ast.Object) {
+ alt := Universe.Insert(obj)
+ if alt != obj {
+ panic("object declared twice")
+ }
+}
+
+
+func init() {
+ Universe = ast.NewScope(nil)
+
+ // basic types
+ for n, name := range ast.BasicTypes {
+ typ := ast.NewType(ast.Basic)
+ typ.N = n
+ obj := ast.NewObj(ast.Typ, name)
+ obj.Type = typ
+ typ.Obj = obj
+ def(obj)
+ }
+
+ // built-in functions
+ // TODO(gri) implement this
+}