--- a/Fraction.st Wed Nov 10 11:39:42 2004 +0100
+++ b/Fraction.st Wed Nov 10 11:40:41 2004 +0100
@@ -79,7 +79,8 @@
!
numerator:num denominator:den
- "create and return a new fraction with numerator num and denominator den"
+ "create and return a new fraction with numerator num and denominator den.
+ Notice: stc inlines this message if sent to the global named Fraction."
|newFraction|
@@ -88,33 +89,35 @@
/* this check allows subclassing .. */
if (self == Fraction) {
if (__bothSmallInteger(num, den)) {
- if (__CanDoQuickAlignedNew(sizeof(struct __Fraction))) { /* OBJECT ALLOCATION */
- OBJ newFraction;
- int spc;
- INT iDen;
+ if (den != __MKSMALLINT(0)) {
+ if (__CanDoQuickAlignedNew(sizeof(struct __Fraction))) { /* OBJECT ALLOCATION */
+ OBJ newFraction;
+ int spc;
+ INT iDen;
- __qCheckedAlignedNew(newFraction, sizeof(struct __Fraction));
- __InstPtr(newFraction)->o_class = self;
- __qSTORE(newFraction, self);
- iDen = __intVal(den);
- if (iDen != 0) {
- if (iDen < 0) {
- __FractionInstPtr(newFraction)->f_numerator = __MKSMALLINT(- __intVal(num));
- __FractionInstPtr(newFraction)->f_denominator = __MKSMALLINT(- iDen);
- } else {
- __FractionInstPtr(newFraction)->f_numerator = num;
- __FractionInstPtr(newFraction)->f_denominator = den;
- }
- if (num == __MKSMALLINT(1)) {
- /* no need to reduce */
- RETURN ( newFraction );
+ __qCheckedAlignedNew(newFraction, sizeof(struct __Fraction));
+ __InstPtr(newFraction)->o_class = self;
+ __qSTORE(newFraction, self);
+ iDen = __intVal(den);
+ if (iDen != 0) {
+ if (iDen < 0) {
+ __FractionInstPtr(newFraction)->f_numerator = __MKSMALLINT(- __intVal(num));
+ __FractionInstPtr(newFraction)->f_denominator = __MKSMALLINT(- iDen);
+ } else {
+ __FractionInstPtr(newFraction)->f_numerator = num;
+ __FractionInstPtr(newFraction)->f_denominator = den;
+ }
+ if (num == __MKSMALLINT(1)) {
+ /* no need to reduce */
+ RETURN ( newFraction );
+ }
}
}
}
}
}
%}.
- den == 0 ifTrue:[
+ den = 0 ifTrue:[
^ ZeroDivide raiseRequestWith:thisContext.
].
newFraction isNil ifTrue:[
@@ -1095,7 +1098,7 @@
!Fraction class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.70 2004-06-11 18:16:08 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.71 2004-11-10 10:40:41 penk Exp $'
! !
Fraction initialize!