1 // Copyright 2011 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.
5 // FILE UNDER CONSTRUCTION. ANY AND ALL PARTS MAY CHANGE.
6 // This file implements the universe and unsafe package scopes.
13 scope *ast.Scope // current scope to use for initialization
15 Unsafe *ast.Object // package unsafe
18 func define(kind ast.ObjKind, name string) *ast.Object {
19 obj := ast.NewObj(kind, name)
20 if scope.Insert(obj) != nil {
21 panic("types internal error: double declaration")
27 func defType(name string) *Name {
28 obj := define(ast.Typ, name)
29 typ := &Name{Underlying: &Basic{}, Obj: obj}
34 func defConst(name string) {
35 obj := define(ast.Con, name)
36 _ = obj // TODO(gri) fill in other properties
39 func defFun(name string) {
40 obj := define(ast.Fun, name)
41 _ = obj // TODO(gri) fill in other properties
53 scope = ast.NewScope(nil)
56 Bool = defType("bool")
57 defType("byte") // TODO(gri) should be an alias for uint8
58 defType("rune") // TODO(gri) should be an alias for int
60 Complex128 = defType("complex128")
63 Float64 = defType("float64")
68 String = defType("string")
98 scope = ast.NewScope(nil)
99 Unsafe = ast.NewObj(ast.Pkg, "unsafe")