Class: RKelly::Visitors::Visitor
- Inherits:
-
Object
- Object
- RKelly::Visitors::Visitor
show all
- Defined in:
- lib/rkelly/visitors/visitor.rb
Constant Summary
collapse
- TERMINAL_NODES =
%w{
Break Continue EmptyStatement False Null Number Parameter Regexp Resolve
String This True
}
- SINGLE_VALUE_NODES =
%w{
Parenthetical AssignExpr BitwiseNot Block Delete Element ExpressionStatement
FunctionBody LogicalNot Return Throw TypeOf UnaryMinus UnaryPlus Void
}
- 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 }
- 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
Instance Method Summary
collapse
Instance Method Details
#accept(target) ⇒ Object
37
38
39
|
# File 'lib/rkelly/visitors/visitor.rb', line 37
def accept(target)
target.accept(self)
end
|
#visit_BracketAccessorNode(o) ⇒ Object
124
125
126
127
128
129
|
# File 'lib/rkelly/visitors/visitor.rb', line 124
def visit_BracketAccessorNode(o)
[
o.value.accept(self),
o.accessor.accept(self)
]
end
|
#visit_DotAccessorNode(o) ⇒ Object
131
132
133
|
# File 'lib/rkelly/visitors/visitor.rb', line 131
def visit_DotAccessorNode(o)
o.value.accept(self)
end
|
#visit_ForInNode(o) ⇒ Object
107
108
109
110
111
112
113
|
# File 'lib/rkelly/visitors/visitor.rb', line 107
def visit_ForInNode(o)
[
o.left.accept(self),
o.right.accept(self),
o.value.accept(self)
]
end
|
#visit_ForNode(o) ⇒ Object
98
99
100
101
102
103
104
105
|
# File 'lib/rkelly/visitors/visitor.rb', line 98
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
115
116
117
118
119
120
121
122
|
# File 'lib/rkelly/visitors/visitor.rb', line 115
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
|