return res
}
-func (r *decoder) rawValue() constant.Value {
+func (r *decoder) value() constant.Value {
+ r.sync(syncValue)
isComplex := r.bool()
val := r.scalar()
if isComplex {
}
}
-func (w *encoder) rawValue(val constant.Value) {
+func (w *encoder) value(val constant.Value) {
+ w.sync(syncValue)
if w.bool(val.Kind() == constant.Complex) {
w.scalar(constant.Real(val))
w.scalar(constant.Imag(val))
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
}
}
-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()
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))
package noder
import (
- "go/constant"
-
"cmd/compile/internal/base"
"cmd/compile/internal/syntax"
"cmd/compile/internal/types2"
case objConst:
pos := r.pos()
- typ, val := r.value()
+ typ := r.typ()
+ val := r.value()
return types2.NewConst(pos, objPkg, objName, typ, val)
case objFunc:
return objPkg, objName
}
-func (r *reader2) value() (types2.Type, constant.Value) {
- r.sync(syncValue)
- return r.typ(), r.rawValue()
-}
-
func (pr *pkgReader2) objDictIdx(idx int) *reader2Dict {
r := pr.newReader(relocObjDict, idx, syncObject1)
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:
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
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.