Class: Duby::AST::JRubyAst::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/duby/transform.rb

Instance Method Summary collapse

Instance Method Details

#[](ix) ⇒ Object



214
215
216
# File 'lib/duby/transform.rb', line 214

def [](ix)
  self.child_nodes[ix]
end

#inspect(indent = 0) ⇒ Object



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/duby/transform.rb', line 218

def inspect(indent = 0)
  s = ' '*indent + self.class.name.split('::').last

  if self.respond_to?(:name)
    s << " |#{self.name}|"
  end
  if self.respond_to?(:value)
    s << " ==#{self.value.inspect}"
  end

  if self.respond_to?(:index)
    s << " &#{self.index.inspect}"
  end

  if self.respond_to?(:depth)
    s << " >#{self.depth.inspect}"
  end

  [:receiver_node, :args_node, :var_node, :head_node, :value_node, :iter_node, :body_node, :next_node, :condition, :then_body, :else_body].each do |mm|
    if self.respond_to?(mm)
      begin
        s << "\n#{self.send(mm).inspect(indent+2)}" if self.send(mm)
      rescue
        s << "\n#{' '*(indent+2)}#{self.send(mm).inspect}" if self.send(mm)
      end
    end
  end

  if org::jruby::ast::ListNode === self
    (0...self.size).each do |n|
      begin
        s << "\n#{self.get(n).inspect(indent+2)}" if self.get(n)
      rescue
        s << "\n#{' '*(indent+2)}#{self.get(n).inspect}" if self.get(n)
      end
    end
  end
  s
end

#signature(parent) ⇒ Object



258
259
260
# File 'lib/duby/transform.rb', line 258

def signature(parent)
  nil
end

#transform(transformer, parent) ⇒ Object

Raises:



209
210
211
212
# File 'lib/duby/transform.rb', line 209

def transform(transformer, parent)
  # default behavior is to raise, to expose missing nodes
  raise TransformError.new("Unsupported syntax: #{self}", position)
end