/
basic_type.go
48 lines (41 loc) · 1.14 KB
/
basic_type.go
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
39
40
41
42
43
44
45
46
47
48
package rendering
import (
"go/ast"
"go/types"
)
var (
BasicBool = BasicLookup("bool")
BasicInt = BasicLookup("int")
BasicInt8 = BasicLookup("int8")
BasicInt16 = BasicLookup("int16")
BasicInt32 = BasicLookup("int32")
BasicInt64 = BasicLookup("int64")
BasicUint = BasicLookup("uint")
BasicUint8 = BasicLookup("uint8")
BasicUint16 = BasicLookup("uint16")
BasicUint32 = BasicLookup("uint32")
BasicUint64 = BasicLookup("uint64")
BasicUintptr = BasicLookup("uintptr")
BasicFloat32 = BasicLookup("float32")
BasicFloat64 = BasicLookup("float64")
BasicComplex64 = BasicLookup("complex64")
BasicComplex128 = BasicLookup("complex128")
BasicString = BasicLookup("string")
BasicByte = BasicLookup("byte")
BasicRune = BasicLookup("rune")
)
func BasicLookup(name string) types.Type {
return types.Universe.Lookup(name).Type()
}
type BasicType struct {
Underlying types.Type
}
func NewBasicType(t types.Type) Type {
return BasicType{
Underlying: t,
}
}
func (bt BasicType) Expr() ast.Expr {
return ast.NewIdent(bt.Underlying.String())
}
func (bt BasicType) isType() {}