dfafa6fc00
Expressions can now be evaluated within an "EvalContext", which provides the variable and function scopes. The JSON implementation of this currently ignores the context entirely and just returns literal values, since we've not yet implemented the template language parser that would be needed for the JSON parser to properly support expressions.
20 lines
501 B
Go
20 lines
501 B
Go
package zcl
|
|
|
|
import (
|
|
"github.com/apparentlymart/go-cty/cty"
|
|
"github.com/apparentlymart/go-cty/cty/function"
|
|
)
|
|
|
|
// An EvalContext provides the variables and functions that should be used
|
|
// to evaluate an expression.
|
|
type EvalContext struct {
|
|
Variables map[string]cty.Value
|
|
Functions map[string]function.Function
|
|
parent *EvalContext
|
|
}
|
|
|
|
// NewChild returns a new EvalContext that is a child of the receiver.
|
|
func (ctx *EvalContext) NewChild() *EvalContext {
|
|
return &EvalContext{parent: ctx}
|
|
}
|