Class: RBelly::Visitors::FunctionVisitor
- Defined in:
- lib/rbelly/visitors/function_visitor.rb
Constant Summary
Constants inherited from Visitor
Visitor::ALL_NODES, Visitor::ARRAY_VALUE_NODES, Visitor::BELLEJS_FUNC_NODES, Visitor::BELLEJS_VAR_NODES, Visitor::BINARY_NODES, Visitor::CLASS_NODES, Visitor::CONDITIONAL_NODES, Visitor::FUNC_CALL_NODES, Visitor::FUNC_DECL_NODES, Visitor::NAME_VALUE_NODES, Visitor::PREFIX_POSTFIX_NODES, Visitor::SINGLE_VALUE_NODES, Visitor::TERMINAL_NODES
Instance Attribute Summary collapse
-
#scope_chain ⇒ Object
readonly
Returns the value of attribute scope_chain.
Instance Method Summary collapse
-
#initialize(scope) ⇒ FunctionVisitor
constructor
A new instance of FunctionVisitor.
- #visit_ClassNode(o) ⇒ Object
- #visit_FunctionDeclNode(o) ⇒ Object
- #visit_SourceElementsNode(o) ⇒ Object
Methods inherited from Visitor
#accept, #visit_BracketAccessorNode, #visit_DotAccessorNode, #visit_ForInNode, #visit_ForNode, #visit_TryNode
Constructor Details
#initialize(scope) ⇒ FunctionVisitor
Returns a new instance of FunctionVisitor.
5 6 7 8 |
# File 'lib/rbelly/visitors/function_visitor.rb', line 5 def initialize(scope) super() @scope_chain = scope end |
Instance Attribute Details
#scope_chain ⇒ Object (readonly)
Returns the value of attribute scope_chain.
4 5 6 |
# File 'lib/rbelly/visitors/function_visitor.rb', line 4 def scope_chain @scope_chain end |
Instance Method Details
#visit_ClassNode(o) ⇒ Object
20 21 22 23 24 |
# File 'lib/rbelly/visitors/function_visitor.rb', line 20 def visit_ClassNode(o) if o.value scope_chain[o.value].value = RBelly::BELLEJS::Class.new(o.class_body) end end |
#visit_FunctionDeclNode(o) ⇒ Object
14 15 16 17 18 |
# File 'lib/rbelly/visitors/function_visitor.rb', line 14 def visit_FunctionDeclNode(o) if o.value scope_chain[o.value].value = RBelly::JS::Function.new(o.function_body, o.arguments) end end |
#visit_SourceElementsNode(o) ⇒ Object
10 11 12 |
# File 'lib/rbelly/visitors/function_visitor.rb', line 10 def visit_SourceElementsNode(o) o.value.each { |x| x.accept(self) } end |