This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/dagger/cc/cc.go
Solomon Hykes 612a25fb9f Simplify code by moving polyfill cue compiler to sub-package cc
Signed-off-by: Solomon Hykes <sh.github.6811@hykes.org>
2021-02-08 15:10:32 -08:00

54 lines
738 B
Go

package cc
import (
"cuelang.org/go/cue"
cueerrors "cuelang.org/go/cue/errors"
"github.com/pkg/errors"
)
var (
// Shared global compiler
cc = &Compiler{}
)
func Compile(name string, src interface{}) (*Value, error) {
return cc.Compile(name, src)
}
func EmptyStruct() (*Value, error) {
return cc.EmptyStruct()
}
// FIXME can be refactored away now?
func Wrap(v cue.Value, inst *cue.Instance) *Value {
return cc.Wrap(v, inst)
}
func Cue() *cue.Runtime {
return cc.Cue()
}
func Err(err error) error {
if err == nil {
return nil
}
return errors.New(cueerrors.Details(err, &cueerrors.Config{}))
}
func Lock() {
cc.Lock()
}
func Unlock() {
cc.Unlock()
}
func RLock() {
cc.RLock()
}
func RUnlock() {
cc.RUnlock()
}