pkg/eval: Remove (*Frame).Eval.

This commit is contained in:
Qi Xiao 2021-01-03 20:54:35 +00:00
parent d140e98f3c
commit 5fbeb781ff
3 changed files with 6 additions and 13 deletions

View File

@ -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) {

View File

@ -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.

View File

@ -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()