diff --git a/ssa/interp/interp.go b/ssa/interp/interp.go index 2f206e0c..de37cdda 100644 --- a/ssa/interp/interp.go +++ b/ssa/interp/interp.go @@ -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} diff --git a/ssa/interp/ops.go b/ssa/interp/ops.go index 95c0a68b..432c5220 100644 --- a/ssa/interp/ops.go +++ b/ssa/interp/ops.go @@ -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