blob: 6133bace44c142c1bc24a264f072a6720d119564 [file] [log] [blame]
Marcel van Lohuizend96ad3d2018-12-10 15:30:20 +01001// 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
15package internal // import "cuelang.org/go/internal"
16
17// TODO: refactor packages as to make this package unnecessary.
18
19// DebugStr prints a syntax node.
20var DebugStr func(x interface{}) string
Marcel van Lohuizen17157ea2018-12-11 10:41:10 +010021
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
31var EvalExpr func(value, expr interface{}) (result interface{})
Marcel van Lohuizen2b85fc82019-04-03 22:43:29 +020032
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.
36var 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.
41var FromGoType func(instance, x interface{}) interface{}
Marcel van Lohuizene9fd2142019-04-12 15:46:31 +020042
43// DropOptional is a blanket override of handling optional values during
44// compilation. TODO: should we make this a build option?
45var DropOptional bool
Marcel van Lohuizenf8132852019-04-26 12:16:18 +020046
47// UnifyBuiltin returns the given Value unified with the given builtin template.
48var UnifyBuiltin func(v interface{}, kind string) interface{}