Module: ParseJS::Visitor::ScopeManager
- Included in:
- AST::ProcessVariables
- Defined in:
- lib/parsejs/visitor.rb
Instance Method Summary collapse
- #current_scope ⇒ Object
- #initialize ⇒ Object
- #push_child(scope) ⇒ Object
- #visit_FunctionDeclaration(decl) ⇒ Object
- #visit_Program(program) ⇒ Object
Instance Method Details
#current_scope ⇒ Object
230 231 232 |
# File 'lib/parsejs/visitor.rb', line 230 def current_scope @scopes.last end |
#initialize ⇒ Object
225 226 227 228 |
# File 'lib/parsejs/visitor.rb', line 225 def initialize(*) @scopes = [] super end |
#push_child(scope) ⇒ Object
234 235 236 237 238 |
# File 'lib/parsejs/visitor.rb', line 234 def push_child(scope) current_scope.child_scopes ||= [] current_scope.child_scopes << scope scope.parent_scope = current_scope end |
#visit_FunctionDeclaration(decl) ⇒ Object
247 248 249 250 251 252 253 254 |
# File 'lib/parsejs/visitor.rb', line 247 def visit_FunctionDeclaration(decl) push_child(decl) @scopes << decl ret = super @scopes.pop ret end |
#visit_Program(program) ⇒ Object
240 241 242 243 244 245 |
# File 'lib/parsejs/visitor.rb', line 240 def visit_Program(program) @scopes << program ret = super @scopes.pop ret end |