cue: remove aliases used for refactoring

Change-Id: I8843e418564ac934ca5829a1e472008ed98d081d
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/7725
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cue/alias.go b/cue/alias.go
deleted file mode 100644
index 83146a6..0000000
--- a/cue/alias.go
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2020 CUE Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package cue
-
-import "cuelang.org/go/internal/core/adt"
-
-type (
-	bottom    = adt.Bottom
-	source    = adt.Node
-	kind      = adt.Kind
-	nullLit   = adt.Null
-	boolLit   = adt.Bool
-	numLit    = adt.Num
-	stringLit = adt.String
-	bytesLit  = adt.Bytes
-	structLit = adt.Vertex
-
-	arc       = *adt.Vertex
-	value     = adt.Expr
-	evaluated = adt.Value
-	label     = adt.Feature
-
-	listLit         = adt.ListLit
-	top             = adt.Top
-	basicType       = adt.BasicType
-	boundExpr       = adt.BoundExpr
-	boundValue      = adt.BoundValue
-	selectorExpr    = adt.SelectorExpr
-	indexExpr       = adt.IndexExpr
-	sliceExpr       = adt.SliceExpr
-	interpolation   = adt.Interpolation
-	unaryExpr       = adt.UnaryExpr
-	binaryExpr      = adt.BinaryExpr
-	callExpr        = adt.CallExpr
-	disjunction     = adt.DisjunctionExpr
-	dValue          = adt.Disjunct
-	customValidator = adt.BuiltinValidator
-)
-
-const (
-	topKind    = adt.TopKind
-	nullKind   = adt.NullKind
-	boolKind   = adt.BoolKind
-	numKind    = adt.NumKind
-	intKind    = adt.IntKind
-	floatKind  = adt.FloatKind
-	stringKind = adt.StringKind
-	bytesKind  = adt.BytesKind
-	listKind   = adt.ListKind
-	structKind = adt.StructKind
-	bottomKind = adt.BottomKind
-)
diff --git a/cue/context.go b/cue/context.go
index 3f00329..8b5f908 100644
--- a/cue/context.go
+++ b/cue/context.go
@@ -55,7 +55,7 @@
 	return debugStr(c, v)
 }
 
-func (c *context) mkErr(src source, args ...interface{}) *bottom {
+func (c *context) mkErr(src adt.Node, args ...interface{}) *adt.Bottom {
 	return c.index.mkErr(src, args...)
 }
 
diff --git a/cue/errors.go b/cue/errors.go
index 7d94051..b7d6fff 100644
--- a/cue/errors.go
+++ b/cue/errors.go
@@ -20,7 +20,7 @@
 	"cuelang.org/go/internal/core/adt"
 )
 
-func (v Value) toErr(b *bottom) (err errors.Error) {
+func (v Value) toErr(b *adt.Bottom) (err errors.Error) {
 	errs := errors.Errors(b.Err)
 	if len(errs) > 1 {
 		for _, e := range errs {
@@ -38,7 +38,7 @@
 // A valueError is returned as a result of evaluating a value.
 type valueError struct {
 	v   Value
-	err *bottom
+	err *adt.Bottom
 }
 
 func (e *valueError) Unwrap() error {
@@ -101,14 +101,14 @@
 	Err:  errors.Newf(token.NoPos, "undefined value"),
 }
 
-func exists(v value) bool {
-	if err, ok := v.(*bottom); ok {
+func exists(v adt.Expr) bool {
+	if err, ok := v.(*adt.Bottom); ok {
 		return err.Code != codeNotExist
 	}
 	return true
 }
 
-func (idx *index) mkErr(src source, args ...interface{}) *bottom {
+func (idx *index) mkErr(src adt.Node, args ...interface{}) *adt.Bottom {
 	var e *adt.Bottom
 	var code errCode = -1
 outer:
@@ -116,15 +116,15 @@
 		switch x := a.(type) {
 		case errCode:
 			code = x
-		case *bottom:
+		case *adt.Bottom:
 			e = adt.CombineErrors(nil, e, x)
-		case []*bottom:
+		case []*adt.Bottom:
 			for _, b := range x {
 				e = adt.CombineErrors(nil, e, b)
 			}
 		case errors.Error:
 			e = adt.CombineErrors(nil, e, &adt.Bottom{Err: x})
-		case value:
+		case adt.Expr:
 		case string:
 			args := args[i+1:]
 			// Do not expand message so that errors can be localized.
diff --git a/cue/instance.go b/cue/instance.go
index 70a89b9..956e011 100644
--- a/cue/instance.go
+++ b/cue/instance.go
@@ -165,7 +165,7 @@
 	inst.Err = errors.Append(inst.Err, err)
 }
 
-func (inst *Instance) eval(ctx *context) evaluated {
+func (inst *Instance) eval(ctx *context) adt.Value {
 	// TODO: remove manifest here?
 	v := ctx.manifest(inst.root)
 	return v
@@ -186,7 +186,7 @@
 }
 
 // evalExpr evaluates expr within scope.
-func evalExpr(ctx *context, scope *adt.Vertex, expr ast.Expr) evaluated {
+func evalExpr(ctx *context, scope *adt.Vertex, expr ast.Expr) adt.Value {
 	cfg := &compile.Config{
 		Scope: scope,
 		Imports: func(x *ast.Ident) (pkgPath string) {
diff --git a/cue/types.go b/cue/types.go
index d9aa414..ac9c3a9 100644
--- a/cue/types.go
+++ b/cue/types.go
@@ -172,14 +172,14 @@
 
 type marshalError struct {
 	err errors.Error
-	b   *bottom
+	b   *adt.Bottom
 }
 
-func toMarshalErr(v Value, b *bottom) error {
+func toMarshalErr(v Value, b *adt.Bottom) error {
 	return &marshalError{v.toErr(b), b}
 }
 
-func marshalErrf(v Value, src source, code errCode, msg string, args ...interface{}) error {
+func marshalErrf(v Value, src adt.Node, code errCode, msg string, args ...interface{}) error {
 	arguments := append([]interface{}{code, msg}, args...)
 	b := v.idx.mkErr(src, arguments...)
 	return toMarshalErr(v, b)
@@ -218,7 +218,7 @@
 	arcs  []field
 	p     int
 	cur   Value
-	f     label
+	f     adt.Feature
 	isOpt bool
 }
 
@@ -298,13 +298,13 @@
 	return b, nil
 }
 
-func (v Value) getNum(k kind) (*numLit, errors.Error) {
+func (v Value) getNum(k adt.Kind) (*adt.Num, errors.Error) {
 	v, _ = v.Default()
 	ctx := v.ctx()
 	if err := v.checkKind(ctx, k); err != nil {
 		return nil, v.toErr(err)
 	}
-	n, _ := v.eval(ctx).(*numLit)
+	n, _ := v.eval(ctx).(*adt.Num)
 	return n, nil
 }
 
@@ -317,7 +317,7 @@
 // 200 and exp == -2. Calling MantExp with a nil argument is an efficient way to
 // get the exponent of the receiver.
 func (v Value) MantExp(mant *big.Int) (exp int, err error) {
-	n, err := v.getNum(numKind)
+	n, err := v.getNum(adt.NumKind)
 	if err != nil {
 		return 0, err
 	}
@@ -336,7 +336,7 @@
 // Decimal is for internal use only. The Decimal type that is returned is
 // subject to change.
 func (v Value) Decimal() (d *internal.Decimal, err error) {
-	n, err := v.getNum(numKind)
+	n, err := v.getNum(adt.NumKind)
 	if err != nil {
 		return nil, err
 	}
@@ -357,7 +357,7 @@
 // AppendFloat appends to buf the string form of the floating-point number x.
 // It returns an error if v is not a number.
 func (v Value) AppendFloat(buf []byte, fmt byte, prec int) ([]byte, error) {
-	n, err := v.getNum(numKind)
+	n, err := v.getNum(adt.NumKind)
 	if err != nil {
 		return nil, err
 	}
@@ -395,7 +395,7 @@
 // argument z is provided, Int stores the result in z instead of allocating a
 // new Int.
 func (v Value) Int(z *big.Int) (*big.Int, error) {
-	n, err := v.getNum(intKind)
+	n, err := v.getNum(adt.IntKind)
 	if err != nil {
 		return nil, err
 	}
@@ -417,7 +417,7 @@
 // as an int64. The result is (math.MinInt64, ErrAbove) for x < math.MinInt64,
 // and (math.MaxInt64, ErrBelow) for x > math.MaxInt64.
 func (v Value) Int64() (int64, error) {
-	n, err := v.getNum(intKind)
+	n, err := v.getNum(adt.IntKind)
 	if err != nil {
 		return 0, err
 	}
@@ -439,7 +439,7 @@
 // as a uint64. The result is (0, ErrAbove) for x < 0, and
 // (math.MaxUint64, ErrBelow) for x > math.MaxUint64.
 func (v Value) Uint64() (uint64, error) {
-	n, err := v.getNum(intKind)
+	n, err := v.getNum(adt.IntKind)
 	if err != nil {
 		return 0, err
 	}
@@ -513,7 +513,7 @@
 // by a float64 (|x| > math.MaxFloat64), the result is (+Inf, ErrAbove) or
 // (-Inf, ErrBelow), depending on the sign of x.
 func (v Value) Float64() (float64, error) {
-	n, err := v.getNum(numKind)
+	n, err := v.getNum(adt.NumKind)
 	if err != nil {
 		return 0, err
 	}
@@ -564,7 +564,7 @@
 	v   *adt.Vertex
 }
 
-func newErrValue(v Value, b *bottom) Value {
+func newErrValue(v Value, b *adt.Bottom) Value {
 	node := &adt.Vertex{Value: b}
 	if v.v != nil {
 		node.Label = v.v.Label
@@ -586,7 +586,7 @@
 	return makeValue(ctx.index, x)
 }
 
-func newValueRoot(ctx *context, x value) Value {
+func newValueRoot(ctx *context, x adt.Expr) Value {
 	if n, ok := x.(*adt.Vertex); ok {
 		return newVertexRoot(ctx, n)
 	}
@@ -642,7 +642,7 @@
 	return Value{idx, v}
 }
 
-func remakeValue(base Value, env *adt.Environment, v value) Value {
+func remakeValue(base Value, env *adt.Environment, v adt.Expr) Value {
 	// TODO: right now this is necessary because disjunctions do not have
 	// populated conjuncts.
 	if v, ok := v.(*adt.Vertex); ok && v.Status() >= adt.Partial {
@@ -665,7 +665,7 @@
 	return v.idx.newContext()
 }
 
-func (v Value) makeChild(ctx *context, i uint32, a arc) Value {
+func (v Value) makeChild(ctx *context, i uint32, a *adt.Vertex) Value {
 	a.Parent = v.v
 	return makeValue(v.idx, a)
 }
@@ -887,29 +887,29 @@
 
 	// TODO: implement marshalles in value.
 	switch k := x.Kind(); k {
-	case nullKind:
+	case adt.NullKind:
 		return json.Marshal(nil)
-	case boolKind:
-		return json.Marshal(x.(*boolLit).B)
-	case intKind, floatKind, numKind:
-		b, err := x.(*numLit).X.MarshalText()
+	case adt.BoolKind:
+		return json.Marshal(x.(*adt.Bool).B)
+	case adt.IntKind, adt.FloatKind, adt.NumKind:
+		b, err := x.(*adt.Num).X.MarshalText()
 		b = bytes.TrimLeft(b, "+")
 		return b, err
-	case stringKind:
-		return json.Marshal(x.(*stringLit).Str)
-	case bytesKind:
-		return json.Marshal(x.(*bytesLit).B)
-	case listKind:
+	case adt.StringKind:
+		return json.Marshal(x.(*adt.String).Str)
+	case adt.BytesKind:
+		return json.Marshal(x.(*adt.Bytes).B)
+	case adt.ListKind:
 		i, _ := v.List()
 		return marshalList(&i)
-	case structKind:
+	case adt.StructKind:
 		obj, err := v.structValData(ctx)
 		if err != nil {
 			return nil, toMarshalErr(v, err)
 		}
 		return obj.marshalJSON()
-	case bottomKind:
-		return nil, toMarshalErr(v, x.(*bottom))
+	case adt.BottomKind:
+		return nil, toMarshalErr(v, x.(*adt.Bottom))
 	default:
 		return nil, marshalErrf(v, x, 0, "cannot convert value %q of type %T to JSON", ctx.str(x), x)
 	}
@@ -1066,7 +1066,7 @@
 
 // Err returns the error represented by v or nil v is not an error.
 func (v Value) Err() error {
-	if err := v.checkKind(v.ctx(), bottomKind); err != nil {
+	if err := v.checkKind(v.ctx(), adt.BottomKind); err != nil {
 		return v.toErr(err)
 	}
 	return nil
@@ -1128,18 +1128,18 @@
 	return exists(v.v.Value)
 }
 
-func (v Value) checkKind(ctx *context, want kind) *bottom {
+func (v Value) checkKind(ctx *context, want adt.Kind) *adt.Bottom {
 	if v.v == nil {
 		return errNotExists
 	}
 	// TODO: use checkKind
 	x := v.eval(ctx)
-	if b, ok := x.(*bottom); ok {
+	if b, ok := x.(*adt.Bottom); ok {
 		return b
 	}
 	k := x.Kind()
-	if want != bottomKind {
-		if k&want == bottomKind {
+	if want != adt.BottomKind {
+		if k&want == adt.BottomKind {
 			return ctx.mkErr(x, "cannot use value %v (type %s) as %s",
 				ctx.opCtx.Str(x), k, want)
 		}
@@ -1151,7 +1151,7 @@
 }
 
 func makeInt(v Value, x int64) Value {
-	n := &adt.Num{K: intKind}
+	n := &adt.Num{K: adt.IntKind}
 	n.X.SetInt64(int64(x))
 	return remakeFinal(v, nil, n)
 }
@@ -1165,7 +1165,7 @@
 		case *adt.Vertex:
 			if x.IsList() {
 				ctx := v.ctx()
-				n := &adt.Num{K: intKind}
+				n := &adt.Num{K: adt.IntKind}
 				n.X.SetInt64(int64(len(x.Elems())))
 				if x.IsClosed(ctx.opCtx) {
 					return remakeFinal(v, nil, n)
@@ -1181,9 +1181,9 @@
 				return remakeFinal(v, nil, c)
 
 			}
-		case *bytesLit:
+		case *adt.Bytes:
 			return makeInt(v, int64(len(x.B)))
-		case *stringLit:
+		case *adt.String:
 			return makeInt(v, int64(len([]rune(x.Str))))
 		}
 	}
@@ -1248,7 +1248,7 @@
 func (v Value) List() (Iterator, error) {
 	v, _ = v.Default()
 	ctx := v.ctx()
-	if err := v.checkKind(ctx, listKind); err != nil {
+	if err := v.checkKind(ctx, adt.ListKind); err != nil {
 		return Iterator{ctx: ctx}, v.toErr(err)
 	}
 	arcs := []field{}
@@ -1263,7 +1263,7 @@
 // Null reports an error if v is not null.
 func (v Value) Null() error {
 	v, _ = v.Default()
-	if err := v.checkKind(v.ctx(), nullKind); err != nil {
+	if err := v.checkKind(v.ctx(), adt.NullKind); err != nil {
 		return v.toErr(err)
 	}
 	return nil
@@ -1278,20 +1278,20 @@
 func (v Value) Bool() (bool, error) {
 	v, _ = v.Default()
 	ctx := v.ctx()
-	if err := v.checkKind(ctx, boolKind); err != nil {
+	if err := v.checkKind(ctx, adt.BoolKind); err != nil {
 		return false, v.toErr(err)
 	}
-	return v.eval(ctx).(*boolLit).B, nil
+	return v.eval(ctx).(*adt.Bool).B, nil
 }
 
 // String returns the string value if v is a string or an error otherwise.
 func (v Value) String() (string, error) {
 	v, _ = v.Default()
 	ctx := v.ctx()
-	if err := v.checkKind(ctx, stringKind); err != nil {
+	if err := v.checkKind(ctx, adt.StringKind); err != nil {
 		return "", v.toErr(err)
 	}
-	return v.eval(ctx).(*stringLit).Str, nil
+	return v.eval(ctx).(*adt.String).Str, nil
 }
 
 // Bytes returns a byte slice if v represents a list of bytes or an error
@@ -1300,12 +1300,12 @@
 	v, _ = v.Default()
 	ctx := v.ctx()
 	switch x := v.eval(ctx).(type) {
-	case *bytesLit:
+	case *adt.Bytes:
 		return append([]byte(nil), x.B...), nil
-	case *stringLit:
+	case *adt.String:
 		return []byte(x.Str), nil
 	}
-	return nil, v.toErr(v.checkKind(ctx, bytesKind|stringKind))
+	return nil, v.toErr(v.checkKind(ctx, adt.BytesKind|adt.StringKind))
 }
 
 // Reader returns a new Reader if v is a string or bytes type and an error
@@ -1314,12 +1314,12 @@
 	v, _ = v.Default()
 	ctx := v.ctx()
 	switch x := v.eval(ctx).(type) {
-	case *bytesLit:
+	case *adt.Bytes:
 		return bytes.NewReader(x.B), nil
-	case *stringLit:
+	case *adt.String:
 		return strings.NewReader(x.Str), nil
 	}
-	return nil, v.toErr(v.checkKind(ctx, stringKind|bytesKind))
+	return nil, v.toErr(v.checkKind(ctx, adt.StringKind|adt.BytesKind))
 }
 
 // TODO: distinguish between optional, hidden, etc. Probably the best approach
@@ -1327,7 +1327,7 @@
 // a structVal.
 
 // structVal returns an structVal or an error if v is not a struct.
-func (v Value) structValData(ctx *context) (structValue, *bottom) {
+func (v Value) structValData(ctx *context) (structValue, *adt.Bottom) {
 	return v.structValOpts(ctx, options{
 		omitHidden:      true,
 		omitDefinitions: true,
@@ -1335,12 +1335,12 @@
 	})
 }
 
-func (v Value) structValFull(ctx *context) (structValue, *bottom) {
+func (v Value) structValFull(ctx *context) (structValue, *adt.Bottom) {
 	return v.structValOpts(ctx, options{})
 }
 
 // structVal returns an structVal or an error if v is not a struct.
-func (v Value) structValOpts(ctx *context, o options) (structValue, *bottom) {
+func (v Value) structValOpts(ctx *context, o options) (structValue, *adt.Bottom) {
 	v, _ = v.Default()
 
 	obj, err := v.getStruct()
@@ -1390,9 +1390,9 @@
 	return &Struct{obj}, nil
 }
 
-func (v Value) getStruct() (*structLit, *bottom) {
+func (v Value) getStruct() (*adt.Vertex, *adt.Bottom) {
 	ctx := v.ctx()
-	if err := v.checkKind(ctx, structKind); err != nil {
+	if err := v.checkKind(ctx, adt.StructKind); err != nil {
 		if !err.ChildError {
 			return nil, err
 		}
@@ -2204,17 +2204,17 @@
 	a := []Value{}
 	op := NoOp
 	switch x := expr.(type) {
-	case *binaryExpr:
+	case *adt.BinaryExpr:
 		a = append(a, remakeValue(v, env, x.X))
 		a = append(a, remakeValue(v, env, x.Y))
 		op = x.Op
-	case *unaryExpr:
+	case *adt.UnaryExpr:
 		a = append(a, remakeValue(v, env, x.X))
 		op = x.Op
-	case *boundExpr:
+	case *adt.BoundExpr:
 		a = append(a, remakeValue(v, env, x.Expr))
 		op = x.Op
-	case *boundValue:
+	case *adt.BoundValue:
 		a = append(a, remakeValue(v, env, x.Value))
 		op = x.Op
 	case *adt.Conjunction:
@@ -2273,7 +2273,7 @@
 			op = adt.OrOp
 		}
 
-	case *interpolation:
+	case *adt.Interpolation:
 		for _, p := range x.Parts {
 			a = append(a, remakeValue(v, env, p))
 		}
@@ -2289,7 +2289,7 @@
 		_ = ctx.PopState(f)
 		op = SelectorOp
 
-	case *selectorExpr:
+	case *adt.SelectorExpr:
 		a = append(a, remakeValue(v, env, x.X))
 		// A string selector is quoted.
 		a = append(a, remakeValue(v, env, &adt.String{
@@ -2297,22 +2297,22 @@
 		}))
 		op = SelectorOp
 
-	case *indexExpr:
+	case *adt.IndexExpr:
 		a = append(a, remakeValue(v, env, x.X))
 		a = append(a, remakeValue(v, env, x.Index))
 		op = IndexOp
-	case *sliceExpr:
+	case *adt.SliceExpr:
 		a = append(a, remakeValue(v, env, x.X))
 		a = append(a, remakeValue(v, env, x.Lo))
 		a = append(a, remakeValue(v, env, x.Hi))
 		op = SliceOp
-	case *callExpr:
+	case *adt.CallExpr:
 		a = append(a, remakeValue(v, env, x.Fun))
 		for _, arg := range x.Args {
 			a = append(a, remakeValue(v, env, arg))
 		}
 		op = CallOp
-	case *customValidator:
+	case *adt.BuiltinValidator:
 		a = append(a, remakeValue(v, env, x.Builtin))
 		for _, arg := range x.Args {
 			a = append(a, remakeValue(v, env, arg))