ident method returns type of environment variable, builtin or function.
(node ast.Node, name string, strict, builtins bool)
| 261 | |
| 262 | // ident method returns type of environment variable, builtin or function. |
| 263 | func (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 | |
| 291 | func (v *Checker) unaryNode(node *ast.UnaryNode) Nature { |
| 292 | nt := v.visit(node.Node) |
no test coverage detected