summaryrefslogtreecommitdiff
path: root/src/pkg/go/typechecker/universe.go
blob: db950737f39f75362cf9397fc552ebe93f4328a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
}