github.com/emcfarlane/larking@v0.0.0-20220605172417-1704b45ee6c3/starlib/globals.go (about) 1 // Copyright 2022 Edward McFarlane. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package starlib 6 7 import ( 8 "github.com/emcfarlane/larking/starlib/starlarkstruct" 9 "go.starlark.net/resolve" 10 "go.starlark.net/starlark" 11 ) 12 13 func init() { 14 resolve.AllowSet = true 15 resolve.AllowGlobalReassign = true 16 resolve.AllowRecursion = true 17 18 // TODO: requirement for REPL. 19 resolve.LoadBindsGlobally = true 20 } 21 22 func NewGlobals() starlark.StringDict { 23 return starlark.StringDict{ 24 "struct": starlark.NewBuiltin("struct", starlarkstruct.Make), 25 "module": starlark.NewBuiltin("module", starlarkstruct.MakeModule), 26 } 27 }