2019-02-21 03:26:11 +03:00
|
|
|
package stdlib
|
|
|
|
|
2019-03-18 18:15:26 +03:00
|
|
|
//go:generate go run gensrcmods.go
|
2019-02-21 03:26:11 +03:00
|
|
|
|
2019-03-18 18:15:26 +03:00
|
|
|
import "github.com/d5/tengo/objects"
|
2019-02-21 03:26:11 +03:00
|
|
|
|
2019-03-01 05:41:29 +03:00
|
|
|
// AllModuleNames returns a list of all default module names.
|
|
|
|
func AllModuleNames() []string {
|
|
|
|
var names []string
|
2019-03-18 18:15:26 +03:00
|
|
|
for name := range BuiltinModules {
|
|
|
|
names = append(names, name)
|
|
|
|
}
|
|
|
|
for name := range SourceModules {
|
2019-03-01 05:41:29 +03:00
|
|
|
names = append(names, name)
|
|
|
|
}
|
|
|
|
return names
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetModules returns the modules for the given names.
|
|
|
|
// Duplicate names and invalid names are ignore.
|
2019-03-18 18:15:26 +03:00
|
|
|
func GetModules(names ...string) map[string]objects.Importable {
|
|
|
|
modules := make(map[string]objects.Importable)
|
2019-03-01 05:41:29 +03:00
|
|
|
for _, name := range names {
|
2019-03-18 18:15:26 +03:00
|
|
|
if mod := BuiltinModules[name]; mod != nil {
|
|
|
|
modules[name] = mod
|
|
|
|
}
|
|
|
|
if mod := SourceModules[name]; mod != nil {
|
2019-03-04 21:21:39 +03:00
|
|
|
modules[name] = mod
|
2019-03-01 05:41:29 +03:00
|
|
|
}
|
|
|
|
}
|
2019-03-18 18:15:26 +03:00
|
|
|
|
2019-03-01 05:41:29 +03:00
|
|
|
return modules
|
|
|
|
}
|