OLD | NEW |
1 // Copyright 2013 The Go Authors. All rights reserved. | 1 // Copyright 2013 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // +build !windows,!plan9 | 5 // +build !windows,!plan9 |
6 | 6 |
7 package interp | 7 package interp |
8 | 8 |
9 import ( | 9 import ( |
10 "exp/ssa" | 10 "exp/ssa" |
11 "syscall" | 11 "syscall" |
12 ) | 12 ) |
13 | 13 |
14 func ext۰syscall۰Kill(fn *ssa.Function, args []value, slots []value) value { | 14 func ext۰syscall۰Kill(fn *ssa.Function, args []value) value { |
15 // We could emulate syscall.Syscall but it's more effort. | 15 // We could emulate syscall.Syscall but it's more effort. |
16 err := syscall.Kill(args[0].(int), syscall.Signal(args[1].(int))) | 16 err := syscall.Kill(args[0].(int), syscall.Signal(args[1].(int))) |
17 err = err // TODO(adonovan): fix: adapt concrete err to interpreted ifac
e (e.g. call interpreted errors.New) | 17 err = err // TODO(adonovan): fix: adapt concrete err to interpreted ifac
e (e.g. call interpreted errors.New) |
18 return iface{} | 18 return iface{} |
19 } | 19 } |
20 | 20 |
21 func ext۰syscall۰Write(fn *ssa.Function, args []value, slots []value) value { | 21 func ext۰syscall۰Write(fn *ssa.Function, args []value) value { |
22 // We could emulate syscall.Syscall but it's more effort. | 22 // We could emulate syscall.Syscall but it's more effort. |
23 p := args[1].([]value) | 23 p := args[1].([]value) |
24 b := make([]byte, 0, len(p)) | 24 b := make([]byte, 0, len(p)) |
25 for i := range p { | 25 for i := range p { |
26 b = append(b, p[i].(byte)) | 26 b = append(b, p[i].(byte)) |
27 } | 27 } |
28 n, _ := syscall.Write(args[0].(int), b) | 28 n, _ := syscall.Write(args[0].(int), b) |
29 err := iface{} // TODO(adonovan): fix: adapt concrete err to interpreted
iface. | 29 err := iface{} // TODO(adonovan): fix: adapt concrete err to interpreted
iface. |
30 return tuple{n, err} | 30 return tuple{n, err} |
31 | 31 |
32 } | 32 } |
OLD | NEW |