Skip to content
Permalink
Browse files
Merge branch 'master' into truffle-head
Conflicts:
	truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java
  • Loading branch information
chrisseaton committed Jan 25, 2015
2 parents 63a99be + 48b7055 commit 231b2130fcd947a505802ef717ead275549261bd
Showing 49 changed files with 459 additions and 207 deletions.
@@ -1110,7 +1110,7 @@ public Operand buildSClass(SClassNode sclassNode) {
Variable sClassVar = addResultInstr(new DefineMetaClassInstr(createTemporaryVariable(), receiver, body));

// sclass bodies inherit the block of their containing method
Variable processBodyResult = addResultInstr(new ProcessModuleBodyInstr(createTemporaryVariable(), sClassVar, NullBlock.INSTANCE));
Variable processBodyResult = addResultInstr(new ProcessModuleBodyInstr(createTemporaryVariable(), sClassVar, scope.getYieldClosureVariable()));
newIRBuilder(manager, body).buildModuleOrClassBody(sclassNode.getBodyNode(), sclassNode.getPosition().getLine());
return processBodyResult;
}
@@ -6,14 +6,40 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

# Copyright (c) 2007-2014, Evan Phoenix and contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Rubinius nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

class Float

NAN = 0.0 / 0.0
INFINITY = 1.0 / 0.0
EPSILON = 2.2204460492503131e-16
RADIX = 2
ROUNDS = 1
MIN = 2.2250738585072014e-308
MIN = 4.9E-324
MAX = 1.7976931348623157e+308
MIN_EXP = -1021
MAX_EXP = 1024
@@ -22,10 +48,6 @@ class Float
DIG = 15
MANT_DIG = 53

def negative?
self < 0
end

# for Float ** Rational we would normally do Rational.convert(a) ** b, but
# this ends up being recursive using Rubinius' code, so we use this helper
# instead.
@@ -36,4 +58,17 @@ def pow_rational(rational)

private :pow_rational

def equal_fallback(other)
# Fallback from Rubinius' Float#==, after the primitive call

begin
b, a = math_coerce(other)
return a == b
rescue TypeError
return other == self
end
end

private :equal_fallback

end
@@ -41,4 +41,60 @@ def to_r
(f * (RADIX ** e)).to_r
end

def arg
if nan?
self
elsif negative?
Math::PI
else
0
end
end
alias_method :angle, :arg
alias_method :phase, :arg

def negative?
Rubinius.primitive :float_negative
raise PrimitiveFailure, "Float#negative primitive failed"
end

def numerator
if nan?
NAN
elsif infinite? == 1
INFINITY
elsif infinite? == -1
-INFINITY
else
super
end
end

def denominator
if infinite? || nan?
1
else
super
end
end

alias_method :quo, :/
alias_method :modulo, :%

def finite?
not (nan? or infinite?)
end

def rationalize(eps=undefined)
if undefined.equal?(eps)
f, n = Math.frexp self
f = Math.ldexp(f, Float::MANT_DIG).to_i
n -= Float::MANT_DIG

Rational.new(2 * f, 1 << (1 - n)).rationalize(Rational.new(1, 1 << (1 - n)))
else
to_r.rationalize(eps)
end
end

end
@@ -112,4 +112,12 @@ def real?
true
end

def numerator
to_r.numerator
end

def denominator
to_r.denominator
end

end

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -1,6 +1,3 @@
fails:Float#rationalize returns self as a simplified Rational with no argument
fails:Float#rationalize simplifies self to the degree specified by a Rational argument
fails:Float#rationalize simplifies self to the degree specified by a Float argument
fails:Float#rationalize raises a FloatDomainError for Infinity
fails:Float#rationalize raises a FloatDomainError for NaN
fails:Float#rationalize raises ArgumentError when passed more than one argument
@@ -1,5 +1,3 @@
fails:Float#round returns the nearest Integer
fails:Float#round raises FloatDomainError for exceptional values
fails:Float#round rounds self to an optionally given precision
fails:Float#round returns zero when passed a negative argument with magitude greater the magitude of the whole number portion of the Float
fails:Float#round raises a TypeError when its argument can not be converted to an Integer

This file was deleted.

@@ -11,5 +11,3 @@ fails:Float#to_s uses e format for a positive value with whole part having 18 si
fails:Float#to_s uses e format for a negative value with whole part having 18 significant figures
fails:Float#to_s uses non-e format for a positive value with whole part having 17 significant figures
fails:Float#to_s uses non-e format for a negative value with whole part having 17 significant figures
fails:Float#to_s returns a String in US-ASCII encoding when Encoding.default_internal is nil
fails:Float#to_s returns a String in US-ASCII encoding when Encoding.default_internal is not nil

This file was deleted.

This file was deleted.

This file was deleted.

@@ -283,6 +283,14 @@ public boolean isForeignObject(Object object) {
return (object instanceof TruffleObject) && !(isRubyBasicObject(object));
}

public boolean isNaN(double value) {
return Double.isNaN(value);
}

public boolean isInfinity(double value) {
return Double.isInfinite(value);
}

// Copied from RubyTypesGen

@SuppressWarnings("static-method")

0 comments on commit 231b213

Please sign in to comment.