internal/core/adt: automatic renaming
This is the last step to make List- and StructMarker
a type different from Value and Expr.
Rename:
Vertex.Value -> Vertex.BaseValue
Vertex.ActualValue() -> Vertex.Value()
This generated changes should be used as a last
manual check that the values are used correctly.
Issue #598
Change-Id: Iadb8eb6d782099cbba4deb7cf99f129ce0363371
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/7766
Reviewed-by: Tony Worm <tony@hofstadter.io>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
diff --git a/cue/context.go b/cue/context.go
index ed85619..1afa832 100644
--- a/cue/context.go
+++ b/cue/context.go
@@ -76,7 +76,7 @@
panic("undefined value")
}
x := ctx.manifest(v.v)
- return x.ActualValue()
+ return x.Value()
}
// func (v Value) evalFull(u value) (Value, adt.Value) {
diff --git a/cue/load/config.go b/cue/load/config.go
index 6a9972a..2e905df 100644
--- a/cue/load/config.go
+++ b/cue/load/config.go
@@ -536,12 +536,12 @@
v.Finalize(ctx)
prefix := v.Lookup(ctx.StringLabel("module"))
if prefix != nil {
- name := ctx.StringValue(prefix.ActualValue())
+ name := ctx.StringValue(prefix.Value())
if err := ctx.Err(); err != nil {
return &c, err.Err
}
pos := token.NoPos
- src := prefix.ActualValue().Source()
+ src := prefix.Value().Source()
if src != nil {
pos = src.Pos()
}
diff --git a/cue/types.go b/cue/types.go
index 824594a..82378ab 100644
--- a/cue/types.go
+++ b/cue/types.go
@@ -565,7 +565,7 @@
}
func newErrValue(v Value, b *adt.Bottom) Value {
- node := &adt.Vertex{Value: b}
+ node := &adt.Vertex{BaseValue: b}
if v.v != nil {
node.Label = v.v.Label
node.Parent = v.v.Parent
@@ -635,9 +635,9 @@
}
func makeValue(idx *index, v *adt.Vertex) Value {
- if v.Status() == 0 || v.Value == nil {
+ if v.Status() == 0 || v.BaseValue == nil {
panic(fmt.Sprintf("not properly initialized (state: %v, value: %T)",
- v.Status(), v.Value))
+ v.Status(), v.BaseValue))
}
return Value{idx, v}
}
@@ -656,7 +656,7 @@
}
func remakeFinal(base Value, env *adt.Environment, v adt.Value) Value {
- n := &adt.Vertex{Parent: base.v.Parent, Label: base.v.Label, Value: v}
+ n := &adt.Vertex{Parent: base.v.Parent, Label: base.v.Label, BaseValue: v}
n.UpdateStatus(adt.Finalized)
return makeValue(base.idx, n)
}
@@ -843,7 +843,7 @@
if v.v == nil {
return BottomKind
}
- c := v.v.Value
+ c := v.v.BaseValue
if !v.v.IsConcrete() {
return BottomKind
}
@@ -1061,7 +1061,7 @@
if len(v.v.Conjuncts) == 1 {
return v.v.Conjuncts[0].Source()
}
- return v.v.ActualValue().Source()
+ return v.v.Value().Source()
}
// Err returns the error represented by v or nil v is not an error.
@@ -1100,7 +1100,7 @@
if v.v == nil {
return false // any is neither concrete, not a list or struct.
}
- if b, ok := v.v.Value.(*adt.Bottom); ok {
+ if b, ok := v.v.BaseValue.(*adt.Bottom); ok {
return !b.IsIncomplete()
}
if !adt.IsConcrete(v.v) {
@@ -1125,7 +1125,7 @@
if v.v == nil {
return false
}
- if err, ok := v.v.Value.(*adt.Bottom); ok {
+ if err, ok := v.v.BaseValue.(*adt.Bottom); ok {
return err.Code != codeNotExist
}
return true
@@ -2164,15 +2164,15 @@
var env *adt.Environment
if v.v.IsData() {
- expr = v.v.ActualValue()
+ expr = v.v.Value()
} else {
switch len(v.v.Conjuncts) {
case 0:
- if v.v.Value == nil {
+ if v.v.BaseValue == nil {
return NoOp, []Value{makeValue(v.idx, v.v)}
}
- expr = v.v.ActualValue()
+ expr = v.v.Value()
case 1:
// the default case, processed below.
diff --git a/cue/types_test.go b/cue/types_test.go
index bc08bd0..63d594e 100644
--- a/cue/types_test.go
+++ b/cue/types_test.go
@@ -2499,7 +2499,7 @@
case ListKind:
buf = append(buf, '[')
default:
- if b, _ := v.v.Value.(*adt.Bottom); b != nil {
+ if b, _ := v.v.BaseValue.(*adt.Bottom); b != nil {
s := debugStr(v.ctx(), b)
buf = append(buf, fmt.Sprint(s, ",")...)
return true
diff --git a/internal/core/adt/adt.go b/internal/core/adt/adt.go
index 8336b8c..13038a5 100644
--- a/internal/core/adt/adt.go
+++ b/internal/core/adt/adt.go
@@ -144,7 +144,7 @@
func (x *Vertex) Concreteness() Concreteness {
// Depends on concreteness of value.
- switch v := x.Value.(type) {
+ switch v := x.BaseValue.(type) {
case nil:
return Concrete // Should be indetermined.
diff --git a/internal/core/adt/composite.go b/internal/core/adt/composite.go
index cb73e84..c7c9bdf 100644
--- a/internal/core/adt/composite.go
+++ b/internal/core/adt/composite.go
@@ -178,9 +178,9 @@
// SelfCount is used for tracking self-references.
SelfCount int
- // Value is the value associated with this vertex. For lists and structs
+ // BaseValue is the value associated with this vertex. For lists and structs
// this is a sentinel value indicating its kind.
- Value BaseValue
+ BaseValue BaseValue
// ChildErrors is the collection of all errors of children.
ChildErrors *Bottom
@@ -249,17 +249,17 @@
if v.status > s+1 {
panic(fmt.Sprintf("attempt to regress status from %d to %d", v.Status(), s))
}
- if s == Finalized && v.Value == nil {
+ if s == Finalized && v.BaseValue == nil {
// panic("not finalized")
}
v.status = s
}
-// ActualValue returns the Value of v without definitions if it is a scalar
+// Value returns the Value of v without definitions if it is a scalar
// or itself otherwise.
-func (v *Vertex) ActualValue() Value {
+func (v *Vertex) Value() Value {
// TODO: rename to Value.
- switch x := v.Value.(type) {
+ switch x := v.BaseValue.(type) {
case nil:
return nil
case *StructMarker, *ListMarker:
@@ -267,7 +267,7 @@
case Value:
return x
default:
- panic(fmt.Sprintf("unexpected type %T", v.Value))
+ panic(fmt.Sprintf("unexpected type %T", v.BaseValue))
}
}
@@ -302,7 +302,7 @@
}
w := *v
- w.Value = toDataAll(w.Value)
+ w.BaseValue = toDataAll(w.BaseValue)
w.Arcs = arcs
w.isData = true
w.Conjuncts = make([]Conjunct, len(v.Conjuncts))
@@ -352,7 +352,7 @@
func (v *Vertex) IsErr() bool {
// if v.Status() > Evaluating {
- if _, ok := v.Value.(*Bottom); ok {
+ if _, ok := v.BaseValue.(*Bottom); ok {
return true
}
// }
@@ -361,7 +361,7 @@
func (v *Vertex) Err(c *OpContext, state VertexStatus) *Bottom {
c.Unify(c, v, state)
- if b, ok := v.Value.(*Bottom); ok {
+ if b, ok := v.BaseValue.(*Bottom); ok {
return b
}
return nil
@@ -374,12 +374,12 @@
}
func (v *Vertex) AddErr(ctx *OpContext, b *Bottom) {
- v.Value = CombineErrors(nil, v.ActualValue(), b)
+ v.BaseValue = CombineErrors(nil, v.Value(), b)
v.UpdateStatus(Finalized)
}
func (v *Vertex) SetValue(ctx *OpContext, state VertexStatus, value BaseValue) *Bottom {
- v.Value = value
+ v.BaseValue = value
v.UpdateStatus(state)
return nil
}
@@ -391,8 +391,8 @@
return x
default:
n := &Vertex{
- status: Finalized,
- Value: x,
+ status: Finalized,
+ BaseValue: x,
}
n.AddConjunct(MakeRootConjunct(nil, v))
return n
@@ -406,7 +406,7 @@
if !ok {
return v
}
- return x.ActualValue()
+ return x.Value()
}
// Acceptor is a single interface that reports whether feature f is a valid
@@ -443,10 +443,10 @@
func (v *Vertex) Kind() Kind {
// This is possible when evaluating comprehensions. It is potentially
// not known at this time what the type is.
- if v.Value == nil {
+ if v.BaseValue == nil {
return TopKind
}
- return v.Value.Kind()
+ return v.BaseValue.Kind()
}
func (v *Vertex) OptionalTypes() OptionalType {
@@ -461,7 +461,7 @@
}
func (v *Vertex) IsClosed(ctx *OpContext) bool {
- switch x := v.Value.(type) {
+ switch x := v.BaseValue.(type) {
case *ListMarker:
// TODO: use one mechanism.
if x.IsOpen {
@@ -505,7 +505,7 @@
}
func (v *Vertex) IsList() bool {
- _, ok := v.Value.(*ListMarker)
+ _, ok := v.BaseValue.(*ListMarker)
return ok
}
@@ -547,7 +547,7 @@
// AddConjunct adds the given Conjuncts to v if it doesn't already exist.
func (v *Vertex) AddConjunct(c Conjunct) *Bottom {
- if v.Value != nil {
+ if v.BaseValue != nil {
// TODO: investigate why this happens at all. Removing it seems to
// change the order of fields in some cases.
//
diff --git a/internal/core/adt/context.go b/internal/core/adt/context.go
index a68efa7..3efa8ad 100644
--- a/internal/core/adt/context.go
+++ b/internal/core/adt/context.go
@@ -372,7 +372,7 @@
}
for {
- x, ok := arc.Value.(*Vertex)
+ x, ok := arc.BaseValue.(*Vertex)
if !ok {
break
}
@@ -449,7 +449,7 @@
case *Vertex:
// TODO: return vertex if not disjunction.
- switch t := x.Value.(type) {
+ switch t := x.BaseValue.(type) {
case *Disjunction:
d = t
@@ -460,7 +460,7 @@
if !scalar {
return x, true
}
- return x.ActualValue(), true
+ return x.Value(), true
}
case *Disjunction:
@@ -551,7 +551,7 @@
}
if isIncomplete(arc) {
if arc != nil {
- return arc.ActualValue() // *Bottom
+ return arc.Value() // *Bottom
}
return nil
}
@@ -573,8 +573,8 @@
}
var kind Kind
- if x.Value != nil {
- kind = x.Value.Kind()
+ if x.BaseValue != nil {
+ kind = x.BaseValue.Kind()
}
switch kind {
@@ -676,7 +676,7 @@
node, ok := v.(*Vertex)
if ok {
- v = node.ActualValue()
+ v = node.Value()
}
switch nv := v.(type) {
case nil:
@@ -966,7 +966,7 @@
}
func (c *OpContext) newList(src ast.Node, parent *Vertex) *Vertex {
- return &Vertex{Parent: parent, Value: &ListMarker{}}
+ return &Vertex{Parent: parent, BaseValue: &ListMarker{}}
}
// Str reports a debug string of x.
diff --git a/internal/core/adt/default.go b/internal/core/adt/default.go
index fc922bd..b366596 100644
--- a/internal/core/adt/default.go
+++ b/internal/core/adt/default.go
@@ -43,7 +43,7 @@
// Default returns the default value or itself if there is no default.
func (v *Vertex) Default() *Vertex {
- switch d := v.Value.(type) {
+ switch d := v.BaseValue.(type) {
default:
return v
@@ -57,7 +57,7 @@
w = d.Values[0]
default:
x := *v
- x.Value = &Disjunction{
+ x.BaseValue = &Disjunction{
Src: d.Src,
Values: d.Values[:d.NumDefaults],
NumDefaults: 0,
@@ -79,7 +79,7 @@
w := *v
w.Closed = nil
- w.Value = &m
+ w.BaseValue = &m
return &w
}
}
diff --git a/internal/core/adt/errors.go b/internal/core/adt/errors.go
index 42f5906..23b7217 100644
--- a/internal/core/adt/errors.go
+++ b/internal/core/adt/errors.go
@@ -130,7 +130,7 @@
if v == nil {
return true
}
- if b, ok := v.Value.(*Bottom); ok {
+ if b, ok := v.BaseValue.(*Bottom); ok {
return b.IsIncomplete()
}
return false
@@ -148,10 +148,10 @@
if recursive.IsIncomplete() {
return
}
- x := v.Value
+ x := v.BaseValue
err, _ := x.(*Bottom)
if err == nil {
- v.Value = &Bottom{
+ v.BaseValue = &Bottom{
Code: recursive.Code,
Value: v,
HasRecursive: true,
@@ -166,7 +166,7 @@
err.Code = recursive.Code
}
- v.Value = err
+ v.BaseValue = err
}
// CombineErrors combines two errors that originate at the same Vertex.
diff --git a/internal/core/adt/expr.go b/internal/core/adt/expr.go
index d617af7..4870ca7 100644
--- a/internal/core/adt/expr.go
+++ b/internal/core/adt/expr.go
@@ -977,7 +977,7 @@
func bottom(v Value) *Bottom {
if x, ok := v.(*Vertex); ok {
- v = x.ActualValue()
+ v = x.Value()
}
b, _ := v.(*Bottom)
return b
@@ -1191,8 +1191,8 @@
// TODO: only needed if value label != _
b := &Vertex{
- Label: x.Value,
- Value: a,
+ Label: x.Value,
+ BaseValue: a,
}
n.Arcs = append(n.Arcs, b)
diff --git a/internal/core/compile/builtin.go b/internal/core/compile/builtin.go
index b1e3e5a..b4c282e 100644
--- a/internal/core/compile/builtin.go
+++ b/internal/core/compile/builtin.go
@@ -30,7 +30,7 @@
Func: func(c *adt.OpContext, args []adt.Value) adt.Expr {
v := args[0]
if x, ok := v.(*adt.Vertex); ok {
- switch x.Value.(type) {
+ switch x.BaseValue.(type) {
case nil:
// This should not happen, but be defensive.
return c.NewErrf("unevaluated vertex")
@@ -48,7 +48,7 @@
return c.NewInt64(int64(n), v)
default:
- v = x.ActualValue()
+ v = x.Value()
}
}
@@ -82,7 +82,7 @@
return s
}
v := *s
- v.Value = &adt.StructMarker{NeedClose: true}
+ v.BaseValue = &adt.StructMarker{NeedClose: true}
return &v
},
}
@@ -98,7 +98,7 @@
}
a := []adt.Value{}
for _, c := range list {
- a = append(a, c.ActualValue())
+ a = append(a, c.Value())
}
return &adt.Conjunction{Values: a}
},
diff --git a/internal/core/convert/go.go b/internal/core/convert/go.go
index aedd6ed..c31a469 100644
--- a/internal/core/convert/go.go
+++ b/internal/core/convert/go.go
@@ -450,7 +450,7 @@
if ok {
arc.Label = f
} else {
- arc = &adt.Vertex{Label: f, Value: sub}
+ arc = &adt.Vertex{Label: f, BaseValue: sub}
arc.UpdateStatus(adt.Finalized)
arc.AddConjunct(adt.MakeRootConjunct(nil, sub))
}
@@ -460,7 +460,7 @@
return v
case reflect.Map:
- v := &adt.Vertex{Value: &adt.StructMarker{}}
+ v := &adt.Vertex{BaseValue: &adt.StructMarker{}}
v.SetValue(ctx, adt.Finalized, &adt.StructMarker{})
t := value.Type()
@@ -496,7 +496,7 @@
if ok {
arc.Label = f
} else {
- arc = &adt.Vertex{Label: f, Value: sub}
+ arc = &adt.Vertex{Label: f, BaseValue: sub}
arc.UpdateStatus(adt.Finalized)
arc.AddConjunct(adt.MakeRootConjunct(nil, sub))
}
diff --git a/internal/core/debug/compact.go b/internal/core/debug/compact.go
index 88b9965..d3dae90 100644
--- a/internal/core/debug/compact.go
+++ b/internal/core/debug/compact.go
@@ -34,7 +34,7 @@
func (w *compactPrinter) node(n adt.Node) {
switch x := n.(type) {
case *adt.Vertex:
- if x.Value == nil || (w.cfg.Raw && !x.IsData()) {
+ if x.BaseValue == nil || (w.cfg.Raw && !x.IsData()) {
for i, c := range x.Conjuncts {
if i > 0 {
w.string(" & ")
@@ -44,7 +44,7 @@
return
}
- switch v := x.Value.(type) {
+ switch v := x.BaseValue.(type) {
case *adt.StructMarker:
w.string("{")
for i, a := range x.Arcs {
diff --git a/internal/core/debug/debug.go b/internal/core/debug/debug.go
index cb55cbe..4e2f8a9 100644
--- a/internal/core/debug/debug.go
+++ b/internal/core/debug/debug.go
@@ -147,8 +147,8 @@
switch x := n.(type) {
case *adt.Vertex:
var kind adt.Kind
- if x.Value != nil {
- kind = x.Value.Kind()
+ if x.BaseValue != nil {
+ kind = x.BaseValue.Kind()
}
kindStr := kind.String()
@@ -166,7 +166,7 @@
w.indent += " "
defer func() { w.indent = saved }()
- switch v := x.Value.(type) {
+ switch v := x.BaseValue.(type) {
case nil:
case *adt.Bottom:
// TODO: reuse bottom.
@@ -211,7 +211,7 @@
w.node(a)
}
- if x.Value == nil {
+ if x.BaseValue == nil {
w.indent += "// "
w.string("// ")
for i, c := range x.Conjuncts {
diff --git a/internal/core/eval/closed.go b/internal/core/eval/closed.go
index 3491dfa..8432e79 100644
--- a/internal/core/eval/closed.go
+++ b/internal/core/eval/closed.go
@@ -341,7 +341,7 @@
// subtree into the parent node using InsertSubtree. If not, the conjuncts can
// just be inserted at the current ID.
func isComplexStruct(v *adt.Vertex) bool {
- m, _ := v.Value.(*adt.StructMarker)
+ m, _ := v.BaseValue.(*adt.StructMarker)
if m == nil {
return false
}
diff --git a/internal/core/eval/disjunct.go b/internal/core/eval/disjunct.go
index bef789b..2b8e0fb 100644
--- a/internal/core/eval/disjunct.go
+++ b/internal/core/eval/disjunct.go
@@ -133,7 +133,7 @@
x := n.node
if n.hasErr() {
- err, ok := x.Value.(*adt.Bottom)
+ err, ok := x.BaseValue.(*adt.Bottom)
if !ok {
err = n.getErr()
}
@@ -153,8 +153,8 @@
d := &n.nodeShared.disjunct
result := *n.node
- if result.Value == nil {
- result.Value = n.getValidators()
+ if result.BaseValue == nil {
+ result.BaseValue = n.getValidators()
}
for _, v := range d.Values {
diff --git a/internal/core/eval/equality.go b/internal/core/eval/equality.go
index f98d74b..193d350 100644
--- a/internal/core/eval/equality.go
+++ b/internal/core/eval/equality.go
@@ -69,8 +69,8 @@
// return false
// }
- v, ok1 := x.Value.(adt.Value)
- w, ok2 := y.Value.(adt.Value)
+ v, ok1 := x.BaseValue.(adt.Value)
+ w, ok2 := y.BaseValue.(adt.Value)
if !ok1 && !ok2 {
return true // both are struct or list.
}
diff --git a/internal/core/eval/eval.go b/internal/core/eval/eval.go
index 7602714..30a9adf 100644
--- a/internal/core/eval/eval.go
+++ b/internal/core/eval/eval.go
@@ -130,7 +130,7 @@
}
func (e *Evaluator) Eval(v *adt.Vertex) errors.Error {
- if v.Value == nil {
+ if v.BaseValue == nil {
ctx := adt.NewContext(e.r, e, v)
e.Unify(ctx, v, adt.Partial)
}
@@ -149,11 +149,11 @@
func (e *Evaluator) Evaluate(c *adt.OpContext, v *adt.Vertex) adt.Value {
var result adt.Vertex
- if b, _ := v.Value.(*adt.Bottom); b != nil {
+ if b, _ := v.BaseValue.(*adt.Bottom); b != nil {
return b
}
- if v.Value == nil {
+ if v.BaseValue == nil {
save := *v
// Use node itself to allow for cycle detection.
s := e.evalVertex(c, v, adt.Partial, nil)
@@ -161,10 +161,10 @@
result = *v
- if s.result_.Value != nil { // There is a complete result.
+ if s.result_.BaseValue != nil { // There is a complete result.
*v = s.result_
result = *v
- } else if b, ok := v.Value.(*adt.Bottom); ok {
+ } else if b, ok := v.BaseValue.(*adt.Bottom); ok {
*v = save
return b
} else {
@@ -185,7 +185,7 @@
arcs := v.Arcs
w := &adt.Vertex{
Parent: v.Parent,
- Value: &adt.StructMarker{},
+ BaseValue: &adt.StructMarker{},
Arcs: arcs,
Conjuncts: v.Conjuncts,
Closed: s.result_.Closed,
@@ -201,7 +201,7 @@
clone := *(d.Values[last])
d.Values[last] = &clone
- v.Value = d
+ v.BaseValue = d
v.Arcs = nil
v.Structs = nil // TODO: maybe not do this.
// The conjuncts will have too much information. Better have no
@@ -222,7 +222,7 @@
return d
}
- err, _ := result.Value.(*adt.Bottom)
+ err, _ := result.BaseValue.(*adt.Bottom)
// BEFORE RESTORING, copy the value to return one
// with the temporary arcs.
if !s.done() && (err == nil || err.IsIncomplete()) {
@@ -230,7 +230,7 @@
*v = save
}
if s.hasResult() {
- if b, _ := v.Value.(*adt.Bottom); b != nil {
+ if b, _ := v.BaseValue.(*adt.Bottom); b != nil {
*v = save
return b
}
@@ -244,7 +244,7 @@
// struct numbers correctly. E.g. by using a function that
// gets the concrete value.
//
- if v.Value == nil {
+ if v.BaseValue == nil {
return &result
}
return v
@@ -277,7 +277,7 @@
return
}
- if x := v.Value; x != nil {
+ if x := v.BaseValue; x != nil {
// if state == adt.Partial || x == cycle {
// return
// }
@@ -293,7 +293,7 @@
case len(n.disjunct.Values) > 0:
d := n.createDisjunct()
- v.Value = d
+ v.BaseValue = d
// The conjuncts will have too much information. Better have no
// information than incorrect information.
for _, d := range d.Values {
@@ -319,14 +319,14 @@
v.Closed = newDisjunctionAcceptor(d) // TODO: remove?
default:
- if r := n.result(); r.Value != nil {
+ if r := n.result(); r.BaseValue != nil {
*v = *r
}
}
// Else set it to something.
- if v.Value == nil {
+ if v.BaseValue == nil {
panic("error")
}
@@ -354,7 +354,7 @@
// conflicts at the appropriate place, to allow valid fields to
// be represented normally and, most importantly, to avoid
// recursive processing of a disallowed field.
- v.Value = err
+ v.BaseValue = err
v.SetValue(c, adt.Finalized, err)
return shared
@@ -387,7 +387,7 @@
// as there is evidence what a correct value must be, but before all
// validation has taken place.
*v = saved
- v.Value = cycle
+ v.BaseValue = cycle
if closedInfo != nil {
ci := closedInfo.clone()
@@ -440,8 +440,8 @@
// Handle disjunctions. If there are no disjunctions, this call is
// equivalent to calling n.postDisjunct.
if n.tryDisjuncts(state) {
- if v.Value == nil {
- v.Value = n.getValidators()
+ if v.BaseValue == nil {
+ v.BaseValue = n.getValidators()
}
e.freeNodeContext(n)
@@ -453,7 +453,7 @@
}
func isStruct(v *adt.Vertex) bool {
- _, ok := v.Value.(*adt.StructMarker)
+ _, ok := v.BaseValue.(*adt.StructMarker)
return ok
}
@@ -478,7 +478,7 @@
switch err := n.getErr(); {
case err != nil:
- n.node.Value = err
+ n.node.BaseValue = err
n.errs = nil
default:
@@ -509,9 +509,9 @@
// safeguard.
err = incompleteSentinel
}
- n.node.Value = err
+ n.node.BaseValue = err
} else {
- n.node.Value = nil
+ n.node.BaseValue = nil
}
}
@@ -527,9 +527,9 @@
} else if len(n.node.Structs) > 0 {
markStruct = n.kind&adt.StructKind != 0 && !n.hasTop
}
- v := n.node.ActualValue()
- if n.node.Value == nil && markStruct {
- n.node.Value = &adt.StructMarker{}
+ v := n.node.Value()
+ if n.node.BaseValue == nil && markStruct {
+ n.node.BaseValue = &adt.StructMarker{}
v = n.node
}
if v != nil && adt.IsConcrete(v) {
@@ -570,7 +570,7 @@
}
} else if !ctx.IsTentative() {
- n.node.Value = n.getValidators()
+ n.node.BaseValue = n.getValidators()
}
// else if v == nil {
// n.node.Value = incompleteSentinel
@@ -610,12 +610,12 @@
ctx := n.ctx
if cyclic := n.hasCycle && !n.hasNonCycle; cyclic {
- n.node.Value = adt.CombineErrors(nil,
- n.node.ActualValue(),
+ n.node.BaseValue = adt.CombineErrors(nil,
+ n.node.Value(),
&adt.Bottom{
Code: adt.StructuralCycleError,
Err: ctx.Newf("structural cycle"),
- Value: n.node.ActualValue(),
+ Value: n.node.Value(),
// TODO: probably, this should have the referenced arc.
})
} else {
@@ -627,7 +627,7 @@
n.node.UpdateStatus(adt.EvaluatingArcs)
}
n.eval.Unify(ctx, a, adt.Finalized)
- if err, _ := a.Value.(*adt.Bottom); err != nil {
+ if err, _ := a.BaseValue.(*adt.Bottom); err != nil {
n.node.AddChildError(err)
}
}
@@ -638,10 +638,10 @@
func (n *nodeContext) updateClosedInfo() {
if err := n.getErr(); err != nil {
- if b, _ := n.node.Value.(*adt.Bottom); b != nil {
+ if b, _ := n.node.BaseValue.(*adt.Bottom); b != nil {
err = adt.CombineErrors(nil, b, err)
}
- n.node.Value = err
+ n.node.BaseValue = err
// TODO: add return: if evaluation of arcs is important it can be done
// later. Logically we're done.
}
@@ -671,7 +671,7 @@
for _, a := range n.node.Arcs {
if !accept.Accept(n.ctx, a.Label) {
label := a.Label.SelectorString(ctx)
- n.node.Value = ctx.NewErrf(
+ n.node.BaseValue = ctx.NewErrf(
"field `%s` not allowed by Acceptor", label)
}
}
@@ -687,8 +687,8 @@
func isEvaluating(v *adt.Vertex) bool {
isCycle := v.Status() == adt.Evaluating
- if isCycle != (v.Value == cycle) {
- panic(fmt.Sprintf("cycle data of sync %d vs %#v", v.Status(), v.Value))
+ if isCycle != (v.BaseValue == cycle) {
+ panic(fmt.Sprintf("cycle data of sync %d vs %#v", v.Status(), v.BaseValue))
}
return isCycle
}
@@ -1186,7 +1186,7 @@
if v, ok := val.(*adt.Vertex); ok {
// Handle generated disjunctions (as in the 'or' builtin).
// These come as a Vertex, but should not be added as a value.
- b, ok := v.Value.(*adt.Bottom)
+ b, ok := v.BaseValue.(*adt.Bottom)
if ok && b.IsIncomplete() && len(v.Conjuncts) > 0 {
for _, c := range v.Conjuncts {
c.CloseID = closeID
@@ -1387,7 +1387,7 @@
ctx := n.ctx
if x, ok := v.(*adt.Vertex); ok {
- if m, ok := x.Value.(*adt.StructMarker); ok {
+ if m, ok := x.BaseValue.(*adt.StructMarker); ok {
n.aStruct = x
n.aStructID = id
if m.NeedClose {
@@ -1418,7 +1418,7 @@
}
// TODO: evaluate value?
- switch v := x.Value.(type) {
+ switch v := x.BaseValue.(type) {
default:
panic("invalid value")
@@ -1901,7 +1901,7 @@
max := 0
var maxNode adt.Expr
- if m, ok := n.node.Value.(*adt.ListMarker); ok {
+ if m, ok := n.node.BaseValue.(*adt.ListMarker); ok {
isOpen = m.IsOpen
max = len(n.node.Arcs)
}
@@ -1935,7 +1935,7 @@
for _, a := range elems {
if a.Conjuncts == nil {
- x := a.Value.(adt.Value)
+ x := a.BaseValue.(adt.Value)
n.insertField(a.Label, adt.MakeConjunct(nil, x, 0))
continue
}
@@ -2060,7 +2060,7 @@
ci.isList = true
ci.openList = isOpen
- if m, ok := n.node.Value.(*adt.ListMarker); !ok {
+ if m, ok := n.node.BaseValue.(*adt.ListMarker); !ok {
n.node.SetValue(c, adt.Partial, &adt.ListMarker{
Src: ast.NewBinExpr(token.AND, sources...),
IsOpen: isOpen,
diff --git a/internal/core/eval/optionals.go b/internal/core/eval/optionals.go
index 765e341..47ffe47 100644
--- a/internal/core/eval/optionals.go
+++ b/internal/core/eval/optionals.go
@@ -253,7 +253,7 @@
label := f.ToValue(c)
v.AddConjunct(adt.MakeRootConjunct(m.Env, label))
v.Finalize(c)
- b, _ := v.Value.(*adt.Bottom)
+ b, _ := v.BaseValue.(*adt.Bottom)
return b == nil
}
diff --git a/internal/core/export/expr.go b/internal/core/export/expr.go
index 99cf2cf..b61bb82 100644
--- a/internal/core/export/expr.go
+++ b/internal/core/export/expr.go
@@ -280,7 +280,7 @@
case *adt.Vertex:
e.structs = append(e.structs, v.Structs...)
- switch y := v.Value.(type) {
+ switch y := v.BaseValue.(type) {
case *adt.ListMarker:
a := []ast.Expr{}
for _, x := range v.Elems() {
diff --git a/internal/core/export/value.go b/internal/core/export/value.go
index 8583fd7..a5a6ae2 100644
--- a/internal/core/export/value.go
+++ b/internal/core/export/value.go
@@ -29,7 +29,7 @@
case *adt.Vertex:
return e.vertex(x)
case adt.Value:
- a := &adt.Vertex{Value: x}
+ a := &adt.Vertex{BaseValue: x}
return e.vertex(a)
default:
panic("unreachable")
@@ -41,7 +41,7 @@
// value with a reference in graph mode.
func (e *exporter) vertex(n *adt.Vertex) (result ast.Expr) {
- switch x := n.Value.(type) {
+ switch x := n.BaseValue.(type) {
case nil:
// bare
case *adt.StructMarker:
@@ -333,7 +333,7 @@
}()
showRegular := false
- switch x := v.Value.(type) {
+ switch x := v.BaseValue.(type) {
case *adt.StructMarker:
showRegular = true
case *adt.ListMarker:
diff --git a/internal/core/subsume/value.go b/internal/core/subsume/value.go
index f050b81..c5bfd27 100644
--- a/internal/core/subsume/value.go
+++ b/internal/core/subsume/value.go
@@ -47,7 +47,7 @@
if a, ok := a.(*adt.Vertex); ok {
return s.vertices(a, b)
}
- if v, ok := b.Value.(adt.Value); ok {
+ if v, ok := b.BaseValue.(adt.Value); ok {
// Safe to ignore arcs of w.
return s.values(a, v)
}
@@ -134,7 +134,7 @@
}
// TODO: Under what conditions can we cast to the value?
- if v, _ := x.Value.(adt.Value); v != nil {
+ if v, _ := x.BaseValue.(adt.Value); v != nil {
return s.values(v, b)
}
return false
diff --git a/internal/core/subsume/vertex.go b/internal/core/subsume/vertex.go
index 8041bc6..4bc549c 100644
--- a/internal/core/subsume/vertex.go
+++ b/internal/core/subsume/vertex.go
@@ -36,7 +36,7 @@
y = y.Default()
}
- if b, _ := y.Value.(*adt.Bottom); b != nil {
+ if b, _ := y.BaseValue.(*adt.Bottom); b != nil {
// If the value is incomplete, the error is not final. So either check
// structural equivalence or return an error.
return !b.IsIncomplete()
@@ -46,7 +46,7 @@
final := y.IsData() || s.Final
- switch v := x.Value.(type) {
+ switch v := x.BaseValue.(type) {
case *adt.Bottom:
return false
@@ -62,13 +62,13 @@
return true
case *adt.StructMarker:
- _, ok := y.Value.(*adt.StructMarker)
+ _, ok := y.BaseValue.(*adt.StructMarker)
if !ok {
return false
}
case adt.Value:
- if !s.values(v, y.ActualValue()) {
+ if !s.values(v, y.Value()) {
return false
}
diff --git a/internal/core/validate/validate.go b/internal/core/validate/validate.go
index fe549ae..e1addf4 100644
--- a/internal/core/validate/validate.go
+++ b/internal/core/validate/validate.go
@@ -67,7 +67,7 @@
func (v *validator) validate(x *adt.Vertex) {
defer v.ctx.PopArc(v.ctx.PushArc(x))
- if b, _ := x.Value.(*adt.Bottom); b != nil {
+ if b, _ := x.BaseValue.(*adt.Bottom); b != nil {
switch b.Code {
case adt.CycleError:
if v.checkConcrete() || v.DisallowCycles {
@@ -89,7 +89,7 @@
} else if v.checkConcrete() {
x := x.Default()
if !adt.IsConcrete(x) {
- x := x.ActualValue()
+ x := x.Value()
v.add(&adt.Bottom{
Code: adt.IncompleteError,
Err: v.ctx.Newf("incomplete value %v", v.ctx.Str(x)),
diff --git a/tools/flow/tasks.go b/tools/flow/tasks.go
index b301c9b..afafe86 100644
--- a/tools/flow/tasks.go
+++ b/tools/flow/tasks.go
@@ -162,7 +162,7 @@
n := d.Node
for ; n != nil; n = n.Parent {
if c.cfg.IgnoreConcrete && n.IsConcrete() {
- if k := n.Value.Kind(); k != adt.StructKind && k != adt.ListKind {
+ if k := n.BaseValue.Kind(); k != adt.StructKind && k != adt.ListKind {
return nil
}
}