summaryrefslogtreecommitdiff
path: root/src/fjbg/ch/epfl/lamp
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-09-17 21:20:56 +0000
committerPaul Phillips <paulp@improving.org>2010-09-17 21:20:56 +0000
commit513fd181bc99263c92f759c4e17889dcb8da53f0 (patch)
tree1622666cd62bd160b68bc0205de6db4317c6026a /src/fjbg/ch/epfl/lamp
parentab8f20c1f7cb13f4c9a7bac88ebb82a5ce89e6d9 (diff)
downloadscala-513fd181bc99263c92f759c4e17889dcb8da53f0.tar.gz
scala-513fd181bc99263c92f759c4e17889dcb8da53f0.tar.bz2
scala-513fd181bc99263c92f759c4e17889dcb8da53f0.zip
Restoring negative literal parsing behavior to ...
Restoring negative literal parsing behavior to what should be the least surprising option. Thanks much to Johannes Rudolph for identifying the bug in the bytecode generator which needed addressing for us to arrive at proper -0.0 behavior, and for writing the majority of this patch. A '-' followed immediately by either a number or a period should now always be treated as a single numeric literal, which means the minus binds more tightly than anything else. A specific example of how this differs from 2.8 final is: -5.+(10) == 5.0 // and not -15.0 The full range of potentially ambiguous parses involving prefix operators, numbers, and dots is quite large and still needs to be completely and clearly specified. Closes #2378 and #3657, review by odersky, jrudolph.
Diffstat (limited to 'src/fjbg/ch/epfl/lamp')
-rw-r--r--src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java b/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java
index 523f960b23..69d0436528 100644
--- a/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java
+++ b/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java
@@ -146,27 +146,32 @@ public class JExtendedCode extends JCode {
}
public void emitPUSH(Long value) { emitPUSH(value.longValue()); }
- public void emitPUSH(float value) {
- if (value == 0.0F)
+ private static final Float ZEROF = Float.valueOf(0f);
+ private static final Float ONEF = Float.valueOf(1f);
+ private static final Float TWOF = Float.valueOf(2f);
+ public void emitPUSH(Float value) {
+ if (ZEROF.equals(value))
emitFCONST_0();
- else if (value == 1.0F)
+ else if (ONEF.equals(value))
emitFCONST_1();
- else if (value == 2.0F)
+ else if (TWOF.equals(value))
emitFCONST_2();
else
- emitPUSH_index(pool.addFloat(value));
+ emitPUSH_index(pool.addFloat(value.floatValue()));
}
- public void emitPUSH(Float value) { emitPUSH(value.floatValue()); }
+ public void emitPUSH(float value) { emitPUSH(Float.valueOf(value)); }
- public void emitPUSH(double value) {
- if (value == 0.0)
+ private static final Double ZEROD = Double.valueOf(0d);
+ private static final Double ONED = Double.valueOf(1d);
+ public void emitPUSH(Double value) {
+ if (ZEROD.equals(value))
emitDCONST_0();
- else if (value == 1.0)
+ else if (ONED.equals(value))
emitDCONST_1();
else
- emitLDC2_W(value);
+ emitLDC2_W(value.doubleValue());
}
- public void emitPUSH(Double value) { emitPUSH(value.doubleValue()); }
+ public void emitPUSH(double value) { emitPUSH(Double.valueOf(value)); }
public void emitPUSH(String s) {
emitPUSH_index(pool.addString(s));