aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder/reader.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-09-07 13:23:08 -0700
committerMatthew Dempsky <mdempsky@google.com>2021-09-09 00:29:35 +0000
commit4c52eac49b7e3f2a107419583012e5251ccbfde9 (patch)
tree4d2065f74e7b06dd8ff073f1d2c78ad6219b8839 /src/cmd/compile/internal/noder/reader.go
parente30a09013b24853cbe6d3d3a919e639df0bdf41c (diff)
downloadgo-4c52eac49b7e3f2a107419583012e5251ccbfde9.tar.xz
cmd/compile: simplify value coding for unified IR
In indexed export, values are always exported along with their type and are encoded in a type-sensitive manner, because this matches how cmd/compile handled constants internally. However, go/types intentionally differs from this, decoupling type from value representation. As unified IR strives to be more go/types-centric, it makes sense to embrace this and make values a more first-class encoding. Change-Id: If21d849c4f610358bd776d5665469d180bcd5f6e Reviewed-on: https://go-review.googlesource.com/c/go/+/348014 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src/cmd/compile/internal/noder/reader.go')
-rw-r--r--src/cmd/compile/internal/noder/reader.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/cmd/compile/internal/noder/reader.go b/src/cmd/compile/internal/noder/reader.go
index b3cb10dadb..e235dd5792 100644
--- a/src/cmd/compile/internal/noder/reader.go
+++ b/src/cmd/compile/internal/noder/reader.go
@@ -626,7 +626,8 @@ func (pr *pkgReader) objIdx(idx int, implicits, explicits []*types.Type) ir.Node
case objConst:
name := do(ir.OLITERAL, false)
- typ, val := r.value()
+ typ := r.typ()
+ val := FixValue(typ, r.value())
setType(name, typ)
setValue(name, val)
return name
@@ -755,12 +756,6 @@ func (r *reader) typeParamNames() {
}
}
-func (r *reader) value() (*types.Type, constant.Value) {
- r.sync(syncValue)
- typ := r.typ()
- return typ, FixValue(typ, r.rawValue())
-}
-
func (r *reader) method() *types.Field {
r.sync(syncMethod)
pos := r.pos()
@@ -1556,7 +1551,8 @@ func (r *reader) expr() (res ir.Node) {
case exprConst:
pos := r.pos()
- typ, val := r.value()
+ typ := r.typ()
+ val := FixValue(typ, r.value())
op := r.op()
orig := r.string()
return typecheck.Expr(OrigConst(pos, typ, val, op, orig))