Documentation
¶
Overview ¶
Package reference handles resolving references across CQL libraries and locally within a library for the CQL Engine parser and interpreter.
Index ¶
- type Def
- type Func
- type Resolver
- func (r *Resolver[T, F]) Alias(name string, a T) error
- func (r *Resolver[T, F]) ClearDefs()
- func (r *Resolver[T, F]) Define(d *Def[T]) error
- func (r *Resolver[T, F]) DefineBuiltinFunc(name string, operands []types.IType, f F) error
- func (r *Resolver[T, F]) DefineFunc(f *Func[F]) error
- func (r *Resolver[T, F]) EnterScope()
- func (r *Resolver[T, F]) ExitScope()
- func (r *Resolver[T, F]) IncludeLibrary(m *model.LibraryIdentifier, validateIsUnique bool) error
- func (r *Resolver[T, F]) PublicAndPrivateDefs() (map[result.LibKey]map[string]T, error)
- func (r *Resolver[T, F]) PublicDefs() (map[result.LibKey]map[string]T, error)
- func (r *Resolver[T, F]) ResolveExactGlobalFunc(libName string, defName string, operands []types.IType, calledFluently bool, ...) (F, error)
- func (r *Resolver[T, F]) ResolveExactLocalFunc(name string, operands []types.IType, calledFluently bool, ...) (F, error)
- func (r *Resolver[T, F]) ResolveGlobal(libName string, defName string) (T, error)
- func (r *Resolver[T, F]) ResolveGlobalFunc(libName string, defName string, operands []model.IExpression, ...) (*convert.MatchedOverload[F], error)
- func (r *Resolver[T, F]) ResolveInclude(name string) *model.LibraryIdentifier
- func (r *Resolver[T, F]) ResolveLocal(name string) (T, error)
- func (r *Resolver[T, F]) ResolveLocalFunc(name string, operands []model.IExpression, calledFluently bool, ...) (*convert.MatchedOverload[F], error)
- func (r *Resolver[T, F]) SetCurrentLibrary(m *model.LibraryIdentifier) error
- func (r *Resolver[T, F]) SetCurrentUnnamed()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Def ¶
type Def[T any] struct { Name string Result T IsPublic bool // ValidateIsUnique validates this definition name is unique. It is turned off by the interpreter // to improve performance. ValidateIsUnique bool }
Def holds the information needed to define a definition.
type Func ¶
type Func[F any] struct { Name string Operands []types.IType Result F IsPublic bool IsFluent bool // ValidateIsUnique validates this function name + signature is unique. It is turned off by the // interpreter to improve performance. ValidateIsUnique bool }
Func holds the information needed to define a function.
type Resolver ¶
Resolver tracks definitions (ExpressionDefs, ParameterDefs, ValueSetDefs...) and aliases across CQL libraries and locally within a CQL library. When a definition is created the resolver stores a result (for the parser it stores a model.IExpression and for the interpreter a result.Value). When a reference to a definition is resolved the result is returned. Resolvers should not be shared between the parser and interpreter. A new empty resolver should be passed to the interpreter.
func NewResolver ¶
NewResolver creates a blank resolver with zero global references. Type T is the type saved and resolved for definitions. Type F is the type saved and resolved for functions.
func (*Resolver[T, F]) Alias ¶
Alias creates a new alias within the current scope. When EndScope is called all aliases in the scope will be removed. Calling ResolveLocal with the same name will return the stored type t. Names must be unique within the CQL library.
func (*Resolver[T, F]) ClearDefs ¶
func (r *Resolver[T, F]) ClearDefs()
ClearDefs clears everything except for the built-in functions.
func (*Resolver[T, F]) Define ¶
Define creates a new definition returning an error if the name already exists. Calling ResolveLocal with the same name will return the stored type t. Names must be unique within the CQL library. Names must be unique regardless of type, for example a ValueSet and Parameter cannot have the same name.
func (*Resolver[T, F]) DefineBuiltinFunc ¶
DefineBuiltinFunc creates a new built-in function, returning an error if the function signature already exists. All built in functions must be defined before CQL libraries are parsed. Only the Parser defines built-in functions. TODO(b/301606416): Refactor DefineBuiltinFunc into the initialization of the reference resolver.
func (*Resolver[T, F]) DefineFunc ¶
DefineFunc creates a new user defined function returning an error if the function signature already exists. Calling ResolveLocalFunc with the same name and operands will return the stored type f. Functions can be overloaded with the same name, but must have a unique combination of name and operands.
func (*Resolver[T, F]) EnterScope ¶
func (r *Resolver[T, F]) EnterScope()
EnterScope starts a new scope for aliases. EndScope should be called to remove all aliases in this scope.
func (*Resolver[T, F]) ExitScope ¶
func (r *Resolver[T, F]) ExitScope()
ExitScope clears any aliases created since the last call to EnterScope.
func (*Resolver[T, F]) IncludeLibrary ¶
func (r *Resolver[T, F]) IncludeLibrary(m *model.LibraryIdentifier, validateIsUnique bool) error
IncludeLibrary should be called for each include statement in the CQL library. IncludeLibrary must be called before a reference to that library is resolved. ValidateIsUnique validates this include is unique. It is turned off by the interpreter to improve performance.
func (*Resolver[T, F]) PublicAndPrivateDefs ¶
PublicAndPrivateDefs should not be used for normal engine execution. Returns all public and private definitions, including definitions in unnamed libraries. Unnamed libraries are converted to UnnamedLibrary-0 1.0, UnnamedLibrary-1 1.0 and so on which can clash with any named libraries that happened to be named UnnamedLibrary-0. Therefore this should only be used for unit tests and the CQL REPL.
func (*Resolver[T, F]) PublicDefs ¶
PublicDefs returns the public definitions stored in the reference resolver.
func (*Resolver[T, F]) ResolveExactGlobalFunc ¶
func (r *Resolver[T, F]) ResolveExactGlobalFunc(libName string, defName string, operands []types.IType, calledFluently bool, modelInfo *modelinfo.ModelInfos) (F, error)
ResolveExactGlobalFunc resolves a reference to a user defined function in an included CQL library without any implicit conversions.
func (*Resolver[T, F]) ResolveExactLocalFunc ¶
func (r *Resolver[T, F]) ResolveExactLocalFunc(name string, operands []types.IType, calledFluently bool, modelInfo *modelinfo.ModelInfos) (F, error)
ResolveExactLocalFunc resolves a reference to a user defined function in the current CQL library without any implicit conversions.
func (*Resolver[T, F]) ResolveGlobal ¶
ResolveGlobal resolves a reference to a definition in an included CQL library.
func (*Resolver[T, F]) ResolveGlobalFunc ¶
func (r *Resolver[T, F]) ResolveGlobalFunc(libName string, defName string, operands []model.IExpression, calledFluently bool, modelInfo *modelinfo.ModelInfos) (*convert.MatchedOverload[F], error)
ResolveGlobalFunc resolves a reference to a user defined function in an included CQL library.
func (*Resolver[T, F]) ResolveInclude ¶
func (r *Resolver[T, F]) ResolveInclude(name string) *model.LibraryIdentifier
ResolveInclude takes the local name of an included library and returns the fully qualified identifier or nil if this local name does not exist.
func (*Resolver[T, F]) ResolveLocal ¶
ResolveLocal resolves a reference to a definition in the current CQL library.
func (*Resolver[T, F]) ResolveLocalFunc ¶
func (r *Resolver[T, F]) ResolveLocalFunc(name string, operands []model.IExpression, calledFluently bool, modelInfo *modelinfo.ModelInfos) (*convert.MatchedOverload[F], error)
ResolveLocalFunc resolves a reference to a user defined or built-in function in the current CQL library.
func (*Resolver[T, F]) SetCurrentLibrary ¶
func (r *Resolver[T, F]) SetCurrentLibrary(m *model.LibraryIdentifier) error
SetCurrentLibrary sets the current library based on the library definition. Either SetCurrentLibrary or SetCurrentUnnamed must be called before creating and resolving references.
func (*Resolver[T, F]) SetCurrentUnnamed ¶
func (r *Resolver[T, F]) SetCurrentUnnamed()
SetCurrentUnnamed should be called if the CQL library does not have a library definition. All definitions in unnamed libraries are private.