mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 01:47:51 +08:00
eval: (*evalCtx).copy -> fork
This commit is contained in:
parent
d0a88e4961
commit
d794dbf210
|
@ -297,7 +297,7 @@ func each(ec *evalCtx, f *closure) exitus {
|
|||
in := ec.ports[0].ch
|
||||
in:
|
||||
for v := range in {
|
||||
e := f.Exec(ec.copy("closure of each"), []Value{v})
|
||||
e := f.Exec(ec.fork("closure of each"), []Value{v})
|
||||
switch e.Sort {
|
||||
case Ok, Continue:
|
||||
// nop
|
||||
|
|
|
@ -81,7 +81,7 @@ func (cp *compiler) pipeline(n *parse.Pipeline) valuesOp {
|
|||
|
||||
// For each form, create a dedicated evalCtx and run asynchronously
|
||||
for i, op := range ops {
|
||||
newEc := ec.copy(fmt.Sprintf("form op %v", op))
|
||||
newEc := ec.fork(fmt.Sprintf("form op %v", op))
|
||||
if i > 0 {
|
||||
newEc.ports[0] = nextIn
|
||||
}
|
||||
|
@ -444,7 +444,7 @@ func (cp *compiler) outputCapture(n *parse.Primary) valuesOp {
|
|||
p := n.Chunk.Begin()
|
||||
return func(ec *evalCtx) []Value {
|
||||
vs := []Value{}
|
||||
newEc := ec.copy(fmt.Sprintf("channel output capture %v", op))
|
||||
newEc := ec.fork(fmt.Sprintf("channel output capture %v", op))
|
||||
|
||||
pipeRead, pipeWrite, err := os.Pipe()
|
||||
if err != nil {
|
||||
|
|
|
@ -143,10 +143,10 @@ func newTopEvalCtx(ev *Evaler, name, text string) (*evalCtx, chan bool) {
|
|||
}, done
|
||||
}
|
||||
|
||||
// copy returns a copy of ec. The ports are copied deeply, with shouldClose
|
||||
// flags reset, and the context is changed to the given value. Other fields are
|
||||
// copied shallowly.
|
||||
func (ec *evalCtx) copy(newContext string) *evalCtx {
|
||||
// fork returns a modified copy of ec. The ports are copied deeply, with
|
||||
// shouldClose flags reset, and the context is changed to the given value.
|
||||
// Other fields are copied shallowly.
|
||||
func (ec *evalCtx) fork(newContext string) *evalCtx {
|
||||
newPorts := make([]*port, len(ec.ports))
|
||||
for i, p := range ec.ports {
|
||||
newPorts[i] = &port{p.f, p.ch, false, false}
|
||||
|
|
Loading…
Reference in New Issue
Block a user