free_mutant/lib/mutant/mutator/call.rb

81 lines
1.5 KiB
Ruby
Raw Normal View History

module Mutant
class Mutator
# Abstract class for mutatiosn where messages are send
class Call < Mutator
2012-08-01 08:38:12 -04:00
handle(Rubinius::AST::Send)
2012-08-01 08:38:12 -04:00
private
# Return receiver AST node
#
# @return [Rubinius::AST::Node]
#
# @api private
#
def receiver
node.receiver
end
# Return name of call
#
# @return [Symbol]
#
# @api private
#
def name
node.name
end
# Check if receiver is self
#
# @return [true]
# returns true when receiver is a Rubinius::AST::Self node
#
# @return [false]
# return false otherwise
#
2012-08-01 07:31:56 -04:00
# @api private
#
def self?
receiver.kind_of?(Rubinius::AST::Self)
end
2012-08-01 08:38:12 -04:00
def emit_explicit_self_receiver
mutatee = dup_node
mutatee.privately = false
# TODO: Fix rubinius to allow this as an attr_accessor
mutatee.instance_variable_set(:@vcall_style,false)
emit_safe(mutatee)
end
2012-08-01 08:38:12 -04:00
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_explicit_self_receiver
end
class SendWithArguments < Call
handle(Rubinius::AST::SendWithArguments)
2012-08-01 08:38:12 -04:00
private
# Emut mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_explicit_self_receiver
end
end
end
end
end