17 lines
448 B
Go
17 lines
448 B
Go
|
package objects
|
||
|
|
||
|
// BuiltinModule is an importable module that's written in Go.
|
||
|
type BuiltinModule struct {
|
||
|
Attrs map[string]Object
|
||
|
}
|
||
|
|
||
|
// Import returns an immutable map for the module.
|
||
|
func (m *BuiltinModule) Import(name string) (interface{}, error) {
|
||
|
attrs := make(map[string]Object, len(m.Attrs))
|
||
|
for k, v := range m.Attrs {
|
||
|
attrs[k] = v.Copy()
|
||
|
}
|
||
|
attrs["__module_name__"] = &String{Value: name}
|
||
|
return &ImmutableMap{Value: attrs}, nil
|
||
|
}
|