2012-08-01 07:27:35 -04:00
|
|
|
module Mutant
|
|
|
|
class Mutator
|
|
|
|
# Abstract class for mutatiosn where messages are send
|
|
|
|
class Call < Mutator
|
|
|
|
|
|
|
|
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
|
|
|
|
#
|
2012-08-01 07:27:35 -04:00
|
|
|
def self?
|
|
|
|
receiver.kind_of?(Rubinius::AST::Self)
|
|
|
|
end
|
2012-08-01 07:53:28 -04:00
|
|
|
|
|
|
|
class Send < Call
|
|
|
|
|
|
|
|
handle(Rubinius::AST::Send)
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
# Emit mutations
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def dispatch
|
2012-08-01 08:13:57 -04:00
|
|
|
emit_explicit_self_receiver
|
2012-08-01 07:53:28 -04:00
|
|
|
end
|
|
|
|
|
2012-08-01 08:13:57 -04:00
|
|
|
# Emit an explicit self receiver if receiver is self
|
2012-08-01 07:53:28 -04:00
|
|
|
#
|
|
|
|
# Transforms a call on self with implict receiver into one with
|
|
|
|
# explcit receiver.
|
|
|
|
#
|
2012-08-01 08:13:57 -04:00
|
|
|
# foo => self.foo
|
2012-08-01 07:53:28 -04:00
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2012-08-01 08:13:57 -04:00
|
|
|
def emit_explicit_self_receiver
|
|
|
|
emit_self(receiver,name,false,false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class SendWithArguments < Call
|
|
|
|
|
|
|
|
handle(Rubinius::AST::SendWithArguments)
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
# Emut mutations
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def dispatch
|
|
|
|
emit_explicit_self_receiver
|
|
|
|
end
|
|
|
|
|
|
|
|
# Emit an explicit self receiver if receiver is self
|
|
|
|
#
|
|
|
|
# Transforms a call on self with implict receiver into one with
|
|
|
|
# explcit receiver.
|
|
|
|
#
|
|
|
|
# foo => self.foo
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def emit_explicit_self_receiver
|
2012-08-01 07:53:28 -04:00
|
|
|
emit_self(receiver,name,false,false)
|
|
|
|
end
|
|
|
|
end
|
2012-08-01 07:27:35 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|