Marcel van Lohuizen | d96ad3d | 2018-12-10 15:30:20 +0100 | [diff] [blame] | 1 | // Copyright 2018 The 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 internal // import "cuelang.org/go/internal" |
| 16 | |
| 17 | // TODO: refactor packages as to make this package unnecessary. |
| 18 | |
| 19 | // DebugStr prints a syntax node. |
| 20 | var DebugStr func(x interface{}) string |
Marcel van Lohuizen | 17157ea | 2018-12-11 10:41:10 +0100 | [diff] [blame] | 21 | |
| 22 | // EvalExpr evaluates an expression within an existing struct value. |
| 23 | // Identifiers only resolve to values defined within the struct. |
| 24 | // |
| 25 | // Expressions may refer to builtin packages if they can be uniquely identified |
| 26 | // |
| 27 | // Both value and result are of type cue.Value, but are an interface to prevent |
| 28 | // cyclic dependencies. |
| 29 | // |
| 30 | // TODO: extract interface |
| 31 | var EvalExpr func(value, expr interface{}) (result interface{}) |
Marcel van Lohuizen | 2b85fc8 | 2019-04-03 22:43:29 +0200 | [diff] [blame] | 32 | |
| 33 | // FromGoValue converts an arbitrary Go value to the corresponding CUE value. |
| 34 | // instance must be of type *cue.Instance. |
| 35 | // The returned value is a cue.Value, which the caller must cast to. |
| 36 | var FromGoValue func(instance, x interface{}) interface{} |
| 37 | |
| 38 | // FromGoType converts an arbitrary Go type to the corresponding CUE value. |
| 39 | // instance must be of type *cue.Instance. |
| 40 | // The returned value is a cue.Value, which the caller must cast to. |
| 41 | var FromGoType func(instance, x interface{}) interface{} |
Marcel van Lohuizen | e9fd214 | 2019-04-12 15:46:31 +0200 | [diff] [blame] | 42 | |
| 43 | // DropOptional is a blanket override of handling optional values during |
| 44 | // compilation. TODO: should we make this a build option? |
| 45 | var DropOptional bool |
Marcel van Lohuizen | f813285 | 2019-04-26 12:16:18 +0200 | [diff] [blame] | 46 | |
| 47 | // UnifyBuiltin returns the given Value unified with the given builtin template. |
| 48 | var UnifyBuiltin func(v interface{}, kind string) interface{} |