Sha256: 3aa2b0f85cdfe0bb57abf36cfa16009c3e5c52d256f2cf877c6999bc124f5fcf

Contents?: true

Size: 1.01 KB

Versions: 16

Compression:

Stored size: 1.01 KB

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(: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)

    # 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

16 entries across 16 versions & 1 rubygems

Version Path
mutant-0.5.10 lib/mutant/node_helpers.rb
mutant-0.5.9 lib/mutant/node_helpers.rb
mutant-0.5.8 lib/mutant/node_helpers.rb
mutant-0.5.7 lib/mutant/node_helpers.rb
mutant-0.5.6 lib/mutant/node_helpers.rb
mutant-0.5.5 lib/mutant/node_helpers.rb
mutant-0.5.4 lib/mutant/node_helpers.rb
mutant-0.5.3 lib/mutant/node_helpers.rb
mutant-0.5.2 lib/mutant/node_helpers.rb
mutant-0.5.1 lib/mutant/node_helpers.rb
mutant-0.5.0 lib/mutant/node_helpers.rb
mutant-0.3.6 lib/mutant/node_helpers.rb
mutant-0.3.5 lib/mutant/node_helpers.rb
mutant-0.3.4 lib/mutant/node_helpers.rb
mutant-0.3.3 lib/mutant/node_helpers.rb
mutant-0.3.2 lib/mutant/node_helpers.rb