mirror of
https://github.com/golang/go
synced 2024-11-18 18:44:42 -07:00
go.tools/ssa/interp: implement unary negation of complex numbers.
Fixes golang/go#6291. Also: call go/types.DefaultSizeof instead of hard-coding the initial value of runtime.sizeof_C_MStats. R=gri CC=golang-dev https://golang.org/cl/13648043
This commit is contained in:
parent
829240cc2e
commit
6bc6da88ec
@ -571,12 +571,9 @@ func Interpret(mainpkg *ssa.Package, mode Mode, filename string, args []string)
|
||||
setGlobal(i, pkg, "envs", envs)
|
||||
|
||||
case "runtime":
|
||||
// TODO(gri): expose go/types.sizeof so we can
|
||||
// avoid this fragile magic number;
|
||||
// unsafe.Sizeof(memStats) won't work since gc
|
||||
// and go/types have different sizeof
|
||||
// functions.
|
||||
setGlobal(i, pkg, "sizeof_C_MStats", uintptr(3696))
|
||||
// (Assumes no custom Sizeof used during SSA construction.)
|
||||
sz := types.DefaultSizeof(pkg.Object.Scope().Lookup("MemStats").Type())
|
||||
setGlobal(i, pkg, "sizeof_C_MStats", uintptr(sz))
|
||||
|
||||
case "os":
|
||||
Args := []value{filename}
|
||||
|
@ -797,6 +797,10 @@ func unop(instr *ssa.UnOp, x value) value {
|
||||
return -x
|
||||
case float64:
|
||||
return -x
|
||||
case complex64:
|
||||
return -x
|
||||
case complex128:
|
||||
return -x
|
||||
}
|
||||
case token.MUL:
|
||||
return copyVal(*x.(*value)) // load
|
||||
|
Loading…
Reference in New Issue
Block a user