Class: RBelly::Visitors::Visitor
- Inherits:
-
Object
- Object
- RBelly::Visitors::Visitor
show all
- Defined in:
- lib/rbelly/visitors/visitor.rb
Constant Summary
collapse
- TERMINAL_NODES =
%w{
Break Continue EmptyStatement False Null Number Parameter Regexp Resolve
String This True Public Private
}
- SINGLE_VALUE_NODES =
%w{
Parenthetical AssignExpr BitwiseNot Block Delete Element ExpressionStatement
FunctionBody ClassBody LogicalNot Return Throw TypeOf UnaryMinus UnaryPlus Void Import Extends
}
- BINARY_NODES =
%w{
Add BitAnd BitOr BitXOr CaseClause Comma Divide DoWhile Equal Greater
GreaterOrEqual In InstanceOf LeftShift Less LessOrEqual LogicalAnd
LogicalOr Modulus Multiply NotEqual NotStrictEqual OpAndEqual
OpDivideEqual OpEqual OpLShiftEqual OpMinusEqual OpModEqual
OpMultiplyEqual OpOrEqual OpPlusEqual OpRShiftEqual OpURShiftEqual
OpXOrEqual RightShift StrictEqual Subtract Switch UnsignedRightShift
While With
}
- ARRAY_VALUE_NODES =
%w{
Arguments Array CaseBlock ConstStatement ObjectLiteral SourceElements
VarStatement
}
- NAME_VALUE_NODES =
%w{
Label Property GetterProperty SetterProperty VarDecl
}
- PREFIX_POSTFIX_NODES =
%w{ Postfix Prefix }
- CONDITIONAL_NODES =
%w{ If Conditional }
- FUNC_CALL_NODES =
%w{ NewExpr FunctionCall }
- FUNC_DECL_NODES =
%w{ FunctionExpr FunctionDecl }
- CLASS_NODES =
%w{ Class }
- BELLEJS_VAR_NODES =
%w{ BellejsVarStatement }
- BELLEJS_FUNC_NODES =
%w{ BellejsFuncStatement }
- ALL_NODES =
%w{ For ForIn Try BracketAccessor DotAccessor } +
TERMINAL_NODES + SINGLE_VALUE_NODES + BINARY_NODES + ARRAY_VALUE_NODES +
NAME_VALUE_NODES + PREFIX_POSTFIX_NODES + CONDITIONAL_NODES +
FUNC_CALL_NODES + FUNC_DECL_NODES + CLASS_NODES + BELLEJS_VAR_NODES
Instance Method Summary
collapse
Instance Method Details
#accept(target) ⇒ Object
40
41
42
|
# File 'lib/rbelly/visitors/visitor.rb', line 40
def accept(target)
target.accept(self)
end
|
#visit_BracketAccessorNode(o) ⇒ Object
156
157
158
159
160
161
|
# File 'lib/rbelly/visitors/visitor.rb', line 156
def visit_BracketAccessorNode(o)
[
o.value.accept(self),
o.accessor.accept(self)
]
end
|
#visit_DotAccessorNode(o) ⇒ Object
163
164
165
|
# File 'lib/rbelly/visitors/visitor.rb', line 163
def visit_DotAccessorNode(o)
o.value.accept(self)
end
|
#visit_ForInNode(o) ⇒ Object
139
140
141
142
143
144
145
|
# File 'lib/rbelly/visitors/visitor.rb', line 139
def visit_ForInNode(o)
[
o.left.accept(self),
o.right.accept(self),
o.value.accept(self)
]
end
|
#visit_ForNode(o) ⇒ Object
130
131
132
133
134
135
136
137
|
# File 'lib/rbelly/visitors/visitor.rb', line 130
def visit_ForNode(o)
[
o.init ? o.init.accept(self) : nil,
o.test ? o.test.accept(self) : nil,
o.counter ? o.counter.accept(self) : nil,
o.value.accept(self)
]
end
|
#visit_TryNode(o) ⇒ Object
147
148
149
150
151
152
153
154
|
# File 'lib/rbelly/visitors/visitor.rb', line 147
def visit_TryNode(o)
[
o.value.accept(self),
o.catch_var ? o.catch_var : nil,
o.catch_block ? o.catch_block.accept(self) : nil,
o.finally_block ? o.finally_block.accept(self) : nil
]
end
|