Class: Cenit::Algorithms::Rewriter
- Inherits:
-
Parser::Rewriter
- Object
- Parser::Rewriter
- Cenit::Algorithms::Rewriter
- Defined in:
- lib/cenit/algorithms/rewriter.rb
Instance Attribute Summary collapse
-
#logs ⇒ Object
readonly
Returns the value of attribute logs.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Rewriter
constructor
A new instance of Rewriter.
- #on_send(node) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Rewriter
Returns a new instance of Rewriter.
9 10 11 12 13 14 |
# File 'lib/cenit/algorithms/rewriter.rb', line 9 def initialize( = {}) @options = || {} @logs = [:logs] || {} @self_linker = [:self_linker] @interpreter = [:interpreter] end |
Instance Attribute Details
#logs ⇒ Object (readonly)
Returns the value of attribute logs.
7 8 9 |
# File 'lib/cenit/algorithms/rewriter.rb', line 7 def logs @logs end |
Instance Method Details
#on_send(node) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cenit/algorithms/rewriter.rb', line 16 def on_send(node) super if node.children[0].nil? && node.type == :send method_name = node.children[1] if @self_linker && !@self_linker.link?(method_name) report_error("error linking #{method_name}") end (@logs[:self_sends] ||= Set.new) << method_name if @interpreter prefix = @interpreter.__prefix__(method_name, @self_linker) insert_before(node.location.expression, prefix) end end end |