mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-14 02:57:52 +08:00
34 lines
494 B
Go
34 lines
494 B
Go
package eval
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/xiaq/persistent/hash"
|
|
)
|
|
|
|
type Pipe struct {
|
|
r, w *os.File
|
|
}
|
|
|
|
var _ Value = Pipe{}
|
|
|
|
func (Pipe) Kind() string {
|
|
return "pipe"
|
|
}
|
|
|
|
func (p Pipe) Equal(rhs interface{}) bool {
|
|
return p == rhs
|
|
}
|
|
|
|
func (p Pipe) Hash() uint32 {
|
|
h := hash.DJBInit
|
|
h = hash.DJBCombine(h, hash.UIntPtr(p.r.Fd()))
|
|
h = hash.DJBCombine(h, hash.UIntPtr(p.w.Fd()))
|
|
return h
|
|
}
|
|
|
|
func (p Pipe) Repr(int) string {
|
|
return fmt.Sprintf("<pipe{%v %v}>", p.r.Fd(), p.w.Fd())
|
|
}
|