1
0
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:
Alan Donovan 2013-09-10 12:08:55 -04:00
parent 829240cc2e
commit 6bc6da88ec
2 changed files with 7 additions and 6 deletions

View File

@ -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}

View File

@ -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