aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder/codes.go
blob: f8cb7729acc2287a13f626d9ab8ce495701b6711 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// UNREVIEWED

// Copyright 2021 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 noder

type code interface {
	marker() syncMarker
	value() int
}

type codeVal int

func (c codeVal) marker() syncMarker { return syncVal }
func (c codeVal) value() int         { return int(c) }

const (
	valBool codeVal = iota
	valString
	valInt64
	valBigInt
	valBigRat
	valBigFloat
)

type codeType int

func (c codeType) marker() syncMarker { return syncType }
func (c codeType) value() int         { return int(c) }

const (
	typeBasic codeType = iota
	typeNamed
	typePointer
	typeSlice
	typeArray
	typeChan
	typeMap
	typeSignature
	typeStruct
	typeInterface
	typeUnion
	typeTypeParam
)

type codeObj int

func (c codeObj) marker() syncMarker { return syncCodeObj }
func (c codeObj) value() int         { return int(c) }

const (
	objAlias codeObj = iota
	objConst
	objType
	objFunc
	objVar
	objStub
)

type codeStmt int

func (c codeStmt) marker() syncMarker { return syncStmt1 }
func (c codeStmt) value() int         { return int(c) }

const (
	stmtEnd codeStmt = iota
	stmtLabel
	stmtBlock
	stmtExpr
	stmtSend
	stmtAssign
	stmtAssignOp
	stmtIncDec
	stmtBranch
	stmtCall
	stmtReturn
	stmtIf
	stmtFor
	stmtSwitch
	stmtSelect

	// TODO(mdempsky): Remove after we don't care about toolstash -cmp.
	stmtTypeDeclHack
)

type codeExpr int

func (c codeExpr) marker() syncMarker { return syncExpr }
func (c codeExpr) value() int         { return int(c) }

// TODO(mdempsky): Split expr into addr, for lvalues.
const (
	exprNone codeExpr = iota
	exprConst
	exprType  // type expression
	exprLocal // local variable
	exprName  // global variable or function
	exprBlank
	exprCompLit
	exprFuncLit
	exprSelector
	exprIndex
	exprSlice
	exprAssert
	exprUnaryOp
	exprBinaryOp
	exprCall
	exprConvert
)

type codeDecl int

func (c codeDecl) marker() syncMarker { return syncDecl }
func (c codeDecl) value() int         { return int(c) }

const (
	declEnd codeDecl = iota
	declFunc
	declMethod
	declVar
	declOther
)