cue: remove dead code

Change-Id: Ie7700e845d50cf0a6ae54d77ee41f597f992fbc8
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6861
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cue/builtin.go b/cue/builtin.go
index 9fa9fa1..6ef6621 100644
--- a/cue/builtin.go
+++ b/cue/builtin.go
@@ -171,50 +171,6 @@
 
 }
 
-var lenBuiltin = &builtin{
-	Name:   "len",
-	Params: []kind{stringKind | bytesKind | listKind | structKind},
-	Result: intKind,
-	Func: func(c *callCtxt) {
-		v := c.value(0)
-		switch k := v.IncompleteKind(); k {
-		case StructKind:
-			s, err := v.structValData(c.ctx)
-			if err != nil {
-				c.ret = err
-				break
-			}
-			c.ret = s.Len()
-		case ListKind:
-			i := 0
-			iter, err := v.List()
-			if err != nil {
-				c.ret = err
-				break
-			}
-			for ; iter.Next(); i++ {
-			}
-			c.ret = i
-		case BytesKind:
-			b, err := v.Bytes()
-			if err != nil {
-				c.ret = err
-				break
-			}
-			c.ret = len(b)
-		case StringKind:
-			s, err := v.String()
-			if err != nil {
-				c.ret = err
-				break
-			}
-			c.ret = len(s)
-		default:
-			c.ret = c.ctx.opCtx.Newf("invalid argument type %v", k)
-		}
-	},
-}
-
 func pos(n adt.Node) (p token.Pos) {
 	if n == nil {
 		return
@@ -226,71 +182,6 @@
 	return src.Pos()
 }
 
-var closeBuiltin = &builtin{
-	Name:   "close",
-	Params: []kind{structKind},
-	Result: structKind,
-	Func: func(c *callCtxt) {
-		s, ok := c.args[0].(*adt.Vertex)
-		if !ok {
-			c.ret = errors.Newf(pos(c.args[0]), "struct argument must be concrete")
-			return
-		}
-		if s.IsClosed(c.ctx.opCtx) {
-			c.ret = s
-		} else {
-			v := *s
-			v.Closed = nil // TODO: set dedicated Closer.
-			c.ret = &v
-		}
-	},
-}
-
-var andBuiltin = &builtin{
-	Name:   "and",
-	Params: []kind{listKind},
-	Result: intKind,
-	Func: func(c *callCtxt) {
-		iter := c.iter(0)
-		if !iter.Next() {
-			c.ret = &top{}
-			return
-		}
-		var u adt.Expr = iter.Value().v
-		for iter.Next() {
-			u = &adt.BinaryExpr{Op: adt.AndOp, X: u, Y: iter.Value().v}
-		}
-		c.ret = u
-	},
-}
-
-var orBuiltin = &builtin{
-	Name:   "or",
-	Params: []kind{listKind},
-	Result: intKind,
-	Func: func(c *callCtxt) {
-		iter := c.iter(0)
-		d := []adt.Disjunct{}
-		for iter.Next() {
-			d = append(d, adt.Disjunct{iter.Value().v, false})
-		}
-		c.ret = &adt.DisjunctionExpr{nil, d, false}
-		if len(d) == 0 {
-			// TODO(manifest): This should not be unconditionally incomplete,
-			// but it requires results from comprehensions and all to have
-			// some special status. Maybe this can be solved by having results
-			// of list comprehensions be open if they result from iterating over
-			// an open list or struct. This would actually be exactly what
-			// that means. The error here could then only add an incomplete
-			// status if the source is open.
-			c.ret = &adt.Bottom{
-				Code: adt.IncompleteError,
-				Err:  errors.Newf(c.Pos(), "empty list in call to or"),
-			}
-		}
-	},
-}
-
 func (x *builtin) name(ctx *context) string {
 	if x.pkg == 0 {
 		return x.Name
@@ -430,10 +321,6 @@
 	}
 }
 
-func getBuiltinShorthandPkg(ctx *context, shorthand string) *structLit {
-	return getBuiltinPkg(ctx, "-/"+shorthand)
-}
-
 func getBuiltinPkg(ctx *context, path string) *structLit {
 	p, ok := builtins[path]
 	if !ok {
diff --git a/cue/errors.go b/cue/errors.go
index 21ed886..a4beeda 100644
--- a/cue/errors.go
+++ b/cue/errors.go
@@ -15,9 +15,6 @@
 package cue
 
 import (
-	"fmt"
-	"reflect"
-
 	"cuelang.org/go/cue/errors"
 	"cuelang.org/go/cue/token"
 	"cuelang.org/go/internal/core/adt"
@@ -77,29 +74,10 @@
 type errCode = adt.ErrorCode
 
 const (
-	codeNone       errCode = 0
-	codeFatal              = adt.EvalError
-	codeNotExist           = adt.NotExistError
-	codeTypeError          = adt.EvalError
-	codeIncomplete         = adt.IncompleteError
-	codeUser               = adt.UserError
-	codeCycle              = adt.CycleError
+	codeNotExist   = adt.NotExistError
+	codeIncomplete = adt.IncompleteError
 )
 
-func isIncomplete(v value) bool {
-	if err, ok := v.(*bottom); ok {
-		return err.Code == codeIncomplete || err.Code == codeCycle
-	}
-	return false
-}
-
-func isLiteralBottom(v value) bool {
-	if err, ok := v.(*bottom); ok {
-		return err.Code == codeUser
-	}
-	return false
-}
-
 var errNotExists = &adt.Bottom{
 	Code: codeNotExist,
 	Err:  errors.Newf(token.NoPos, "undefined value"),
@@ -148,35 +126,3 @@
 	}
 	return e
 }
-
-func fixArg(idx *index, x interface{}) interface{} {
-	switch x.(type) {
-	case uint, int, string:
-		return x
-	case value:
-		return x
-	}
-	t := reflect.TypeOf(x)
-	// Store all non-ptr types as is, as they cannot change.
-	if k := t.Kind(); k == reflect.String || k <= reflect.Complex128 {
-		return x
-	}
-	return fmt.Sprint(x)
-}
-
-func isBottom(x adt.Node) bool {
-	if x == nil {
-		return true
-	}
-	b, _ := x.(*adt.Bottom)
-	return b != nil
-}
-
-func firstBottom(v ...value) *bottom {
-	for _, b := range v {
-		if isBottom(b) {
-			return b.(*bottom)
-		}
-	}
-	return nil
-}
diff --git a/cue/op.go b/cue/op.go
index b313289..26f564d 100644
--- a/cue/op.go
+++ b/cue/op.go
@@ -61,43 +61,6 @@
 	InterpolationOp = adt.InterpolationOp
 )
 
-var opToOp = map[op]Op{
-	opUnify: AndOp,
-	// TODO(eval): opUnifyUnchecked is not the same as opUnify and should have its own
-	// category, if needed. More likely opUnifyUnchecked, should be
-	// represented as a separate embedding method.
-	opUnifyUnchecked: AndOp,
-	opDisjunction:    OrOp,
-	opLand:           BooleanAndOp,
-	opLor:            BooleanOrOp,
-	opEql:            EqualOp,
-	opNot:            NotOp,
-	opNeq:            NotEqualOp,
-	opLss:            LessThanOp,
-	opLeq:            LessThanEqualOp,
-	opGtr:            GreaterThanOp,
-	opGeq:            GreaterThanEqualOp,
-	opMat:            RegexMatchOp,
-	opNMat:           NotRegexMatchOp,
-	opAdd:            AddOp,
-	opSub:            SubtractOp,
-	opMul:            MultiplyOp,
-	opQuo:            FloatQuotientOp,
-	opIQuo:           IntQuotientOp,
-	opIRem:           IntRemainderOp,
-	opIDiv:           IntDivideOp,
-	opIMod:           IntModuloOp,
-}
-
-func opIn(op op, anyOf ...op) bool {
-	for _, o := range anyOf {
-		if o == op {
-			return true
-		}
-	}
-	return false
-}
-
 // isCmp reports whether an op is a comparator.
 func (op op) isCmp() bool {
 	return opEql <= op && op <= opGeq
diff --git a/cue/resolve_test.go b/cue/resolve_test.go
index b9ad808..a375ca8 100644
--- a/cue/resolve_test.go
+++ b/cue/resolve_test.go
@@ -17,8 +17,6 @@
 import (
 	"strings"
 	"testing"
-
-	"cuelang.org/go/internal/core/adt"
 )
 
 func TestX(t *testing.T) {
@@ -30,33 +28,3 @@
 		t.Skip()
 	}
 }
-
-// var traceOn = flag.Bool("debug", false, "enable tracing")
-
-// func compileFileWithErrors(t *testing.T, body string) (*context, *structLit, error) {
-// 	t.Helper()
-// 	ctx, inst, err := compileInstance(t, body)
-// 	return ctx, inst.root, err
-// }
-
-// func compileFile(t *testing.T, body string) (*context, *structLit) {
-// 	t.Helper()
-// 	ctx, inst, errs := compileInstance(t, body)
-// 	if errs != nil {
-// 		t.Fatal(errs)
-// 	}
-// 	return ctx, inst.root
-// }
-
-func compileInstance(t *testing.T, body string) (*context, *Instance, error) {
-	var r Runtime
-	inst, err := r.Compile("test", body)
-
-	if err != nil {
-		x := newInstance(newIndex(sharedIndex), nil, &adt.Vertex{})
-		ctx := x.newContext()
-		return ctx, x, err
-	}
-
-	return r.index().newContext(), inst, nil
-}
diff --git a/cue/types_test.go b/cue/types_test.go
index b36c6c5..7c7adb4 100644
--- a/cue/types_test.go
+++ b/cue/types_test.go
@@ -2950,9 +2950,3 @@
 	cfg := &debug.Config{Compact: true, Raw: true}
 	return debug.NodeString(ctx.opCtx, v.v, cfg)
 }
-
-func compactValueStr(v Value) string {
-	ctx := v.ctx()
-	cfg := &debug.Config{Compact: true}
-	return debug.NodeString(ctx.opCtx, v.v, cfg)
-}