github.com/solo-io/cue@v0.4.7/internal/core/adt/doc.go (about) 1 // Copyright 2020 CUE Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Package adt represents partially and fully evaluated CUE types. 16 // 17 // This package introduces several categories of types that indicate some set of 18 // values that may be used in a certain situation. Concrete types may belong to 19 // multiple categories. 20 // 21 // 22 // Abstract Types 23 // 24 // The following types describe the a place where a value may be used: 25 // 26 // Decl a value than can be used as a StructLit element. 27 // Elem a value than can be used as a ListLit element. 28 // Expr represents an Expr in the CUE grammar. 29 // Value a fully evaluated value that has no references (except for 30 // children in composite values). 31 // Node any of the above values. 32 // 33 // The following types categorize nodes by function: 34 // 35 // Resolver a reference to position in the result tree. 36 // Evaluator evaluates to 1 value. 37 // Yielder evaluates to 0 or more values. 38 // Validator validates another value. 39 // 40 // 41 // Reference resolution algorithm 42 // 43 // A Resolver is resolved within the context of an Environment. In CUE, a 44 // reference is evaluated by substituting it with a copy of the value to which 45 // it refers. If the copied value itself contains references we can distinguish 46 // two different cases. References that refer to values within the copied 47 // reference (not regarding selectors) will henceforth point to the copied node. 48 // References that point to outside the referened value will keep referring to 49 // their original value. 50 // 51 // a: b: { 52 // c: int 53 // d: c 54 // e: f 55 // } 56 // f: 4 57 // g: a.b { // d.c points to inside the referred value, e.f, not. 58 // c: 3 59 // } 60 // 61 // The implementation doesn't actually copy referred values, but rather resolves 62 // references with the aid of an Environment. During compile time, each 63 // references is associated with the label and a number indicating in which 64 // parent scope (offset from the current) this label needs to be looked up. An 65 // Environment keeps track of the point at which a value was referenced, 66 // providing enough information to look up the labeled value. This Environment 67 // is the identical for all references within a fields conjunct. Often, an 68 // Environment can even be shared among conjuncts. 69 // 70 // 71 // Values 72 // 73 // Values are fully evaluated expressions. As this means that all references 74 // will have been eliminated, Values are fully defined without the need for an 75 // Environment. Additionally, Values represent a fully evaluated form, stripped 76 // of any comprehensions, optional fields or embeddings. 77 // 78 package adt