mirror of
				https://github.com/golang/go.git
				synced 2025-11-04 02:30:57 +00:00 
			
		
		
		
	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
		
	
			
		
			
				
	
	
		
			32 lines
		
	
	
	
		
			934 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
	
		
			934 B
		
	
	
	
		
			Go
		
	
	
	
	
	
// 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}
 | 
						||
 | 
						||
}
 |