2016-03-11 15:22:21 -08:00
|
|
|
// Copyright 2009 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.
|
|
|
|
|
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
// TODO(gri) This file should probably become part of package types.
|
|
|
|
|
|
2016-03-11 15:22:21 -08:00
|
|
|
package gc
|
|
|
|
|
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
import "cmd/compile/internal/types"
|
|
|
|
|
|
2016-03-11 15:22:21 -08:00
|
|
|
// builtinpkg is a fake package that declares the universe block.
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
var builtinpkg *types.Pkg
|
2016-03-11 15:22:21 -08:00
|
|
|
|
|
|
|
|
var basicTypes = [...]struct {
|
|
|
|
|
name string
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
etype types.EType
|
2016-03-11 15:22:21 -08:00
|
|
|
}{
|
|
|
|
|
{"int8", TINT8},
|
|
|
|
|
{"int16", TINT16},
|
|
|
|
|
{"int32", TINT32},
|
|
|
|
|
{"int64", TINT64},
|
|
|
|
|
{"uint8", TUINT8},
|
|
|
|
|
{"uint16", TUINT16},
|
|
|
|
|
{"uint32", TUINT32},
|
|
|
|
|
{"uint64", TUINT64},
|
|
|
|
|
{"float32", TFLOAT32},
|
|
|
|
|
{"float64", TFLOAT64},
|
|
|
|
|
{"complex64", TCOMPLEX64},
|
|
|
|
|
{"complex128", TCOMPLEX128},
|
|
|
|
|
{"bool", TBOOL},
|
|
|
|
|
{"string", TSTRING},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var typedefs = [...]struct {
|
|
|
|
|
name string
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
etype types.EType
|
|
|
|
|
sameas32 types.EType
|
|
|
|
|
sameas64 types.EType
|
2016-03-11 15:22:21 -08:00
|
|
|
}{
|
2017-04-21 19:16:15 -07:00
|
|
|
{"int", TINT, TINT32, TINT64},
|
|
|
|
|
{"uint", TUINT, TUINT32, TUINT64},
|
|
|
|
|
{"uintptr", TUINTPTR, TUINT32, TUINT64},
|
2016-03-11 15:22:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var builtinFuncs = [...]struct {
|
|
|
|
|
name string
|
|
|
|
|
op Op
|
|
|
|
|
}{
|
|
|
|
|
{"append", OAPPEND},
|
|
|
|
|
{"cap", OCAP},
|
|
|
|
|
{"close", OCLOSE},
|
|
|
|
|
{"complex", OCOMPLEX},
|
|
|
|
|
{"copy", OCOPY},
|
|
|
|
|
{"delete", ODELETE},
|
|
|
|
|
{"imag", OIMAG},
|
|
|
|
|
{"len", OLEN},
|
|
|
|
|
{"make", OMAKE},
|
|
|
|
|
{"new", ONEW},
|
|
|
|
|
{"panic", OPANIC},
|
|
|
|
|
{"print", OPRINT},
|
|
|
|
|
{"println", OPRINTN},
|
|
|
|
|
{"real", OREAL},
|
|
|
|
|
{"recover", ORECOVER},
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-27 18:54:50 +00:00
|
|
|
// isBuiltinFuncName reports whether name matches a builtin function
|
|
|
|
|
// name.
|
|
|
|
|
func isBuiltinFuncName(name string) bool {
|
|
|
|
|
for _, fn := range builtinFuncs {
|
|
|
|
|
if fn.name == name {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-18 14:17:05 -07:00
|
|
|
var unsafeFuncs = [...]struct {
|
|
|
|
|
name string
|
|
|
|
|
op Op
|
|
|
|
|
}{
|
|
|
|
|
{"Alignof", OALIGNOF},
|
|
|
|
|
{"Offsetof", OOFFSETOF},
|
|
|
|
|
{"Sizeof", OSIZEOF},
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-11 15:22:21 -08:00
|
|
|
// initUniverse initializes the universe block.
|
|
|
|
|
func initUniverse() {
|
|
|
|
|
lexinit()
|
|
|
|
|
typeinit()
|
|
|
|
|
lexinit1()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// lexinit initializes known symbols and the basic types.
|
|
|
|
|
func lexinit() {
|
|
|
|
|
for _, s := range basicTypes {
|
|
|
|
|
etype := s.etype
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
if int(etype) >= len(types.Types) {
|
2016-03-11 15:22:21 -08:00
|
|
|
Fatalf("lexinit: %s bad etype", s.name)
|
|
|
|
|
}
|
2017-03-30 13:19:18 -07:00
|
|
|
s2 := builtinpkg.Lookup(s.name)
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
t := types.Types[etype]
|
2016-03-11 15:22:21 -08:00
|
|
|
if t == nil {
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
t = types.New(etype)
|
2016-03-11 15:22:21 -08:00
|
|
|
t.Sym = s2
|
|
|
|
|
if etype != TANY && etype != TSTRING {
|
|
|
|
|
dowidth(t)
|
|
|
|
|
}
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
types.Types[etype] = t
|
2016-03-11 15:22:21 -08:00
|
|
|
}
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
s2.Def = asTypesNode(typenod(t))
|
|
|
|
|
asNode(s2.Def).Name = new(Name)
|
2016-03-11 15:22:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, s := range builtinFuncs {
|
2017-03-30 13:19:18 -07:00
|
|
|
s2 := builtinpkg.Lookup(s.name)
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
s2.Def = asTypesNode(newname(s2))
|
2018-03-08 04:18:18 -08:00
|
|
|
asNode(s2.Def).SetSubOp(s.op)
|
2016-03-11 15:22:21 -08:00
|
|
|
}
|
|
|
|
|
|
2016-10-18 14:17:05 -07:00
|
|
|
for _, s := range unsafeFuncs {
|
2017-03-30 13:19:18 -07:00
|
|
|
s2 := unsafepkg.Lookup(s.name)
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
s2.Def = asTypesNode(newname(s2))
|
2018-03-08 04:18:18 -08:00
|
|
|
asNode(s2.Def).SetSubOp(s.op)
|
2016-10-18 14:17:05 -07:00
|
|
|
}
|
|
|
|
|
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
types.Idealstring = types.New(TSTRING)
|
|
|
|
|
types.Idealbool = types.New(TBOOL)
|
|
|
|
|
types.Types[TANY] = types.New(TANY)
|
2016-03-11 15:22:21 -08:00
|
|
|
|
2017-03-30 13:19:18 -07:00
|
|
|
s := builtinpkg.Lookup("true")
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
s.Def = asTypesNode(nodbool(true))
|
|
|
|
|
asNode(s.Def).Sym = lookup("true")
|
|
|
|
|
asNode(s.Def).Name = new(Name)
|
|
|
|
|
asNode(s.Def).Type = types.Idealbool
|
2016-03-11 15:22:21 -08:00
|
|
|
|
2017-03-30 13:19:18 -07:00
|
|
|
s = builtinpkg.Lookup("false")
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
s.Def = asTypesNode(nodbool(false))
|
|
|
|
|
asNode(s.Def).Sym = lookup("false")
|
|
|
|
|
asNode(s.Def).Name = new(Name)
|
|
|
|
|
asNode(s.Def).Type = types.Idealbool
|
2016-03-11 15:22:21 -08:00
|
|
|
|
2016-09-15 15:45:10 +10:00
|
|
|
s = lookup("_")
|
2016-03-11 15:22:21 -08:00
|
|
|
s.Block = -100
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
s.Def = asTypesNode(newname(s))
|
|
|
|
|
types.Types[TBLANK] = types.New(TBLANK)
|
|
|
|
|
asNode(s.Def).Type = types.Types[TBLANK]
|
|
|
|
|
nblank = asNode(s.Def)
|
2016-03-11 15:22:21 -08:00
|
|
|
|
2017-03-30 13:19:18 -07:00
|
|
|
s = builtinpkg.Lookup("_")
|
2016-03-11 15:22:21 -08:00
|
|
|
s.Block = -100
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
s.Def = asTypesNode(newname(s))
|
|
|
|
|
types.Types[TBLANK] = types.New(TBLANK)
|
|
|
|
|
asNode(s.Def).Type = types.Types[TBLANK]
|
2016-03-11 15:22:21 -08:00
|
|
|
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
types.Types[TNIL] = types.New(TNIL)
|
2017-03-30 13:19:18 -07:00
|
|
|
s = builtinpkg.Lookup("nil")
|
2016-03-11 15:22:21 -08:00
|
|
|
var v Val
|
|
|
|
|
v.U = new(NilVal)
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
s.Def = asTypesNode(nodlit(v))
|
|
|
|
|
asNode(s.Def).Sym = s
|
|
|
|
|
asNode(s.Def).Name = new(Name)
|
2016-03-11 15:22:21 -08:00
|
|
|
|
2017-03-30 13:19:18 -07:00
|
|
|
s = builtinpkg.Lookup("iota")
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
s.Def = asTypesNode(nod(OIOTA, nil, nil))
|
|
|
|
|
asNode(s.Def).Sym = s
|
|
|
|
|
asNode(s.Def).Name = new(Name)
|
2016-03-11 15:22:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func typeinit() {
|
|
|
|
|
if Widthptr == 0 {
|
|
|
|
|
Fatalf("typeinit before betypeinit")
|
|
|
|
|
}
|
|
|
|
|
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
for et := types.EType(0); et < NTYPE; et++ {
|
2016-09-16 00:33:29 +10:00
|
|
|
simtype[et] = et
|
2016-03-11 15:22:21 -08:00
|
|
|
}
|
|
|
|
|
|
2017-11-06 14:50:30 -08:00
|
|
|
types.Types[TPTR] = types.New(TPTR)
|
|
|
|
|
dowidth(types.Types[TPTR])
|
2016-03-11 15:22:21 -08:00
|
|
|
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
t := types.New(TUNSAFEPTR)
|
|
|
|
|
types.Types[TUNSAFEPTR] = t
|
2017-03-30 13:19:18 -07:00
|
|
|
t.Sym = unsafepkg.Lookup("Pointer")
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
t.Sym.Def = asTypesNode(typenod(t))
|
|
|
|
|
asNode(t.Sym.Def).Name = new(Name)
|
|
|
|
|
dowidth(types.Types[TUNSAFEPTR])
|
2016-03-11 15:22:21 -08:00
|
|
|
|
|
|
|
|
for et := TINT8; et <= TUINT64; et++ {
|
2016-09-16 00:33:29 +10:00
|
|
|
isInt[et] = true
|
2016-03-11 15:22:21 -08:00
|
|
|
}
|
2016-09-16 00:33:29 +10:00
|
|
|
isInt[TINT] = true
|
|
|
|
|
isInt[TUINT] = true
|
|
|
|
|
isInt[TUINTPTR] = true
|
2016-03-11 15:22:21 -08:00
|
|
|
|
2016-09-16 00:33:29 +10:00
|
|
|
isFloat[TFLOAT32] = true
|
|
|
|
|
isFloat[TFLOAT64] = true
|
2016-03-11 15:22:21 -08:00
|
|
|
|
2016-09-16 00:33:29 +10:00
|
|
|
isComplex[TCOMPLEX64] = true
|
|
|
|
|
isComplex[TCOMPLEX128] = true
|
2016-03-11 15:22:21 -08:00
|
|
|
|
|
|
|
|
// initialize okfor
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
for et := types.EType(0); et < NTYPE; et++ {
|
2016-09-16 00:33:29 +10:00
|
|
|
if isInt[et] || et == TIDEAL {
|
2016-03-11 15:22:21 -08:00
|
|
|
okforeq[et] = true
|
|
|
|
|
okforcmp[et] = true
|
|
|
|
|
okforarith[et] = true
|
|
|
|
|
okforadd[et] = true
|
|
|
|
|
okforand[et] = true
|
|
|
|
|
okforconst[et] = true
|
|
|
|
|
issimple[et] = true
|
2016-09-16 00:33:29 +10:00
|
|
|
minintval[et] = new(Mpint)
|
|
|
|
|
maxintval[et] = new(Mpint)
|
2016-03-11 15:22:21 -08:00
|
|
|
}
|
|
|
|
|
|
2016-09-16 00:33:29 +10:00
|
|
|
if isFloat[et] {
|
2016-03-11 15:22:21 -08:00
|
|
|
okforeq[et] = true
|
|
|
|
|
okforcmp[et] = true
|
|
|
|
|
okforadd[et] = true
|
|
|
|
|
okforarith[et] = true
|
|
|
|
|
okforconst[et] = true
|
|
|
|
|
issimple[et] = true
|
|
|
|
|
minfltval[et] = newMpflt()
|
|
|
|
|
maxfltval[et] = newMpflt()
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-16 00:33:29 +10:00
|
|
|
if isComplex[et] {
|
2016-03-11 15:22:21 -08:00
|
|
|
okforeq[et] = true
|
|
|
|
|
okforadd[et] = true
|
|
|
|
|
okforarith[et] = true
|
|
|
|
|
okforconst[et] = true
|
|
|
|
|
issimple[et] = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
issimple[TBOOL] = true
|
|
|
|
|
|
|
|
|
|
okforadd[TSTRING] = true
|
|
|
|
|
|
|
|
|
|
okforbool[TBOOL] = true
|
|
|
|
|
|
|
|
|
|
okforcap[TARRAY] = true
|
|
|
|
|
okforcap[TCHAN] = true
|
2016-04-18 14:02:08 -07:00
|
|
|
okforcap[TSLICE] = true
|
2016-03-11 15:22:21 -08:00
|
|
|
|
|
|
|
|
okforconst[TBOOL] = true
|
|
|
|
|
okforconst[TSTRING] = true
|
|
|
|
|
|
|
|
|
|
okforlen[TARRAY] = true
|
|
|
|
|
okforlen[TCHAN] = true
|
|
|
|
|
okforlen[TMAP] = true
|
2016-04-18 14:02:08 -07:00
|
|
|
okforlen[TSLICE] = true
|
2016-03-11 15:22:21 -08:00
|
|
|
okforlen[TSTRING] = true
|
|
|
|
|
|
2017-11-06 14:50:30 -08:00
|
|
|
okforeq[TPTR] = true
|
2016-03-11 15:22:21 -08:00
|
|
|
okforeq[TUNSAFEPTR] = true
|
|
|
|
|
okforeq[TINTER] = true
|
|
|
|
|
okforeq[TCHAN] = true
|
|
|
|
|
okforeq[TSTRING] = true
|
|
|
|
|
okforeq[TBOOL] = true
|
|
|
|
|
okforeq[TMAP] = true // nil only; refined in typecheck
|
|
|
|
|
okforeq[TFUNC] = true // nil only; refined in typecheck
|
2016-04-18 14:02:08 -07:00
|
|
|
okforeq[TSLICE] = true // nil only; refined in typecheck
|
|
|
|
|
okforeq[TARRAY] = true // only if element type is comparable; refined in typecheck
|
|
|
|
|
okforeq[TSTRUCT] = true // only if all struct fields are comparable; refined in typecheck
|
2016-03-11 15:22:21 -08:00
|
|
|
|
|
|
|
|
okforcmp[TSTRING] = true
|
|
|
|
|
|
|
|
|
|
var i int
|
|
|
|
|
for i = 0; i < len(okfor); i++ {
|
|
|
|
|
okfor[i] = okfornone[:]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// binary
|
|
|
|
|
okfor[OADD] = okforadd[:]
|
|
|
|
|
okfor[OAND] = okforand[:]
|
|
|
|
|
okfor[OANDAND] = okforbool[:]
|
|
|
|
|
okfor[OANDNOT] = okforand[:]
|
|
|
|
|
okfor[ODIV] = okforarith[:]
|
|
|
|
|
okfor[OEQ] = okforeq[:]
|
|
|
|
|
okfor[OGE] = okforcmp[:]
|
|
|
|
|
okfor[OGT] = okforcmp[:]
|
|
|
|
|
okfor[OLE] = okforcmp[:]
|
|
|
|
|
okfor[OLT] = okforcmp[:]
|
|
|
|
|
okfor[OMOD] = okforand[:]
|
|
|
|
|
okfor[OMUL] = okforarith[:]
|
|
|
|
|
okfor[ONE] = okforeq[:]
|
|
|
|
|
okfor[OOR] = okforand[:]
|
|
|
|
|
okfor[OOROR] = okforbool[:]
|
|
|
|
|
okfor[OSUB] = okforarith[:]
|
|
|
|
|
okfor[OXOR] = okforand[:]
|
|
|
|
|
okfor[OLSH] = okforand[:]
|
|
|
|
|
okfor[ORSH] = okforand[:]
|
|
|
|
|
|
|
|
|
|
// unary
|
2018-11-18 08:34:38 -08:00
|
|
|
okfor[OBITNOT] = okforand[:]
|
|
|
|
|
okfor[ONEG] = okforarith[:]
|
2016-03-11 15:22:21 -08:00
|
|
|
okfor[ONOT] = okforbool[:]
|
|
|
|
|
okfor[OPLUS] = okforarith[:]
|
|
|
|
|
|
|
|
|
|
// special
|
|
|
|
|
okfor[OCAP] = okforcap[:]
|
|
|
|
|
okfor[OLEN] = okforlen[:]
|
|
|
|
|
|
|
|
|
|
// comparison
|
|
|
|
|
iscmp[OLT] = true
|
|
|
|
|
iscmp[OGT] = true
|
|
|
|
|
iscmp[OGE] = true
|
|
|
|
|
iscmp[OLE] = true
|
|
|
|
|
iscmp[OEQ] = true
|
|
|
|
|
iscmp[ONE] = true
|
|
|
|
|
|
2016-09-16 00:33:29 +10:00
|
|
|
maxintval[TINT8].SetString("0x7f")
|
|
|
|
|
minintval[TINT8].SetString("-0x80")
|
|
|
|
|
maxintval[TINT16].SetString("0x7fff")
|
|
|
|
|
minintval[TINT16].SetString("-0x8000")
|
|
|
|
|
maxintval[TINT32].SetString("0x7fffffff")
|
|
|
|
|
minintval[TINT32].SetString("-0x80000000")
|
|
|
|
|
maxintval[TINT64].SetString("0x7fffffffffffffff")
|
|
|
|
|
minintval[TINT64].SetString("-0x8000000000000000")
|
2016-03-20 13:55:42 -07:00
|
|
|
|
2016-09-16 00:33:29 +10:00
|
|
|
maxintval[TUINT8].SetString("0xff")
|
|
|
|
|
maxintval[TUINT16].SetString("0xffff")
|
|
|
|
|
maxintval[TUINT32].SetString("0xffffffff")
|
|
|
|
|
maxintval[TUINT64].SetString("0xffffffffffffffff")
|
2016-03-11 15:22:21 -08:00
|
|
|
|
|
|
|
|
// f is valid float if min < f < max. (min and max are not themselves valid.)
|
2016-03-20 13:55:42 -07:00
|
|
|
maxfltval[TFLOAT32].SetString("33554431p103") // 2^24-1 p (127-23) + 1/2 ulp
|
|
|
|
|
minfltval[TFLOAT32].SetString("-33554431p103")
|
|
|
|
|
maxfltval[TFLOAT64].SetString("18014398509481983p970") // 2^53-1 p (1023-52) + 1/2 ulp
|
|
|
|
|
minfltval[TFLOAT64].SetString("-18014398509481983p970")
|
2016-03-11 15:22:21 -08:00
|
|
|
|
|
|
|
|
maxfltval[TCOMPLEX64] = maxfltval[TFLOAT32]
|
|
|
|
|
minfltval[TCOMPLEX64] = minfltval[TFLOAT32]
|
|
|
|
|
maxfltval[TCOMPLEX128] = maxfltval[TFLOAT64]
|
|
|
|
|
minfltval[TCOMPLEX128] = minfltval[TFLOAT64]
|
|
|
|
|
|
2019-09-06 16:05:36 -07:00
|
|
|
types.Types[TINTER] = types.New(TINTER) // empty interface
|
2016-03-11 15:22:21 -08:00
|
|
|
|
|
|
|
|
// simple aliases
|
2017-11-06 14:50:30 -08:00
|
|
|
simtype[TMAP] = TPTR
|
|
|
|
|
simtype[TCHAN] = TPTR
|
|
|
|
|
simtype[TFUNC] = TPTR
|
|
|
|
|
simtype[TUNSAFEPTR] = TPTR
|
2016-03-11 15:22:21 -08:00
|
|
|
|
2016-09-16 00:33:29 +10:00
|
|
|
array_array = int(Rnd(0, int64(Widthptr)))
|
2017-04-21 18:44:34 -07:00
|
|
|
array_nel = int(Rnd(int64(array_array)+int64(Widthptr), int64(Widthptr)))
|
|
|
|
|
array_cap = int(Rnd(int64(array_nel)+int64(Widthptr), int64(Widthptr)))
|
|
|
|
|
sizeof_Array = int(Rnd(int64(array_cap)+int64(Widthptr), int64(Widthptr)))
|
2016-03-11 15:22:21 -08:00
|
|
|
|
|
|
|
|
// string is same as slice wo the cap
|
2017-04-21 18:44:34 -07:00
|
|
|
sizeof_String = int(Rnd(int64(array_nel)+int64(Widthptr), int64(Widthptr)))
|
2016-03-11 15:22:21 -08:00
|
|
|
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
dowidth(types.Types[TSTRING])
|
|
|
|
|
dowidth(types.Idealstring)
|
2016-03-11 15:22:21 -08:00
|
|
|
}
|
|
|
|
|
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
func makeErrorInterface() *types.Type {
|
|
|
|
|
field := types.NewField()
|
|
|
|
|
field.Type = types.Types[TSTRING]
|
2017-04-24 22:17:03 -07:00
|
|
|
f := functypefield(fakeRecvField(), nil, []*types.Field{field})
|
2016-03-13 23:02:38 -07:00
|
|
|
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
field = types.NewField()
|
2016-09-15 15:45:10 +10:00
|
|
|
field.Sym = lookup("Error")
|
2016-03-13 23:02:38 -07:00
|
|
|
field.Type = f
|
2016-03-11 15:22:21 -08:00
|
|
|
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
t := types.New(TINTER)
|
|
|
|
|
t.SetInterface([]*types.Field{field})
|
2016-06-01 13:46:49 -07:00
|
|
|
return t
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func lexinit1() {
|
2016-03-11 15:22:21 -08:00
|
|
|
// error type
|
2017-03-30 13:19:18 -07:00
|
|
|
s := builtinpkg.Lookup("error")
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
types.Errortype = makeErrorInterface()
|
|
|
|
|
types.Errortype.Sym = s
|
2017-09-05 18:49:36 -07:00
|
|
|
types.Errortype.Orig = makeErrorInterface()
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
s.Def = asTypesNode(typenod(types.Errortype))
|
2018-12-20 11:10:06 -08:00
|
|
|
dowidth(types.Errortype)
|
2016-03-11 15:22:21 -08:00
|
|
|
|
2017-01-12 15:21:21 -08:00
|
|
|
// We create separate byte and rune types for better error messages
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
// rather than just creating type alias *types.Sym's for the uint8 and
|
2017-01-12 15:21:21 -08:00
|
|
|
// int32 types. Hence, (bytetype|runtype).Sym.isAlias() is false.
|
|
|
|
|
// TODO(gri) Should we get rid of this special case (at the cost
|
|
|
|
|
// of less informative error messages involving bytes and runes)?
|
|
|
|
|
// (Alternatively, we could introduce an OTALIAS node representing
|
|
|
|
|
// type aliases, albeit at the cost of having to deal with it everywhere).
|
|
|
|
|
|
2016-03-11 15:22:21 -08:00
|
|
|
// byte alias
|
2017-03-30 13:19:18 -07:00
|
|
|
s = builtinpkg.Lookup("byte")
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
types.Bytetype = types.New(TUINT8)
|
|
|
|
|
types.Bytetype.Sym = s
|
|
|
|
|
s.Def = asTypesNode(typenod(types.Bytetype))
|
|
|
|
|
asNode(s.Def).Name = new(Name)
|
2018-12-20 11:10:06 -08:00
|
|
|
dowidth(types.Bytetype)
|
2016-03-11 15:22:21 -08:00
|
|
|
|
|
|
|
|
// rune alias
|
2017-03-30 13:19:18 -07:00
|
|
|
s = builtinpkg.Lookup("rune")
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
types.Runetype = types.New(TINT32)
|
|
|
|
|
types.Runetype.Sym = s
|
|
|
|
|
s.Def = asTypesNode(typenod(types.Runetype))
|
|
|
|
|
asNode(s.Def).Name = new(Name)
|
2018-12-20 11:10:06 -08:00
|
|
|
dowidth(types.Runetype)
|
2016-03-11 15:22:21 -08:00
|
|
|
|
|
|
|
|
// backend-dependent builtin types (e.g. int).
|
|
|
|
|
for _, s := range typedefs {
|
2017-03-30 13:19:18 -07:00
|
|
|
s1 := builtinpkg.Lookup(s.name)
|
2016-03-11 15:22:21 -08:00
|
|
|
|
|
|
|
|
sameas := s.sameas32
|
2017-04-21 19:16:15 -07:00
|
|
|
if Widthptr == 8 {
|
2016-03-11 15:22:21 -08:00
|
|
|
sameas = s.sameas64
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-16 00:33:29 +10:00
|
|
|
simtype[s.etype] = sameas
|
2016-03-11 15:22:21 -08:00
|
|
|
minfltval[s.etype] = minfltval[sameas]
|
|
|
|
|
maxfltval[s.etype] = maxfltval[sameas]
|
2016-09-16 00:33:29 +10:00
|
|
|
minintval[s.etype] = minintval[sameas]
|
|
|
|
|
maxintval[s.etype] = maxintval[sameas]
|
2016-03-11 15:22:21 -08:00
|
|
|
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
t := types.New(s.etype)
|
2016-03-11 15:22:21 -08:00
|
|
|
t.Sym = s1
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
types.Types[s.etype] = t
|
|
|
|
|
s1.Def = asTypesNode(typenod(t))
|
|
|
|
|
asNode(s1.Def).Name = new(Name)
|
2016-03-11 15:22:21 -08:00
|
|
|
s1.Origpkg = builtinpkg
|
|
|
|
|
|
|
|
|
|
dowidth(t)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// finishUniverse makes the universe block visible within the current package.
|
|
|
|
|
func finishUniverse() {
|
|
|
|
|
// Operationally, this is similar to a dot import of builtinpkg, except
|
|
|
|
|
// that we silently skip symbols that are already declared in the
|
|
|
|
|
// package block rather than emitting a redeclared symbol error.
|
|
|
|
|
|
|
|
|
|
for _, s := range builtinpkg.Syms {
|
2016-10-19 12:58:16 -07:00
|
|
|
if s.Def == nil {
|
2016-03-11 15:22:21 -08:00
|
|
|
continue
|
|
|
|
|
}
|
2016-09-15 15:45:10 +10:00
|
|
|
s1 := lookup(s.Name)
|
2016-03-11 15:22:21 -08:00
|
|
|
if s1.Def != nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s1.Def = s.Def
|
|
|
|
|
s1.Block = s.Block
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-08 21:00:36 +00:00
|
|
|
nodfp = newname(lookup(".fp"))
|
|
|
|
|
nodfp.Type = types.Types[TINT32]
|
|
|
|
|
nodfp.SetClass(PPARAM)
|
|
|
|
|
nodfp.Name.SetUsed(true)
|
2016-03-11 15:22:21 -08:00
|
|
|
}
|