Class: CArray::FuseSource::Leaves

Inherits:
Prism::Visitor
  • Object
show all
Defined in:
lib/carray/fuse_source.rb

Overview

The leaves are the names being read. Everything else keeps its shape: calls are inserted around leaves and the expression they sit in is left alone.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLeaves

Returns a new instance of Leaves.



82
83
84
# File 'lib/carray/fuse_source.rb', line 82

def initialize
  @spots = []
end

Instance Attribute Details

#spotsObject (readonly)

Returns the value of attribute spots.



80
81
82
# File 'lib/carray/fuse_source.rb', line 80

def spots
  @spots
end

Instance Method Details

#visit_call_node(node) ⇒ Object



95
96
97
98
99
100
101
102
103
104
# File 'lib/carray/fuse_source.rb', line 95

def visit_call_node (node)
  if node.name == :[] || node.name == :[]=
    # An index is a position, not a value to fuse: `a[i]` shadows `a`
    # and leaves `i` alone.
    visit(node.receiver)
    return
  end
  mark(node) if node.receiver.nil? && node.arguments.nil? && node.block.nil?
  super
end

#visit_constant_path_node(node) ⇒ Object

Math::PI is one name, not Math with something after it.



91
92
93
# File 'lib/carray/fuse_source.rb', line 91

def visit_constant_path_node (node)
  mark(node)
end

#visit_constant_read_node(node) ⇒ Object



88
# File 'lib/carray/fuse_source.rb', line 88

def visit_constant_read_node (node)          = mark(node)

#visit_instance_variable_read_node(node) ⇒ Object



87
# File 'lib/carray/fuse_source.rb', line 87

def visit_instance_variable_read_node (node) = mark(node)

#visit_local_variable_read_node(node) ⇒ Object



86
# File 'lib/carray/fuse_source.rb', line 86

def visit_local_variable_read_node (node)    = mark(node)