1
2
3
4
5 package ir
6
7 import (
8 "cmd/compile/internal/base"
9 "cmd/compile/internal/types"
10 "cmd/internal/src"
11 )
12
13
14
15
16 type typeNode struct {
17 miniNode
18 typ *types.Type
19 }
20
21 func newTypeNode(typ *types.Type) *typeNode {
22 n := &typeNode{typ: typ}
23 n.pos = src.NoXPos
24 n.op = OTYPE
25 n.SetTypecheck(1)
26 return n
27 }
28
29 func (n *typeNode) Type() *types.Type { return n.typ }
30 func (n *typeNode) Sym() *types.Sym { return n.typ.Sym() }
31
32
33 func TypeNode(t *types.Type) Node {
34 if n := t.Obj(); n != nil {
35 if n.Type() != t {
36 base.Fatalf("type skew: %v has type %v, but expected %v", n, n.Type(), t)
37 }
38 return n.(*Name)
39 }
40 return newTypeNode(t)
41 }
42
43
44
45 type DynamicType struct {
46 miniExpr
47
48
49
50
51
52 RType Node
53
54
55
56
57
58
59
60
61 ITab Node
62 }
63
64 func NewDynamicType(pos src.XPos, rtype Node) *DynamicType {
65 n := &DynamicType{RType: rtype}
66 n.pos = pos
67 n.op = ODYNAMICTYPE
68 return n
69 }
70
View as plain text