Skip to content

Commit

Permalink
internal: remove MakeInstance
Browse files Browse the repository at this point in the history
Its last use was in internal/encoding and removed in
https://cuelang.org/cl/1193586, which fixed its deprecation warnings.

This removes the close dependency between the cue and internal packages,
which is a good step as it was a bit of a hack.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I449eb6ddad58da256c4ff7eb64d134a73d1cfa27
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1193598
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
  • Loading branch information
mvdan committed Apr 22, 2024
1 parent c16bac7 commit 25e8713
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 19 deletions.
16 changes: 0 additions & 16 deletions cue/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"cuelang.org/go/cue/ast"
"cuelang.org/go/cue/build"
"cuelang.org/go/cue/errors"
"cuelang.org/go/internal"
"cuelang.org/go/internal/core/adt"
"cuelang.org/go/internal/core/compile"
"cuelang.org/go/internal/core/runtime"
Expand Down Expand Up @@ -138,21 +137,6 @@ func getImportFromPath(x *runtime.Runtime, id string) *Instance {
return inst
}

func init() {
internal.MakeInstance = func(value interface{}) interface{} {
v := value.(Value)
x := v.eval(v.ctx())
st, ok := x.(*adt.Vertex)
if !ok {
st = &adt.Vertex{}
st.AddConjunct(adt.MakeRootConjunct(nil, x))
}
return addInst(v.idx, &Instance{
root: st,
})
}
}

// newInstance creates a new instance. Use Insert to populate the instance.
func newInstance(x *runtime.Runtime, p *build.Instance, v *adt.Vertex) *Instance {
// TODO: associate root source with structLit.
Expand Down
3 changes: 0 additions & 3 deletions internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ func (c Context) Sqrt(d, x *apd.Decimal) (apd.Condition, error) {
// incomplete.
var ErrIncomplete = errors.New("incomplete value")

// MakeInstance makes a new instance from a value.
var MakeInstance func(value interface{}) (instance interface{})

// BaseContext is used as CUE's default context for arbitrary-precision decimals.
var BaseContext = Context{*apd.BaseContext.WithPrecision(34)}

Expand Down

0 comments on commit 25e8713

Please sign in to comment.