2013-07-28 19:03:06 -04:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2013-06-04 13:22:33 -04:00
|
|
|
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
|
2013-06-12 13:19:06 -04:00
|
|
|
module_function :s
|
|
|
|
|
2013-07-28 13:57:06 -04:00
|
|
|
NAN =
|
|
|
|
s(:begin, s(:send, s(:float, 0.0), :/, s(:args, s(:float, 0.0))))
|
|
|
|
INFINITY =
|
|
|
|
s(:begin, 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(:begin, s(:send, s(:float, -1.0), :/, s(:args, s(:float, 0.0))))
|
2013-06-21 09:03:21 -04:00
|
|
|
|
2013-07-02 14:42:09 -04:00
|
|
|
RAISE = s(:send, nil, :raise)
|
|
|
|
|
2013-07-24 01:58:20 -04:00
|
|
|
N_TRUE = s(:true)
|
|
|
|
N_FALSE = s(:false)
|
2013-07-24 02:30:04 -04:00
|
|
|
N_NIL = s(:nil)
|
2013-06-21 09:03:21 -04:00
|
|
|
N_EMPTY = s(:empty)
|
2013-06-04 13:22:33 -04:00
|
|
|
|
2013-07-24 13:53:37 -04:00
|
|
|
# Build a negated boolean node
|
|
|
|
#
|
|
|
|
# @param [Parser::AST::Node] node
|
|
|
|
#
|
|
|
|
# @return [Parser::AST::Node]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def n_not(node)
|
|
|
|
s(:send, node, :!)
|
|
|
|
end
|
|
|
|
|
2013-06-04 13:22:33 -04:00
|
|
|
end # NodeHelpers
|
|
|
|
end # Mutant
|