Skip to content

Commit 231b213

Browse files
committed
Merge branch 'master' into truffle-head
Conflicts: truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java
2 parents 63a99be + 48b7055 commit 231b213

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+459
-207
lines changed

core/src/main/java/org/jruby/ir/IRBuilder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ public Operand buildSClass(SClassNode sclassNode) {
11101110
Variable sClassVar = addResultInstr(new DefineMetaClassInstr(createTemporaryVariable(), receiver, body));
11111111

11121112
// sclass bodies inherit the block of their containing method
1113-
Variable processBodyResult = addResultInstr(new ProcessModuleBodyInstr(createTemporaryVariable(), sClassVar, NullBlock.INSTANCE));
1113+
Variable processBodyResult = addResultInstr(new ProcessModuleBodyInstr(createTemporaryVariable(), sClassVar, scope.getYieldClosureVariable()));
11141114
newIRBuilder(manager, body).buildModuleOrClassBody(sclassNode.getBodyNode(), sclassNode.getPosition().getLine());
11151115
return processBodyResult;
11161116
}

core/src/main/ruby/jruby/truffle/core/float.rb

+40-5
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,40 @@
66
# GNU General Public License version 2
77
# GNU Lesser General Public License version 2.1
88

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

1137
NAN = 0.0 / 0.0
1238
INFINITY = 1.0 / 0.0
1339
EPSILON = 2.2204460492503131e-16
1440
RADIX = 2
1541
ROUNDS = 1
16-
MIN = 2.2250738585072014e-308
42+
MIN = 4.9E-324
1743
MAX = 1.7976931348623157e+308
1844
MIN_EXP = -1021
1945
MAX_EXP = 1024
@@ -22,10 +48,6 @@ class Float
2248
DIG = 15
2349
MANT_DIG = 53
2450

25-
def negative?
26-
self < 0
27-
end
28-
2951
# for Float ** Rational we would normally do Rational.convert(a) ** b, but
3052
# this ends up being recursive using Rubinius' code, so we use this helper
3153
# instead.
@@ -36,4 +58,17 @@ def pow_rational(rational)
3658

3759
private :pow_rational
3860

61+
def equal_fallback(other)
62+
# Fallback from Rubinius' Float#==, after the primitive call
63+
64+
begin
65+
b, a = math_coerce(other)
66+
return a == b
67+
rescue TypeError
68+
return other == self
69+
end
70+
end
71+
72+
private :equal_fallback
73+
3974
end

core/src/main/ruby/jruby/truffle/core/rubinius/kernel/common/float.rb

+56
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,60 @@ def to_r
4141
(f * (RADIX ** e)).to_r
4242
end
4343

44+
def arg
45+
if nan?
46+
self
47+
elsif negative?
48+
Math::PI
49+
else
50+
0
51+
end
52+
end
53+
alias_method :angle, :arg
54+
alias_method :phase, :arg
55+
56+
def negative?
57+
Rubinius.primitive :float_negative
58+
raise PrimitiveFailure, "Float#negative primitive failed"
59+
end
60+
61+
def numerator
62+
if nan?
63+
NAN
64+
elsif infinite? == 1
65+
INFINITY
66+
elsif infinite? == -1
67+
-INFINITY
68+
else
69+
super
70+
end
71+
end
72+
73+
def denominator
74+
if infinite? || nan?
75+
1
76+
else
77+
super
78+
end
79+
end
80+
81+
alias_method :quo, :/
82+
alias_method :modulo, :%
83+
84+
def finite?
85+
not (nan? or infinite?)
86+
end
87+
88+
def rationalize(eps=undefined)
89+
if undefined.equal?(eps)
90+
f, n = Math.frexp self
91+
f = Math.ldexp(f, Float::MANT_DIG).to_i
92+
n -= Float::MANT_DIG
93+
94+
Rational.new(2 * f, 1 << (1 - n)).rationalize(Rational.new(1, 1 << (1 - n)))
95+
else
96+
to_r.rationalize(eps)
97+
end
98+
end
99+
44100
end

core/src/main/ruby/jruby/truffle/core/rubinius/kernel/common/numeric.rb

+8
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,12 @@ def real?
112112
true
113113
end
114114

115+
def numerator
116+
to_r.numerator
117+
end
118+
119+
def denominator
120+
to_r.denominator
121+
end
122+
115123
end

spec/truffle/tags/core/float/abs_tags.txt

-4
This file was deleted.

spec/truffle/tags/core/float/angle_tags.txt

-8
This file was deleted.

spec/truffle/tags/core/float/arg_tags.txt

-8
This file was deleted.

spec/truffle/tags/core/float/ceil_tags.txt

-1
This file was deleted.

spec/truffle/tags/core/float/coerce_tags.txt

-1
This file was deleted.

spec/truffle/tags/core/float/comparison_tags.txt

-7
This file was deleted.

spec/truffle/tags/core/float/constants_tags.txt

-13
This file was deleted.

spec/truffle/tags/core/float/denominator_tags.txt

-3
This file was deleted.

spec/truffle/tags/core/float/divide_tags.txt

-6
This file was deleted.

spec/truffle/tags/core/float/divmod_tags.txt

-6
This file was deleted.

spec/truffle/tags/core/float/eql_tags.txt

-3
This file was deleted.

spec/truffle/tags/core/float/exponent_tags.txt

-2
This file was deleted.

spec/truffle/tags/core/float/fdiv_tags.txt

-14
This file was deleted.

spec/truffle/tags/core/float/finite_tags.txt

-4
This file was deleted.

spec/truffle/tags/core/float/float_tags.txt

-1
This file was deleted.

spec/truffle/tags/core/float/floor_tags.txt

-1
This file was deleted.

spec/truffle/tags/core/float/hash_tags.txt

-2
This file was deleted.

spec/truffle/tags/core/float/infinite_tags.txt

-4
This file was deleted.

spec/truffle/tags/core/float/magnitude_tags.txt

-4
This file was deleted.

spec/truffle/tags/core/float/minus_tags.txt

-1
This file was deleted.

spec/truffle/tags/core/float/modulo_tags.txt

-14
This file was deleted.

spec/truffle/tags/core/float/multiply_tags.txt

-2
This file was deleted.

spec/truffle/tags/core/float/nan_tags.txt

-1
This file was deleted.

spec/truffle/tags/core/float/numerator_tags.txt

-5
This file was deleted.

spec/truffle/tags/core/float/phase_tags.txt

-8
This file was deleted.

spec/truffle/tags/core/float/plus_tags.txt

-1
This file was deleted.

spec/truffle/tags/core/float/quo_tags.txt

-14
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
fails:Float#rationalize returns self as a simplified Rational with no argument
22
fails:Float#rationalize simplifies self to the degree specified by a Rational argument
33
fails:Float#rationalize simplifies self to the degree specified by a Float argument
4-
fails:Float#rationalize raises a FloatDomainError for Infinity
5-
fails:Float#rationalize raises a FloatDomainError for NaN
6-
fails:Float#rationalize raises ArgumentError when passed more than one argument

spec/truffle/tags/core/float/round_tags.txt

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
fails:Float#round returns the nearest Integer
2-
fails:Float#round raises FloatDomainError for exceptional values
31
fails:Float#round rounds self to an optionally given precision
42
fails:Float#round returns zero when passed a negative argument with magitude greater the magitude of the whole number portion of the Float
53
fails:Float#round raises a TypeError when its argument can not be converted to an Integer

spec/truffle/tags/core/float/to_r_tags.txt

-1
This file was deleted.

spec/truffle/tags/core/float/to_s_tags.txt

-2
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@ fails:Float#to_s uses e format for a positive value with whole part having 18 si
1111
fails:Float#to_s uses e format for a negative value with whole part having 18 significant figures
1212
fails:Float#to_s uses non-e format for a positive value with whole part having 17 significant figures
1313
fails:Float#to_s uses non-e format for a negative value with whole part having 17 significant figures
14-
fails:Float#to_s returns a String in US-ASCII encoding when Encoding.default_internal is nil
15-
fails:Float#to_s returns a String in US-ASCII encoding when Encoding.default_internal is not nil

spec/truffle/tags/core/float/uminus_tags.txt

-5
This file was deleted.

spec/truffle/tags/core/float/uplus_tags.txt

-1
This file was deleted.

spec/truffle/tags/core/float/zero_tags.txt

-1
This file was deleted.

truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java

+8
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,14 @@ public boolean isForeignObject(Object object) {
283283
return (object instanceof TruffleObject) && !(isRubyBasicObject(object));
284284
}
285285

286+
public boolean isNaN(double value) {
287+
return Double.isNaN(value);
288+
}
289+
290+
public boolean isInfinity(double value) {
291+
return Double.isInfinite(value);
292+
}
293+
286294
// Copied from RubyTypesGen
287295

288296
@SuppressWarnings("static-method")

0 commit comments

Comments
 (0)