MCPcopy
hub / github.com/expr-lang/expr / ident

Method ident

checker/checker.go:263–289  ·  view source on GitHub ↗

ident method returns type of environment variable, builtin or function.

(node ast.Node, name string, strict, builtins bool)

Source from the content-addressed store, hash-verified

261
262// ident method returns type of environment variable, builtin or function.
263func (v *Checker) ident(node ast.Node, name string, strict, builtins bool) Nature {
264 if nt, ok := v.config.Env.Get(&v.config.NtCache, name); ok {
265 return nt
266 }
267 if builtins {
268 if fn, ok := v.config.Functions[name]; ok {
269 nt := v.config.NtCache.FromType(fn.Type())
270 if nt.TypeData == nil {
271 nt.TypeData = new(TypeData)
272 }
273 nt.TypeData.Func = fn
274 return nt
275 }
276 if fn, ok := v.config.Builtins[name]; ok {
277 nt := v.config.NtCache.FromType(fn.Type())
278 if nt.TypeData == nil {
279 nt.TypeData = new(TypeData)
280 }
281 nt.TypeData.Func = fn
282 return nt
283 }
284 }
285 if v.config.Strict && strict {
286 return v.error(node, "unknown name %s", name)
287 }
288 return Nature{}
289}
290
291func (v *Checker) unaryNode(node *ast.UnaryNode) Nature {
292 nt := v.visit(node.Node)

Callers 2

identifierNodeMethod · 0.95
memberNodeMethod · 0.95

Implementers 3

Configconf/config.go
Checkerchecker/checker.go
OperatorOverloadingpatcher/operator_override.go

Calls 4

errorMethod · 0.95
FromTypeMethod · 0.80
GetMethod · 0.65
TypeMethod · 0.65

Tested by

no test coverage detected