Skip to content

Commit

Permalink
cmd/cue/cmd: remove usage of cue.Runtime
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: I3985ec1d9e8cd731970dbccf5a1c0f776a3c4313
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/536070
Reviewed-by: Roger Peppe <[email protected]>
Unity-Result: CUEcueckoo <[email protected]>
Reviewed-by: Daniel Martí <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
  • Loading branch information
mpvl committed Jun 21, 2022
1 parent 3ac85dc commit 0b0f1d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 0 additions & 2 deletions cmd/cue/cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ var defaultConfig = config{
},
}

var runtime = &cue.Runtime{}

var inTest = false

func exitIfErr(cmd *Command, inst *cue.Instance, err error, fatal bool) {
Expand Down
10 changes: 7 additions & 3 deletions cmd/cue/cmd/orphans.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,9 @@ func placeOrphans(b *buildPlan, d *encoding.Decoder, pkg string, objs ...*ast.Fi
return nil, errors.Wrapf(err, token.NoPos,
"invalid combination of input files")
}
inst, err := runtime.CompileFile(f)
if err != nil {
ctx := b.cmd.ctx
inst := ctx.BuildFile(f)
if err := inst.Err(); err != nil {
return nil, err
}

Expand All @@ -206,7 +207,10 @@ func placeOrphans(b *buildPlan, d *encoding.Decoder, pkg string, objs ...*ast.Fi
if p, ok := x.(*ast.ParenExpr); ok {
x = p.X // unwrap for better error messages
}
switch l := inst.Eval(x); l.Kind() {
l := ctx.BuildExpr(x,
cue.InferBuiltins(true),
cue.Scope(inst))
switch l.Kind() {
case cue.StringKind, cue.IntKind:
label = l.Syntax().(ast.Label)

Expand Down

0 comments on commit 0b0f1d3

Please sign in to comment.