2021-08-24 22:56:04 +08:00
|
|
|
// Package mods collects standard library modules.
|
|
|
|
package mods
|
|
|
|
|
|
|
|
import (
|
|
|
|
"src.elv.sh/pkg/eval"
|
|
|
|
"src.elv.sh/pkg/mods/epm"
|
|
|
|
"src.elv.sh/pkg/mods/file"
|
2021-12-30 21:28:25 +08:00
|
|
|
"src.elv.sh/pkg/mods/flag"
|
2021-08-24 22:56:04 +08:00
|
|
|
"src.elv.sh/pkg/mods/math"
|
|
|
|
"src.elv.sh/pkg/mods/path"
|
|
|
|
"src.elv.sh/pkg/mods/platform"
|
|
|
|
"src.elv.sh/pkg/mods/re"
|
|
|
|
"src.elv.sh/pkg/mods/readlinebinding"
|
2022-08-08 06:42:43 +08:00
|
|
|
"src.elv.sh/pkg/mods/runtime"
|
2021-08-24 22:56:04 +08:00
|
|
|
"src.elv.sh/pkg/mods/str"
|
2021-12-17 08:50:53 +08:00
|
|
|
"src.elv.sh/pkg/mods/unix"
|
2021-08-24 22:56:04 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// AddTo adds all standard library modules to the Evaler.
|
2022-08-08 06:42:43 +08:00
|
|
|
//
|
|
|
|
// All the public properties of the Evaler should be set before this function is
|
|
|
|
// called.
|
2021-08-24 22:56:04 +08:00
|
|
|
func AddTo(ev *eval.Evaler) {
|
2022-08-08 06:42:43 +08:00
|
|
|
ev.AddModule("runtime", runtime.Ns(ev))
|
2021-08-24 22:56:04 +08:00
|
|
|
ev.AddModule("math", math.Ns)
|
|
|
|
ev.AddModule("path", path.Ns)
|
|
|
|
ev.AddModule("platform", platform.Ns)
|
|
|
|
ev.AddModule("re", re.Ns)
|
|
|
|
ev.AddModule("str", str.Ns)
|
|
|
|
ev.AddModule("file", file.Ns)
|
2021-12-30 21:28:25 +08:00
|
|
|
ev.AddModule("flag", flag.Ns)
|
2021-12-17 08:50:53 +08:00
|
|
|
if unix.ExposeUnixNs {
|
|
|
|
ev.AddModule("unix", unix.Ns)
|
|
|
|
}
|
2021-10-05 07:52:28 +08:00
|
|
|
ev.BundledModules["epm"] = epm.Code
|
|
|
|
ev.BundledModules["readline-binding"] = readlinebinding.Code
|
2021-08-24 22:56:04 +08:00
|
|
|
}
|