mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-12 17:27:50 +08:00
pkg/eval: Remove (*Frame).Eval.
This commit is contained in:
parent
d140e98f3c
commit
5fbeb781ff
|
@ -332,7 +332,9 @@ func source(fm *Frame, fname string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return fm.Eval(op)
|
||||
newFm := fm.fork("[-source]")
|
||||
newFm.srcMeta = src
|
||||
return op.Exec(newFm)
|
||||
}
|
||||
|
||||
func readFileUTF8(fname string) (string, error) {
|
||||
|
|
|
@ -171,6 +171,8 @@ func compileFn(cp *compiler, fn *parse.Form) effectOp {
|
|||
bodyNode := args.nextMustLambda()
|
||||
args.mustEnd()
|
||||
|
||||
// Define the variable before compiling the body, so that the body may refer
|
||||
// to the function itself.
|
||||
index := cp.thisScope().add(name + FnSuffix)
|
||||
op := cp.lambda(bodyNode)
|
||||
|
||||
|
@ -322,7 +324,7 @@ func evalInner(fm *Frame, src parse.Source, ns *Ns, st *StackTrace) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return newFm.Eval(op)
|
||||
return op.Exec(newFm)
|
||||
}
|
||||
|
||||
// compileAnd compiles the "and" special form.
|
||||
|
|
|
@ -131,17 +131,6 @@ func (fm *Frame) forkWithOutput(name string, p *Port) *Frame {
|
|||
return newFm
|
||||
}
|
||||
|
||||
// Eval evaluates an Op. It is like eval except that it sets fm.srcMeta
|
||||
// temporarily to op.src during the evaluation.
|
||||
func (fm *Frame) Eval(op Op) error {
|
||||
oldSrc := fm.srcMeta
|
||||
fm.srcMeta = op.Src
|
||||
defer func() {
|
||||
fm.srcMeta = oldSrc
|
||||
}()
|
||||
return op.Exec(fm)
|
||||
}
|
||||
|
||||
// CaptureOutput captures the output of a given callback that operates on a Frame.
|
||||
func (fm *Frame) CaptureOutput(f func(*Frame) error) ([]interface{}, error) {
|
||||
outPort, collect, err := CapturePort()
|
||||
|
|
Loading…
Reference in New Issue
Block a user