2018-09-18 22:42:38 +02:00
|
|
|
package stdlib
|
|
|
|
|
|
|
|
import (
|
2019-03-13 20:51:30 +02:00
|
|
|
"fmt"
|
2018-09-18 22:42:38 +02:00
|
|
|
"github.com/MontFerret/ferret/pkg/runtime/core"
|
2018-10-06 03:27:34 +02:00
|
|
|
"github.com/MontFerret/ferret/pkg/stdlib/arrays"
|
2018-09-18 22:42:38 +02:00
|
|
|
"github.com/MontFerret/ferret/pkg/stdlib/collections"
|
|
|
|
"github.com/MontFerret/ferret/pkg/stdlib/html"
|
2018-10-14 03:07:28 +02:00
|
|
|
"github.com/MontFerret/ferret/pkg/stdlib/math"
|
2018-10-07 23:58:22 +02:00
|
|
|
"github.com/MontFerret/ferret/pkg/stdlib/objects"
|
2018-09-18 22:42:38 +02:00
|
|
|
"github.com/MontFerret/ferret/pkg/stdlib/strings"
|
|
|
|
"github.com/MontFerret/ferret/pkg/stdlib/types"
|
|
|
|
"github.com/MontFerret/ferret/pkg/stdlib/utils"
|
|
|
|
)
|
|
|
|
|
|
|
|
func NewLib() map[string]core.Function {
|
|
|
|
lib := make(map[string]core.Function)
|
|
|
|
|
|
|
|
add := func(l map[string]core.Function) {
|
|
|
|
for name, fn := range l {
|
2019-03-13 20:51:30 +02:00
|
|
|
if _, exists := lib[name]; exists {
|
|
|
|
panic(fmt.Sprintf("%s function already exists", name))
|
|
|
|
}
|
|
|
|
|
2018-09-18 22:42:38 +02:00
|
|
|
lib[name] = fn
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
add(types.NewLib())
|
|
|
|
add(strings.NewLib())
|
2018-10-14 03:07:28 +02:00
|
|
|
add(math.NewLib())
|
2018-09-18 22:42:38 +02:00
|
|
|
add(collections.NewLib())
|
2018-10-06 03:27:34 +02:00
|
|
|
add(arrays.NewLib())
|
2018-10-07 23:58:22 +02:00
|
|
|
add(objects.NewLib())
|
2018-09-18 22:42:38 +02:00
|
|
|
add(html.NewLib())
|
|
|
|
add(utils.NewLib())
|
|
|
|
|
|
|
|
return lib
|
|
|
|
}
|