mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
e30a09013b
commit
4c52eac49b
5 changed files with 14 additions and 26 deletions
|
|
@ -542,7 +542,8 @@ func (w *writer) doObj(obj types2.Object) codeObj {
|
|||
|
||||
case *types2.Const:
|
||||
w.pos(obj)
|
||||
w.value(obj.Type(), obj.Val())
|
||||
w.typ(obj.Type())
|
||||
w.value(obj.Val())
|
||||
return objConst
|
||||
|
||||
case *types2.Func:
|
||||
|
|
@ -598,12 +599,6 @@ func (w *writer) typExpr(expr syntax.Expr) {
|
|||
w.typ(tv.Type)
|
||||
}
|
||||
|
||||
func (w *writer) value(typ types2.Type, val constant.Value) {
|
||||
w.sync(syncValue)
|
||||
w.typ(typ)
|
||||
w.rawValue(val)
|
||||
}
|
||||
|
||||
// objDict writes the dictionary needed for reading the given object.
|
||||
func (w *writer) objDict(obj types2.Object, dict *writerDict) {
|
||||
// TODO(mdempsky): Split objDict into multiple entries? reader.go
|
||||
|
|
@ -1199,7 +1194,8 @@ func (w *writer) expr(expr syntax.Expr) {
|
|||
|
||||
w.code(exprConst)
|
||||
w.pos(pos)
|
||||
w.value(tv.Type, tv.Value)
|
||||
w.typ(tv.Type)
|
||||
w.value(tv.Value)
|
||||
|
||||
// TODO(mdempsky): These details are only important for backend
|
||||
// diagnostics. Explore writing them out separately.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue