FindGlobalIdent finds an identifier in the global scope, ignoring all local scopes.
(name string)
| 94 | |
| 95 | // FindGlobalIdent finds an identifier in the global scope, ignoring all local scopes. |
| 96 | func (s *Scopes) FindGlobalIdent(name string) *decls.VariableDecl { |
| 97 | scope := s |
| 98 | for scope.parent != nil { |
| 99 | scope = scope.parent |
| 100 | } |
| 101 | if ident := scope.FindIdentInScope(name); ident != nil { |
| 102 | return ident |
| 103 | } |
| 104 | if scope.inherited != nil { |
| 105 | return scope.inherited.FindGlobalIdent(name) |
| 106 | } |
| 107 | return nil |
| 108 | } |
| 109 | |
| 110 | // SetFunction adds the function Decl to the current scope. |
| 111 | // Note: Any previous entry for a function in the current scope with the same name is overwritten. |
no test coverage detected