elvish/pkg/eval/builtin_fn_debug.go
Qi Xiao a3f4384495 Move all elvdocs into .d.elv files.
The elvdocs still use the old format (#elvdoc:fn or #elvdoc:var) for now, but
will be changed to "fn" and "var" forms soon.

Also remove the accidentally committed cmd/mvelvdoc. It has been used to perform
the conversion automatically but is not supposed to be committed.
2022-11-20 21:59:45 +00:00

40 lines
595 B
Go

package eval
import (
"runtime"
"src.elv.sh/pkg/logutil"
"src.elv.sh/pkg/parse"
)
func init() {
addBuiltinFns(map[string]any{
"src": src,
"-gc": _gc,
"-stack": _stack,
"-log": _log,
})
}
func src(fm *Frame) parse.Source {
return fm.srcMeta
}
func _gc() {
runtime.GC()
}
func _stack(fm *Frame) error {
// TODO(xiaq): Dup with main.go.
buf := make([]byte, 1024)
for runtime.Stack(buf, true) == cap(buf) {
buf = make([]byte, cap(buf)*2)
}
_, err := fm.ByteOutput().Write(buf)
return err
}
func _log(fname string) error {
return logutil.SetOutputFile(fname)
}