aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog13
-rw-r--r--src/algebra/sf.spad.pamphlet33
-rw-r--r--src/algebra/view2D.spad.pamphlet2
-rw-r--r--src/interp/g-opt.boot2
-rw-r--r--src/interp/lisp-backend.boot4
5 files changed, 35 insertions, 19 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index f2422129..10413a15 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,18 @@
2011-10-23 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * interp/g-opt.boot ($VMsideEffectFreeOperators): Include %fdecode.
+ * interp/lisp-backend.boot: Expand it.
+ * algebra/sf.spad.pamphlet (DoubleFloat): Remove %fmanexpr import.
+ Use %fdecode to access Lisp-level double-float decoding.
+ [mantissa]: Rewrite.
+ [exponent]: Likewise.
+ [negative?]: Likewise.
+ [positive?]: Likewise.
+ [manexp]: Likewise.
+ * algebra/view2D.spad.pamphlet (TwoDimensionalViewport): Tidy.
+
+2011-10-23 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
* interp/compiler.boot (compForm2): Simplify. Don't bother with
subsumption. Exit early on empty modemap candidate list.
diff --git a/src/algebra/sf.spad.pamphlet b/src/algebra/sf.spad.pamphlet
index e15fdddd..fc01b769 100644
--- a/src/algebra/sf.spad.pamphlet
+++ b/src/algebra/sf.spad.pamphlet
@@ -286,7 +286,6 @@ DoubleFloat(): Join(FloatingPointSystem, DifferentialRing,
import %fmaxval: () -> % from Foreign Builtin
import %fbase: () -> PositiveInteger from Foreign Builtin
import %fprec: () -> PositiveInteger from Foreign Builtin
- import %fmanexp: % -> Record(man: %,exp: Integer) from Foreign Builtin
import %i2f: Integer -> % from Foreign Builtin
import %fabs: % -> % from Foreign Builtin
import %fneg: % -> % from Foreign Builtin
@@ -327,12 +326,16 @@ DoubleFloat(): Join(FloatingPointSystem, DifferentialRing,
import %fatanh: % -> % from Foreign Builtin
import %fcstpi: () -> % from Foreign Builtin
import %fNaN?: % -> Boolean from Foreign Builtin
-
- manexp: % -> MER
+ import %fdecode: % -> List Integer from Foreign Builtin
+ import %lfirst: List Integer -> Integer from Foreign Builtin
+ import %lsecond: List Integer -> Integer from Foreign Builtin
+ import %lthird: List Integer -> Integer from Foreign Builtin
base() == %fbase()
- mantissa x == manexp(x).MANTISSA
- exponent x == manexp(x).EXPONENT
+ mantissa x ==
+ fp := %fdecode x
+ %lfirst fp * %lthird fp
+ exponent x == %lsecond %fdecode x
precision() == %fprec()
bits() ==
base() = 2 => precision()
@@ -394,7 +397,7 @@ DoubleFloat(): Join(FloatingPointSystem, DifferentialRing,
acoth x == atanh(1/x)
asech x == acosh(1/x)
x:% / y:% == %fdiv(x,y)
- negative? x == x < 0
+ negative? x == sign x < 0
zero? x == x = 0
one? x == x = 1
hash x == %hash x
@@ -438,18 +441,14 @@ DoubleFloat(): Join(FloatingPointSystem, DifferentialRing,
x = (%i2f(n := wholePart x)) => n
"failed"
- sign(x) == retract FLOAT_-SIGN(x,1)$Lisp
+ sign(x) == %lthird %fdecode x
abs x == %fabs x
- positive? x == 0 < x
- manexp(x) ==
- zero? x => [0,0]
- s := sign x
- x := abs x
- if x > max()$% then
- return [s*mantissa(max())+1,exponent max()]
- me: Record(man: %,exp: Integer) := %fmanexp x
- two53 := base()**precision()
- [s*wholePart(two53 * me.man ),me.exp-precision()]
+ positive? x == sign x > 0
+ manexp(x: %): MER ==
+ fp := %fdecode x
+ m := %lfirst fp
+ zero? m => [m,0]
+ [%lfirst fp * %lthird fp, %lsecond fp]
-- rationalApproximation(y,d,b) ==
-- this is the quotient remainder algorithm (requires wholePart operation)
diff --git a/src/algebra/view2D.spad.pamphlet b/src/algebra/view2D.spad.pamphlet
index 5a032a44..bdd63f5e 100644
--- a/src/algebra/view2D.spad.pamphlet
+++ b/src/algebra/view2D.spad.pamphlet
@@ -779,7 +779,7 @@ TwoDimensionalViewport ():Exports == Implementation where
-- the viewports in its list. a -1 means it doesn't
-- exist.
sendI(VIEW,viewport.key)$Lisp
- i := getI(VIEW)$Lisp
+ i: Integer := getI(VIEW)$Lisp
negative? i =>
viewport.key := 0$I
error "This viewport has already been closed!"
diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot
index e2a1e7c9..f044b7a2 100644
--- a/src/interp/g-opt.boot
+++ b/src/interp/g-opt.boot
@@ -431,7 +431,7 @@ $VMsideEffectFreeOperators ==
%idec %irem %iquo %idivide %idec %irandom
%feq %flt %fle %fgt %fge %fmul %fadd %fsub %fexp %fmin %fmax %float?
%fpowi %fdiv %fneg %i2f %fminval %fmaxval %fbase %fprec %ftrunc
- %fsqrt %fpowf %flog %flog2 %flog10 %fmanexp %fNaN?
+ %fsqrt %fpowf %flog %flog2 %flog10 %fmanexp %fNaN? %fdecode
%fsin %fcos %ftan %fcot
%fasin %facos %fatan %facot
%fsinh %fcosh %ftanh
diff --git a/src/interp/lisp-backend.boot b/src/interp/lisp-backend.boot
index 89972184..17efec64 100644
--- a/src/interp/lisp-backend.boot
+++ b/src/interp/lisp-backend.boot
@@ -322,6 +322,9 @@ expandFatanh ['%fatanh,x] ==
expandFacoth ['%facoth,x] ==
['C_-TO_-R,['ACOTH,expandToVMForm x]]
+expandFdecode ['%fdecode,x] ==
+ ['MULTIPLE_-VALUE_-CALL,['FUNCTION,'LIST],
+ ['INTEGER_-DECODE_-FLOAT,expandToVMForm x]]
-- String operations
@@ -655,6 +658,7 @@ for x in [
['%idivide, :function expandIdivide],
['%i2f, :function expandI2f],
+ ['%fdecode, :function expandFdecode],
['%fbase, :function expandFbase],
['%feq, :function expandFeq],
['%fgt, :function expandFgt],