1
0
mirror of https://github.com/golang/go synced 2024-11-18 20:24:41 -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) setGlobal(i, pkg, "envs", envs)
case "runtime": case "runtime":
// TODO(gri): expose go/types.sizeof so we can // (Assumes no custom Sizeof used during SSA construction.)
// avoid this fragile magic number; sz := types.DefaultSizeof(pkg.Object.Scope().Lookup("MemStats").Type())
// unsafe.Sizeof(memStats) won't work since gc setGlobal(i, pkg, "sizeof_C_MStats", uintptr(sz))
// and go/types have different sizeof
// functions.
setGlobal(i, pkg, "sizeof_C_MStats", uintptr(3696))
case "os": case "os":
Args := []value{filename} Args := []value{filename}

View File

@ -797,6 +797,10 @@ func unop(instr *ssa.UnOp, x value) value {
return -x return -x
case float64: case float64:
return -x return -x
case complex64:
return -x
case complex128:
return -x
} }
case token.MUL: case token.MUL:
return copyVal(*x.(*value)) // load return copyVal(*x.(*value)) // load