diff options
Diffstat (limited to 'src/cmd/compile/internal/noder/codes.go')
-rw-r--r-- | src/cmd/compile/internal/noder/codes.go | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/noder/codes.go b/src/cmd/compile/internal/noder/codes.go new file mode 100644 index 0000000..c1ee8d1 --- /dev/null +++ b/src/cmd/compile/internal/noder/codes.go @@ -0,0 +1,87 @@ +// 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 + +import "internal/pkgbits" + +// A codeStmt distinguishes among statement encodings. +type codeStmt int + +func (c codeStmt) Marker() pkgbits.SyncMarker { return pkgbits.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 +) + +// A codeExpr distinguishes among expression encodings. +type codeExpr int + +func (c codeExpr) Marker() pkgbits.SyncMarker { return pkgbits.SyncExpr } +func (c codeExpr) Value() int { return int(c) } + +// TODO(mdempsky): Split expr into addr, for lvalues. +const ( + exprConst codeExpr = iota + exprLocal // local variable + exprGlobal // global variable or function + exprCompLit + exprFuncLit + exprFieldVal + exprMethodVal + exprMethodExpr + exprIndex + exprSlice + exprAssert + exprUnaryOp + exprBinaryOp + exprCall + exprConvert + exprNew + exprMake + exprNil + exprFuncInst + exprRecv + exprReshape +) + +type codeAssign int + +func (c codeAssign) Marker() pkgbits.SyncMarker { return pkgbits.SyncAssign } +func (c codeAssign) Value() int { return int(c) } + +const ( + assignBlank codeAssign = iota + assignDef + assignExpr +) + +// A codeDecl distinguishes among declaration encodings. +type codeDecl int + +func (c codeDecl) Marker() pkgbits.SyncMarker { return pkgbits.SyncDecl } +func (c codeDecl) Value() int { return int(c) } + +const ( + declEnd codeDecl = iota + declFunc + declMethod + declVar + declOther +) |