xgo/stdlib/stdlib.go
Daniel 3500c686b3
Improvements on compiler/VM error reporting (filename:line:col)
- add type infos to VM error messages
- add 'Name' to UserFunction objects 
- add 'expectErrorString' to VM tests
- replace vm.expectError() with vm.expectErrorString() to make it more explicit
- add source map info to VM error messages
- optimization in function calls
- add file/line/col info to compiler errors
- change stdlib module to be loaded from VM (instead of compiler) so they can be properly loaded after the source is compiled into binary
- VM can take builtin modules optionally
2019-02-20 16:26:11 -08:00

16 lines
518 B
Go

package stdlib
import "github.com/d5/tengo/objects"
// Modules contain the standard modules.
var Modules = map[string]*objects.Object{
"math": objectPtr(&objects.ImmutableMap{Value: mathModule}),
"os": objectPtr(&objects.ImmutableMap{Value: osModule}),
"text": objectPtr(&objects.ImmutableMap{Value: textModule}),
"times": objectPtr(&objects.ImmutableMap{Value: timesModule}),
"rand": objectPtr(&objects.ImmutableMap{Value: randModule}),
}
func objectPtr(o objects.Object) *objects.Object {
return &o
}