Module: Mutant::NodeHelpers

Included in:
Context::Scope, Mutator::Node, Subject::Method::Instance::Memoized, Zombifier::Subject
Defined in:
lib/mutant/node_helpers.rb

Overview

Mixin for node helpers

Constant Summary collapse

NAN =
s(:send, s(:float,  0.0), :/, s(:args, s(:float, 0.0)))
INFINITY =
s(:send, s(:float,  1.0), :/, s(:args, s(:float, 0.0)))
NEW_OBJECT =
s(:send, s(:const, s(:cbase), :Object), :new)
NEGATIVE_INFINITY =
s(:send, s(:float, -1.0), :/, s(:args, s(:float, 0.0)))
RAISE =
s(:send, nil, :raise)
N_TRUE =
s(:true)
N_FALSE =
s(:false)
N_NIL =
s(:nil)
N_EMPTY =
s(:empty)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.s(type, *children) ⇒ Parser::AST::Node

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Build node

Parameters:

  • type (Symbol)

Returns:

  • (Parser::AST::Node)


15
16
17
# File 'lib/mutant/node_helpers.rb', line 15

def s(type, *children)
  ::Parser::AST::Node.new(type, children)
end

Instance Method Details

#n_not(node) ⇒ Parser::AST::Node

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Build a negated boolean node

Parameters:

  • node (Parser::AST::Node)

Returns:

  • (Parser::AST::Node)


44
45
46
# File 'lib/mutant/node_helpers.rb', line 44

def n_not(node)
  s(:send, node, :!)
end