* @param {string} name * @returns {IDeclaration}
(name)
| 99 | * @returns {IDeclaration} |
| 100 | */ |
| 101 | getDeclaration(name) { |
| 102 | const { currentContext, currentFunctionContext, runningContexts } = this; |
| 103 | const declaration = currentContext[name] || currentFunctionContext[name] || null; |
| 104 | |
| 105 | if ( |
| 106 | !declaration && |
| 107 | currentContext === currentFunctionContext && |
| 108 | runningContexts.length > 0 |
| 109 | ) { |
| 110 | const previousRunningContext = runningContexts[runningContexts.length - 2]; |
| 111 | if (previousRunningContext[name]) { |
| 112 | return previousRunningContext[name]; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | return declaration; |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * Recursively scans AST for declarations and functions, and add them to their respective context |