Sha256: 87d6350c2e0eb858cf9c575c76f8e2efa058594bd08ab1c0222c8f1dc41c5422

Contents?: true

Size: 930 Bytes

Versions: 6

Compression:

Stored size: 930 Bytes

Contents

# encoding: utf-8

module Mutant
  # Mixin for node helpers
  module NodeHelpers

    # Build node
    #
    # @param [Symbol] type
    #
    # @return [Parser::AST::Node]
    #
    # @api private
    #
    def s(type, *children)
      Parser::AST::Node.new(type, children)
    end
    module_function :s

    NAN =
      s(:send, s(:float,  0.0), :/, s(:float, 0.0))
    INFINITY =
      s(:send, s(:float,  1.0), :/, s(:float, 0.0))
    NEGATIVE_INFINITY =
      s(:send, s(:float, -1.0), :/, 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)

    # Build a negated boolean node
    #
    # @param [Parser::AST::Node] node
    #
    # @return [Parser::AST::Node]
    #
    # @api private
    #
    def n_not(node)
      s(:send, node, :!)
    end

  end # NodeHelpers
end # Mutant

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mutant-0.5.18 lib/mutant/node_helpers.rb
mutant-0.5.17 lib/mutant/node_helpers.rb
mutant-0.5.16 lib/mutant/node_helpers.rb
mutant-0.5.15 lib/mutant/node_helpers.rb
mutant-0.5.14 lib/mutant/node_helpers.rb
mutant-0.5.13 lib/mutant/node_helpers.rb