2014-06-29 17:25:17 -04:00
|
|
|
module Mutant
|
|
|
|
module AST
|
|
|
|
# Module for node predicates
|
|
|
|
module NodePredicates
|
|
|
|
|
|
|
|
Types::ALL.each do |type|
|
|
|
|
fail "method: #{type} is already defined" if instance_methods(true).include?(type)
|
|
|
|
|
2014-06-29 18:21:47 -04:00
|
|
|
name = "n_#{type.to_s.chomp('?')}?"
|
2014-06-29 17:25:17 -04:00
|
|
|
|
|
|
|
define_method(name) do |node|
|
|
|
|
node.type.equal?(type)
|
|
|
|
end
|
|
|
|
private name
|
|
|
|
end
|
|
|
|
|
|
|
|
end # NodePredicates
|
|
|
|
end # AST
|
|
|
|
end # Mutant
|