go/src/pkg/exp/ssa/interp/external_unix.go
Alan Donovan aa5aaabb0d exp/ssa/interp: (#6 of 5): test interpretation of SSA form of $GOROOT/test/*.go.
The interpreter's os.Exit now triggers a special panic rather
than kill the test process.  (It's semantically dubious, since
it will run deferred routines.)  Interpret now returns its
exit code rather than calling os.Exit.

Also:
- disabled parts of a few $GOROOT/tests via os.Getenv("GOSSAINTERP").
- remove unnecessary 'slots' param to external functions; they
  are never closures.

Most of the tests are disabled until go/types supports shifts.
They can be reenabled if you patch this workaround:
https://golang.org/cl/7312068

R=iant, bradfitz
CC=golang-dev, gri
https://golang.org/cl/7313062
2013-02-21 12:48:38 -05:00

32 lines
934 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build !windows,!plan9
package interp
import (
"exp/ssa"
"syscall"
)
func ext۰syscall۰Kill(fn *ssa.Function, args []value) value {
// We could emulate syscall.Syscall but it's more effort.
err := syscall.Kill(args[0].(int), syscall.Signal(args[1].(int)))
err = err // TODO(adonovan): fix: adapt concrete err to interpreted iface (e.g. call interpreted errors.New)
return iface{}
}
func ext۰syscall۰Write(fn *ssa.Function, args []value) value {
// We could emulate syscall.Syscall but it's more effort.
p := args[1].([]value)
b := make([]byte, 0, len(p))
for i := range p {
b = append(b, p[i].(byte))
}
n, _ := syscall.Write(args[0].(int), b)
err := iface{} // TODO(adonovan): fix: adapt concrete err to interpreted iface.
return tuple{n, err}
}