mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 01:47:51 +08:00
802f5ab31e
This batch rename was done with an Elvish script: https://gist.github.com/xiaq/d8601c822c814f8bd8819a2ae96d2b7b
39 lines
553 B
Go
39 lines
553 B
Go
package eval
|
|
|
|
import (
|
|
"runtime"
|
|
|
|
"github.com/elves/elvish/util"
|
|
)
|
|
|
|
func init() {
|
|
addBuiltinFns(map[string]interface{}{
|
|
"src": src,
|
|
"-gc": _gc,
|
|
"-stack": _stack,
|
|
"-log": _log,
|
|
})
|
|
}
|
|
|
|
func src(fm *Frame) *Source {
|
|
return fm.srcMeta
|
|
}
|
|
|
|
func _gc() {
|
|
runtime.GC()
|
|
}
|
|
|
|
func _stack(fm *Frame) {
|
|
out := fm.ports[1].File
|
|
// XXX dup with main.go
|
|
buf := make([]byte, 1024)
|
|
for runtime.Stack(buf, true) == cap(buf) {
|
|
buf = make([]byte, cap(buf)*2)
|
|
}
|
|
out.Write(buf)
|
|
}
|
|
|
|
func _log(fname string) error {
|
|
return util.SetOutputFile(fname)
|
|
}
|