2016-02-28 06:43:54 +08:00
|
|
|
package eval
|
|
|
|
|
|
|
|
import (
|
2022-12-27 05:33:03 +08:00
|
|
|
"embed"
|
2016-02-28 06:43:54 +08:00
|
|
|
"strconv"
|
|
|
|
"syscall"
|
2018-01-01 23:21:15 +08:00
|
|
|
|
2021-06-17 12:39:16 +08:00
|
|
|
"src.elv.sh/pkg/buildinfo"
|
2021-01-27 09:28:38 +08:00
|
|
|
"src.elv.sh/pkg/eval/vars"
|
2016-02-28 06:43:54 +08:00
|
|
|
)
|
|
|
|
|
2021-10-24 04:44:11 +08:00
|
|
|
var builtinNs = BuildNsNamed("").AddVars(map[string]vars.Var{
|
2022-06-08 03:20:00 +08:00
|
|
|
"_": vars.NewBlackhole(),
|
|
|
|
"pid": vars.NewReadOnly(strconv.Itoa(syscall.Getpid())),
|
|
|
|
"ok": vars.NewReadOnly(OK),
|
|
|
|
"nil": vars.NewReadOnly(nil),
|
|
|
|
"true": vars.NewReadOnly(true),
|
|
|
|
"false": vars.NewReadOnly(false),
|
|
|
|
"buildinfo": vars.NewReadOnly(buildinfo.Value),
|
|
|
|
"version": vars.NewReadOnly(buildinfo.Value.Version),
|
|
|
|
"paths": vars.NewEnvListVar("PATH"),
|
|
|
|
"nop" + FnSuffix: vars.NewReadOnly(nopGoFn),
|
2021-10-24 04:44:11 +08:00
|
|
|
})
|
2017-06-28 07:39:05 +08:00
|
|
|
|
2022-03-20 23:50:25 +08:00
|
|
|
func addBuiltinFns(fns map[string]any) {
|
2021-10-24 04:44:11 +08:00
|
|
|
builtinNs.AddGoFns(fns)
|
2018-02-04 12:25:23 +08:00
|
|
|
}
|
2022-12-27 05:33:03 +08:00
|
|
|
|
|
|
|
// BuiltinDElvFiles embeds all the .d.elv files for the builtin module.
|
|
|
|
//
|
|
|
|
//go:embed *.d.elv
|
|
|
|
var BuiltinDElvFiles embed.FS
|