cue: remove build.Context reference
This is really unused,but would cause memory leaks
when used.
Change-Id: I9dc637324d16eb4290cba9a56c96a64287083d14
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/8223
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cue/build.go b/cue/build.go
index 2ea58e8..b694906 100644
--- a/cue/build.go
+++ b/cue/build.go
@@ -31,7 +31,6 @@
//
// The zero value of a Runtime is ready to use.
type Runtime struct {
- ctx *build.Context // TODO: remove
idx *index
}
@@ -75,14 +74,6 @@
return r.idx
}
-func (r *Runtime) buildContext() *build.Context {
- ctx := r.ctx
- if r.ctx == nil {
- ctx = build.NewContext()
- }
- return ctx
-}
-
func (r *Runtime) complete(p *build.Instance) (*Instance, error) {
idx := r.index()
if err := p.Complete(); err != nil {
@@ -101,7 +92,7 @@
// name in position information. The source may import builtin packages. Use
// Build to allow importing non-builtin packages.
func (r *Runtime) Compile(filename string, source interface{}) (*Instance, error) {
- ctx := r.buildContext()
+ ctx := build.NewContext()
p := ctx.NewInstance(filename, dummyLoad)
if err := p.AddFile(filename, source); err != nil {
return nil, p.Err
@@ -112,7 +103,7 @@
// CompileFile compiles the given source file into an Instance. The source may
// import builtin packages. Use Build to allow importing non-builtin packages.
func (r *Runtime) CompileFile(file *ast.File) (*Instance, error) {
- ctx := r.buildContext()
+ ctx := build.NewContext()
p := ctx.NewInstance(file.Filename, dummyLoad)
err := p.AddSyntax(file)
if err != nil {
diff --git a/cue/marshal.go b/cue/marshal.go
index 8ce44ea..8d86525 100644
--- a/cue/marshal.go
+++ b/cue/marshal.go
@@ -70,7 +70,7 @@
func compileInstances(r *Runtime, data []*instanceData) (instances []*Instance, err error) {
b := unmarshaller{
- ctxt: r.buildContext(),
+ ctxt: build.NewContext(),
imports: map[string]*instanceData{},
}
for _, i := range data {