aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder/codes.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2022-02-14 09:41:19 -0800
committerMatthew Dempsky <mdempsky@google.com>2022-03-01 07:36:05 +0000
commit7c151f328056c354d3db13c17b3d96bec316cff6 (patch)
tree01327d059a54a85d4cfe4f83bdcefeb2626d6c9f /src/cmd/compile/internal/noder/codes.go
parent6d881da9c894dfcd8c3dda0057a7c63a3ab59ea2 (diff)
downloadgo-7c151f328056c354d3db13c17b3d96bec316cff6.tar.xz
internal/pkgbits: extract unified IR coding-level logic
This logic is needed for the go/types unified IR importer, so extract it into a separate internal package so we can reuse a single copy. Change-Id: I5f734b76e580fdb69ee39e45ac553c22d01c5909 Reviewed-on: https://go-review.googlesource.com/c/go/+/386000 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/noder/codes.go')
-rw-r--r--src/cmd/compile/internal/noder/codes.go65
1 files changed, 7 insertions, 58 deletions
diff --git a/src/cmd/compile/internal/noder/codes.go b/src/cmd/compile/internal/noder/codes.go
index f8cb7729ac..bc0831dd78 100644
--- a/src/cmd/compile/internal/noder/codes.go
+++ b/src/cmd/compile/internal/noder/codes.go
@@ -6,63 +6,12 @@
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
-)
+import "internal/pkgbits"
type codeStmt int
-func (c codeStmt) marker() syncMarker { return syncStmt1 }
-func (c codeStmt) value() int { return int(c) }
+func (c codeStmt) Marker() pkgbits.SyncMarker { return pkgbits.SyncStmt1 }
+func (c codeStmt) Value() int { return int(c) }
const (
stmtEnd codeStmt = iota
@@ -87,8 +36,8 @@ const (
type codeExpr int
-func (c codeExpr) marker() syncMarker { return syncExpr }
-func (c codeExpr) value() int { return int(c) }
+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 (
@@ -112,8 +61,8 @@ const (
type codeDecl int
-func (c codeDecl) marker() syncMarker { return syncDecl }
-func (c codeDecl) value() int { return int(c) }
+func (c codeDecl) Marker() pkgbits.SyncMarker { return pkgbits.SyncDecl }
+func (c codeDecl) Value() int { return int(c) }
const (
declEnd codeDecl = iota