renamed sone structures;
added mclass - instvar to method
This bumps the major revision,
since old classFiles are no longer cmpatible
--- a/Fraction.st Fri Mar 24 12:53:57 2000 +0100
+++ b/Fraction.st Fri Mar 24 12:54:44 2000 +0100
@@ -41,17 +41,17 @@
(for exact division).
Mixed mode arithmetic:
- fraction op fraction -> fraction
- fraction op fix -> fix; scale is fix's scale
- fraction op integer -> fraction
- fraction op float -> float
+ fraction op fraction -> fraction
+ fraction op fix -> fix; scale is fix's scale
+ fraction op integer -> fraction
+ fraction op float -> float
[author:]
- Claus Gittinger
+ Claus Gittinger
[see also:]
- Number
- Float Integer FixedPoint
+ Number
+ Float Integer FixedPoint
"
! !
@@ -81,29 +81,29 @@
/* this check allows subclassing .. */
if (self == Fraction) {
- if (__bothSmallInteger(num, den)) {
- if (__CanDoQuickAlignedNew(sizeof(struct __fraction))) { /* OBJECT ALLOCATION */
- OBJ newFraction;
- int spc;
+ if (__bothSmallInteger(num, den)) {
+ if (__CanDoQuickAlignedNew(sizeof(struct __Fraction))) { /* OBJECT ALLOCATION */
+ OBJ newFraction;
+ int spc;
- __qCheckedAlignedNew(newFraction, sizeof(struct __fraction));
- __InstPtr(newFraction)->o_class = self;
- if (__intVal(den) < 0) {
- __FractionInstPtr(newFraction)->f_numerator = __MKSMALLINT(- __intVal(num));
- __FractionInstPtr(newFraction)->f_denominator = __MKSMALLINT(- __intVal(den));
- } else {
- __FractionInstPtr(newFraction)->f_numerator = num;
- __FractionInstPtr(newFraction)->f_denominator = den;
- }
- if (num == __MKSMALLINT(1)) {
- RETURN ( newFraction );
- }
- }
- }
+ __qCheckedAlignedNew(newFraction, sizeof(struct __Fraction));
+ __InstPtr(newFraction)->o_class = self;
+ if (__intVal(den) < 0) {
+ __FractionInstPtr(newFraction)->f_numerator = __MKSMALLINT(- __intVal(num));
+ __FractionInstPtr(newFraction)->f_denominator = __MKSMALLINT(- __intVal(den));
+ } else {
+ __FractionInstPtr(newFraction)->f_numerator = num;
+ __FractionInstPtr(newFraction)->f_denominator = den;
+ }
+ if (num == __MKSMALLINT(1)) {
+ RETURN ( newFraction );
+ }
+ }
+ }
}
%}.
newFraction isNil ifTrue:[
- newFraction := self basicNew setNumerator:num denominator:den.
+ newFraction := self basicNew setNumerator:num denominator:den.
].
^ newFraction reduced
! !
@@ -114,8 +114,8 @@
"return the constant pi as Fraction"
^ self
- numerator: 31415926535897932384626434
- denominator:10000000000000000000000000
+ numerator: 31415926535897932384626434
+ denominator:10000000000000000000000000
"
Fraction pi
@@ -175,18 +175,18 @@
|n d|
(aNumber isMemberOf:SmallInteger) ifTrue:[
- ^ (self class numerator:(numerator * aNumber)
- denominator:denominator)
+ ^ (self class numerator:(numerator * aNumber)
+ denominator:denominator)
].
aNumber isFraction ifTrue:[
- aNumber isFixedPoint ifFalse:[ "/ the value was corrent, but the scale is lost
- n := numerator * aNumber numerator.
- d := denominator * aNumber denominator.
- ^ (self class numerator:n denominator:d)
- ]
+ aNumber isFixedPoint ifFalse:[ "/ the value was corrent, but the scale is lost
+ n := numerator * aNumber numerator.
+ d := denominator * aNumber denominator.
+ ^ (self class numerator:n denominator:d)
+ ]
].
(aNumber isMemberOf:Float) ifTrue:[
- ^ (numerator * aNumber) / denominator
+ ^ (numerator * aNumber) / denominator
].
^ aNumber productFromFraction:self
@@ -199,26 +199,26 @@
|n d|
(aNumber isMemberOf:SmallInteger) ifTrue:[
- ^ (self class numerator:(numerator + (denominator * aNumber))
- denominator:denominator)
+ ^ (self class numerator:(numerator + (denominator * aNumber))
+ denominator:denominator)
].
aNumber isFraction ifTrue:[
- aNumber isFixedPoint ifFalse:[ "/ the value was corrent, but the scale is lost
- n := aNumber numerator.
- d := aNumber denominator.
+ aNumber isFixedPoint ifFalse:[ "/ the value was corrent, but the scale is lost
+ n := aNumber numerator.
+ d := aNumber denominator.
- "save a multiplication if possible"
- denominator == d ifTrue:[
- n := numerator + n
- ] ifFalse:[
- n := (numerator * d) + (n * denominator).
- d := denominator * d.
- ].
- ^ (self class numerator:n denominator:d)
- ]
+ "save a multiplication if possible"
+ denominator == d ifTrue:[
+ n := numerator + n
+ ] ifFalse:[
+ n := (numerator * d) + (n * denominator).
+ d := denominator * d.
+ ].
+ ^ (self class numerator:n denominator:d)
+ ]
].
(aNumber isMemberOf:Float) ifTrue:[
- ^ aNumber + (numerator asFloat / denominator asFloat)
+ ^ aNumber + (numerator asFloat / denominator asFloat)
].
^ aNumber sumFromFraction:self
@@ -231,26 +231,26 @@
|n d|
(aNumber isMemberOf:SmallInteger) ifTrue:[
- ^ (self class numerator:(numerator - (denominator * aNumber))
- denominator:denominator)
+ ^ (self class numerator:(numerator - (denominator * aNumber))
+ denominator:denominator)
].
aNumber isFraction ifTrue:[
- aNumber isFixedPoint ifFalse:[ "/ the value was corrent, but the scale is lost
- n := aNumber numerator.
- d := aNumber denominator.
+ aNumber isFixedPoint ifFalse:[ "/ the value was corrent, but the scale is lost
+ n := aNumber numerator.
+ d := aNumber denominator.
- "save a multiplication if possible"
- denominator == d ifTrue:[
- n := numerator - n
- ] ifFalse:[
- n := (numerator * d) - (n * denominator).
- d := denominator * d
- ].
- ^ (self class numerator:n denominator:d)
- ]
+ "save a multiplication if possible"
+ denominator == d ifTrue:[
+ n := numerator - n
+ ] ifFalse:[
+ n := (numerator * d) - (n * denominator).
+ d := denominator * d
+ ].
+ ^ (self class numerator:n denominator:d)
+ ]
].
(aNumber isMemberOf:Float) ifTrue:[
- ^ (numerator asFloat / denominator asFloat) - aNumber
+ ^ (numerator asFloat / denominator asFloat) - aNumber
].
^ aNumber differenceFromFraction:self
@@ -271,18 +271,18 @@
|n d|
(aNumber isMemberOf:SmallInteger) ifTrue:[
- ^ (self class numerator:numerator
- denominator:(denominator * aNumber))
+ ^ (self class numerator:numerator
+ denominator:(denominator * aNumber))
].
aNumber isFraction ifTrue:[
- aNumber isFixedPoint ifFalse:[ "/ the value was corrent, but the scale is lost
- n := numerator * aNumber denominator.
- d := denominator * aNumber numerator.
- ^ (self class numerator:n denominator:d)
- ]
+ aNumber isFixedPoint ifFalse:[ "/ the value was corrent, but the scale is lost
+ n := numerator * aNumber denominator.
+ d := denominator * aNumber numerator.
+ ^ (self class numerator:n denominator:d)
+ ]
].
(aNumber isMemberOf:Float) ifTrue:[
- ^ numerator / (denominator * aNumber)
+ ^ numerator / (denominator * aNumber)
].
^ aNumber quotientFromFraction:self
@@ -310,8 +310,8 @@
"optional - could use inherited method ..."
^ self class
- numerator:(numerator negated)
- denominator:denominator
+ numerator:(numerator negated)
+ denominator:denominator
"Modified: 5.11.1996 / 10:29:11 / cg"
!
@@ -321,8 +321,8 @@
numerator == 1 ifTrue:[^ denominator].
^ self class
- numerator:denominator
- denominator:numerator
+ numerator:denominator
+ denominator:numerator
"Modified: 5.11.1996 / 10:29:22 / cg"
! !
@@ -413,17 +413,17 @@
|d n|
(aNumber isMemberOf:SmallInteger) ifTrue:[
- ^ numerator < (denominator * aNumber)
+ ^ numerator < (denominator * aNumber)
].
aNumber isFraction ifTrue:[
- d := aNumber denominator.
- n := aNumber numerator.
+ d := aNumber denominator.
+ n := aNumber numerator.
- "/ save a multiplication if possible
- d == denominator ifTrue:[
- ^ numerator < n
- ].
- ^ (numerator * d) < (denominator * n)
+ "/ save a multiplication if possible
+ d == denominator ifTrue:[
+ ^ numerator < n
+ ].
+ ^ (numerator * d) < (denominator * n)
].
^ aNumber lessFromFraction:self
@@ -435,16 +435,16 @@
as the receiver, false otherwise"
(aNumber isMemberOf:SmallInteger) ifTrue:[
- (denominator = 1) ifFalse:[^ false].
- ^ numerator = aNumber
+ (denominator = 1) ifFalse:[^ false].
+ ^ numerator = aNumber
].
aNumber isFraction ifTrue:[
- (numerator = aNumber numerator) ifFalse:[^ false].
- ^ denominator = aNumber denominator
+ (numerator = aNumber numerator) ifFalse:[^ false].
+ ^ denominator = aNumber denominator
].
(aNumber isInteger) ifTrue:[
- (denominator = 1) ifFalse:[^ false].
- ^ numerator = aNumber
+ (denominator = 1) ifFalse:[^ false].
+ ^ numerator = aNumber
].
^ self retry:#= coercing:aNumber
@@ -459,17 +459,17 @@
|d n|
(aNumber isMemberOf:SmallInteger) ifTrue:[
- ^ numerator > (denominator * aNumber)
+ ^ numerator > (denominator * aNumber)
].
aNumber isFraction ifTrue:[
- d := aNumber denominator.
- n := aNumber numerator.
+ d := aNumber denominator.
+ n := aNumber numerator.
- "/ save a multiplication if possible
- d == denominator ifTrue:[
- ^ numerator > n
- ].
- ^ (numerator * d) > (denominator * n)
+ "/ save a multiplication if possible
+ d == denominator ifTrue:[
+ ^ numerator > n
+ ].
+ ^ (numerator * d) > (denominator * n)
].
^ self retry:#> coercing:aNumber
@@ -510,8 +510,8 @@
"sent when an integer does not know how to subtract the receiver, a fraction"
^ (self class
- numerator:((anInteger * denominator) - numerator)
- denominator:denominator)
+ numerator:((anInteger * denominator) - numerator)
+ denominator:denominator)
"Modified: 28.7.1997 / 19:08:53 / cg"
!
@@ -532,8 +532,8 @@
"sent when an integer does not know how to multiply the receiver, a fraction"
^ (self class
- numerator:(anInteger * numerator)
- denominator:denominator)
+ numerator:(anInteger * numerator)
+ denominator:denominator)
"Modified: 28.7.1997 / 19:06:22 / cg"
!
@@ -548,8 +548,8 @@
"sent when an integer does not know how to divide by the receiver, a fraction"
^ (self class
- numerator:(anInteger * denominator)
- denominator:numerator)
+ numerator:(anInteger * denominator)
+ denominator:numerator)
"Modified: 28.7.1997 / 19:08:46 / cg"
!
@@ -564,8 +564,8 @@
"sent when an integer does not know how to add the receiver, a fraction"
^ (self class
- numerator:(numerator + (anInteger * denominator))
- denominator:denominator)
+ numerator:(numerator + (anInteger * denominator))
+ denominator:denominator)
"Modified: 28.7.1997 / 19:08:40 / cg"
! !
@@ -592,8 +592,8 @@
den := denominator.
den < 0 ifTrue:[
- numerator := numerator negated.
- den := denominator := den negated.
+ numerator := numerator negated.
+ den := denominator := den negated.
].
den == 1 ifTrue:[^ numerator].
@@ -602,13 +602,13 @@
gcd := numerator gcd:den.
(gcd ~~ 1) ifTrue:[
- numerator := numerator // gcd.
- denominator := den := den // gcd.
- den < 0 ifTrue:[
- numerator := numerator negated.
- den := denominator := den negated.
- ].
- (den == 1) ifTrue:[^ numerator].
+ numerator := numerator // gcd.
+ denominator := den := den // gcd.
+ den < 0 ifTrue:[
+ numerator := numerator negated.
+ den := denominator := den negated.
+ ].
+ (den == 1) ifTrue:[^ numerator].
].
^ self
!
@@ -654,7 +654,7 @@
"extract the after-decimal fraction part."
numerator < denominator ifTrue:[
- ^ self
+ ^ self
].
^ super fractionPart
@@ -672,7 +672,7 @@
"extract the pre-decimal integer part."
numerator < denominator ifTrue:[
- ^ 0
+ ^ 0
].
^ super integerPart
@@ -694,9 +694,9 @@
|t|
self negative ifTrue:[
- t := self - (1/2)
+ t := self - (1/2)
] ifFalse:[
- t := self + (1/2)
+ t := self + (1/2)
].
^ t truncated.
@@ -730,6 +730,6 @@
!Fraction class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.47 1999-09-01 20:00:25 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.48 2000-03-24 11:54:39 cg Exp $'
! !
Fraction initialize!
--- a/Method.st Fri Mar 24 12:53:57 2000 +0100
+++ b/Method.st Fri Mar 24 12:54:44 2000 +0100
@@ -11,7 +11,7 @@
"
CompiledCode variableSubclass:#Method
- instanceVariableNames:'source sourcePosition category package'
+ instanceVariableNames:'source sourcePosition category package mclass'
classVariableNames:'PrivateMethodSignal LastFileReference LastSourceFileName
LastWhoClass LastFileLock LastMethodSources CompilationLock'
poolDictionaries:''
@@ -71,26 +71,27 @@
[Instance variables:]
- source <String> the source itself (if sourcePosition isNil)
- or the fileName where the source is found
-
- sourcePosition <Integer> the position of the methods chunk in the file
-
- category <Symbol> the methods category
- package <Symbol> the package, in which the methods was defined
-
+ source <String> the source itself (if sourcePosition isNil)
+ or the fileName where the source is found
+
+ sourcePosition <Integer> the position of the methods chunk in the file
+
+ category <Symbol> the methods category
+ package <Symbol> the package, in which the methods was defined
+ mclass <Class> the class in which I am defined
+ indexed slots literals
[Class variables:]
- PrivateMethodSignal raised on privacy violation (see docu)
-
- LastFileReference weak reference to the last sourceFile
- LastSourceFileName to speedup source access via NFS
+ PrivateMethodSignal raised on privacy violation (see docu)
+
+ LastFileReference weak reference to the last sourceFile
+ LastSourceFileName to speedup source access via NFS
WARNING: layout known by compiler and runtime system - dont change
[author:]
- Claus Gittinger
+ Claus Gittinger
"
!
@@ -149,13 +150,13 @@
Be warned and send me suggestions & critics (constructive ;-)
Late note (Feb 2000):
- the privacy feature has new been in ST/X for some years and was NOT heavily
- used - neither at eXept, nor by customers.
- In Smalltalk, it seems to be a very questionable feature, actually limiting
- code reusability.
- The privacy features are left in the system to demonstrate that it can be
- done in Smalltalk (for religious C++ fans ... to avoid useless discussions)
- (the check is not expensive, w.r.t. the VM runtime behavior).
+ the privacy feature has new been in ST/X for some years and was NOT heavily
+ used - neither at eXept, nor by customers.
+ In Smalltalk, it seems to be a very questionable feature, actually limiting
+ code reusability.
+ The privacy features are left in the system to demonstrate that it can be
+ done in Smalltalk (for religious C++ fans ... to avoid useless discussions)
+ (the check is not expensive, w.r.t. the VM runtime behavior).
"
! !
@@ -165,16 +166,16 @@
"create signals"
PrivateMethodSignal isNil ifTrue:[
- "EXPERIMENTAL"
- PrivateMethodSignal := ExecutionErrorSignal newSignalMayProceed:true.
- PrivateMethodSignal nameClass:self message:#privateMethodSignal.
- PrivateMethodSignal notifierString:'attempt to execute private/protected method'.
+ "EXPERIMENTAL"
+ PrivateMethodSignal := ExecutionErrorSignal newSignalMayProceed:true.
+ PrivateMethodSignal nameClass:self message:#privateMethodSignal.
+ PrivateMethodSignal notifierString:'attempt to execute private/protected method'.
].
LastFileLock isNil ifTrue:[
- LastFileLock := Semaphore forMutualExclusion name:'LastFileLock'.
- LastFileReference := WeakArray new:1.
- LastFileReference at:1 put:0.
+ LastFileLock := Semaphore forMutualExclusion name:'LastFileLock'.
+ LastFileReference := WeakArray new:1.
+ LastFileReference at:1 put:0.
].
CompilationLock := Semaphore forMutualExclusion name:'MethodCompilation'.
@@ -313,7 +314,7 @@
"set the methods category"
aStringOrSymbol notNil ifTrue:[
- category := aStringOrSymbol asSymbol
+ category := aStringOrSymbol asSymbol
]
"Modified: / 13.11.1998 / 23:55:05 / cg"
@@ -335,14 +336,14 @@
parser parseMethodSpec.
comments := parser comments.
comments size ~~ 0 ifTrue:[
- comment := comments first string.
- (comment withoutSpaces endsWith:'}') ifTrue:[
- "if first comment is a pragma, take next comment"
- comment := comments at:2 ifAbsent:nil.
- comment notNil ifTrue:[
- comment := comment string.
- ].
- ].
+ comment := comments first string.
+ (comment withoutSpaces endsWith:'}') ifTrue:[
+ "if first comment is a pragma, take next comment"
+ comment := comments at:2 ifAbsent:nil.
+ comment notNil ifTrue:[
+ comment := comment string.
+ ].
+ ].
].
^ comment.
@@ -388,16 +389,16 @@
|fileName aStream|
package notNil ifTrue:[
- fileName := Smalltalk getSourceFileName:(package copyReplaceAll:$: with:$/) , '/' , source.
- fileName notNil ifTrue:[
- aStream := fileName asFilename readStream.
- aStream notNil ifTrue:[^ aStream].
- ].
+ fileName := Smalltalk getSourceFileName:(package copyReplaceAll:$: with:$/) , '/' , source.
+ fileName notNil ifTrue:[
+ aStream := fileName asFilename readStream.
+ aStream notNil ifTrue:[^ aStream].
+ ].
].
fileName := Smalltalk getSourceFileName:source.
fileName notNil ifTrue:[
- aStream := fileName asFilename readStream.
- aStream notNil ifTrue:[^ aStream].
+ aStream := fileName asFilename readStream.
+ aStream notNil ifTrue:[^ aStream].
].
^ nil
!
@@ -410,9 +411,9 @@
sourceCode is not lost."
source notNil ifTrue:[
- sourcePosition notNil ifTrue:[
- self source:(self source)
- ]
+ sourcePosition notNil ifTrue:[
+ self source:(self source)
+ ]
].
!
@@ -444,40 +445,40 @@
sourcePosition isNil ifTrue:[^ source].
source notNil ifTrue:[
- LastMethodSources notNil ifTrue:[
- junk := LastMethodSources at:self ifAbsent:nil.
- junk notNil ifTrue:[
- ^ junk
- ]
- ].
-
- aStream := self sourceStream.
- aStream notNil ifTrue:[
- Stream positionErrorSignal handle:[:ex |
- ^ nil
- ] do:[
- aStream position:sourcePosition abs.
- ].
- junk := aStream nextChunk.
-
- OperatingSystem isMSDOSlike ifTrue:[
- "
- kludge for now - somehow this does not work under win32 (sigh)
- "
- aStream close.
- (LastFileReference at:1) == aStream ifTrue:[
- LastFileReference at:1 put:0.
- LastSourceFileName := nil.
- ]
- ].
- ]
+ LastMethodSources notNil ifTrue:[
+ junk := LastMethodSources at:self ifAbsent:nil.
+ junk notNil ifTrue:[
+ ^ junk
+ ]
+ ].
+
+ aStream := self sourceStream.
+ aStream notNil ifTrue:[
+ Stream positionErrorSignal handle:[:ex |
+ ^ nil
+ ] do:[
+ aStream position:sourcePosition abs.
+ ].
+ junk := aStream nextChunk.
+
+ OperatingSystem isMSDOSlike ifTrue:[
+ "
+ kludge for now - somehow this does not work under win32 (sigh)
+ "
+ aStream close.
+ (LastFileReference at:1) == aStream ifTrue:[
+ LastFileReference at:1 put:0.
+ LastSourceFileName := nil.
+ ]
+ ].
+ ]
].
junk notNil ifTrue:[
- LastMethodSources isNil ifTrue:[
- LastMethodSources := CacheDictionary new:20.
- ].
- LastMethodSources at:self put:junk.
+ LastMethodSources isNil ifTrue:[
+ LastMethodSources := CacheDictionary new:20.
+ ].
+ LastMethodSources at:self put:junk.
].
^ junk
@@ -547,24 +548,24 @@
"/ Neat trick.
LastFileLock critical:[
- aStream := LastFileReference at:1.
- LastFileReference at:1 put:0.
-
- aStream == 0 ifTrue:[
- aStream := nil.
- ] ifFalse:[
- LastSourceFileName = source ifFalse:[
- aStream close.
- aStream := nil.
- ]
- ].
- LastSourceFileName := nil.
+ aStream := LastFileReference at:1.
+ LastFileReference at:1 put:0.
+
+ aStream == 0 ifTrue:[
+ aStream := nil.
+ ] ifFalse:[
+ LastSourceFileName = source ifFalse:[
+ aStream close.
+ aStream := nil.
+ ]
+ ].
+ LastSourceFileName := nil.
].
aStream notNil ifTrue:[
- LastSourceFileName := source.
- LastFileReference at:1 put:aStream.
- ^ aStream
+ LastSourceFileName := source.
+ LastFileReference at:1 put:aStream.
+ ^ aStream
].
"/ a negative sourcePosition indicates
@@ -575,34 +576,34 @@
"/ and having a clue for which file is meant later.
sourcePosition < 0 ifTrue:[
- aStream := source asFilename readStream.
- aStream notNil ifTrue:[
- LastSourceFileName := source.
- LastFileReference at:1 put:aStream.
- ^ aStream
- ].
-
- fileName := Smalltalk getSourceFileName:source.
- fileName notNil ifTrue:[
- aStream := fileName asFilename readStream.
- aStream notNil ifTrue:[
- LastSourceFileName := source.
- LastFileReference at:1 put:aStream.
- ^ aStream
- ].
- ].
+ aStream := source asFilename readStream.
+ aStream notNil ifTrue:[
+ LastSourceFileName := source.
+ LastFileReference at:1 put:aStream.
+ ^ aStream
+ ].
+
+ fileName := Smalltalk getSourceFileName:source.
+ fileName notNil ifTrue:[
+ aStream := fileName asFilename readStream.
+ aStream notNil ifTrue:[
+ LastSourceFileName := source.
+ LastFileReference at:1 put:aStream.
+ ^ aStream
+ ].
+ ].
].
"/
"/ if there is no SourceManager, look in local standard places first
"/
(mgr := Smalltalk at:#SourceCodeManager) isNil ifTrue:[
- aStream := self localSourceStream.
- aStream notNil ifTrue:[
- LastSourceFileName := source.
- LastFileReference at:1 put:aStream.
- ^ aStream
- ].
+ aStream := self localSourceStream.
+ aStream notNil ifTrue:[
+ LastSourceFileName := source.
+ LastFileReference at:1 put:aStream.
+ ^ aStream
+ ].
].
"/
@@ -610,31 +611,31 @@
"/
who := self who.
who notNil ifTrue:[
- myClass := who methodClass.
-
- (package notNil and:[package ~= myClass package]) ifTrue:[
- mgr notNil ifTrue:[
- "/ try to get the source using my package information ...
- sep := package indexOfAny:'/\:'.
- sep ~~ 0 ifTrue:[
- mod := package copyTo:sep - 1.
- dir := package copyFrom:sep + 1.
- aStream := mgr streamForClass:nil fileName:source revision:nil directory:dir module:mod cache:true.
- aStream notNil ifTrue:[
- LastSourceFileName := source.
- LastFileReference at:1 put:aStream.
- ^ aStream
- ].
- ].
- ].
- ].
-
- aStream := myClass sourceStreamFor:source.
- aStream notNil ifTrue:[
- LastSourceFileName := source.
- LastFileReference at:1 put:aStream.
- ^ aStream
- ].
+ myClass := who methodClass.
+
+ (package notNil and:[package ~= myClass package]) ifTrue:[
+ mgr notNil ifTrue:[
+ "/ try to get the source using my package information ...
+ sep := package indexOfAny:'/\:'.
+ sep ~~ 0 ifTrue:[
+ mod := package copyTo:sep - 1.
+ dir := package copyFrom:sep + 1.
+ aStream := mgr streamForClass:nil fileName:source revision:nil directory:dir module:mod cache:true.
+ aStream notNil ifTrue:[
+ LastSourceFileName := source.
+ LastFileReference at:1 put:aStream.
+ ^ aStream
+ ].
+ ].
+ ].
+ ].
+
+ aStream := myClass sourceStreamFor:source.
+ aStream notNil ifTrue:[
+ LastSourceFileName := source.
+ LastFileReference at:1 put:aStream.
+ ^ aStream
+ ].
].
"/
@@ -642,46 +643,46 @@
"/ (if there is a source-code manager - otherwise, we already did that)
"/
mgr notNil ifTrue:[
- aStream := self localSourceStream.
- aStream notNil ifTrue:[
- LastSourceFileName := source.
- LastFileReference at:1 put:aStream.
- ^ aStream
- ].
+ aStream := self localSourceStream.
+ aStream notNil ifTrue:[
+ LastSourceFileName := source.
+ LastFileReference at:1 put:aStream.
+ ^ aStream
+ ].
].
"/
"/ final chance: try current directory
"/
aStream isNil ifTrue:[
- aStream := source asFilename readStream.
- aStream notNil ifTrue:[
- LastSourceFileName := source.
- LastFileReference at:1 put:aStream.
- ^ aStream
- ].
+ aStream := source asFilename readStream.
+ aStream notNil ifTrue:[
+ LastSourceFileName := source.
+ LastFileReference at:1 put:aStream.
+ ^ aStream
+ ].
].
(who isNil and:[source notNil]) ifTrue:[
- "/
- "/ mhmh - seems to be a method which used to be in some
- "/ class, but has been overwritten by another or removed.
- "/ (i.e. it has no containing class anyMore)
- "/ try to guess the class from the sourceFileName.
- "/ and retry.
- "/
- className := Smalltalk classNameForFile:source.
- className knownAsSymbol ifTrue:[
- myClass := Smalltalk at:className asSymbol ifAbsent:nil.
- myClass notNil ifTrue:[
- aStream := myClass sourceStreamFor:source.
- aStream notNil ifTrue:[
- LastSourceFileName := source.
- LastFileReference at:1 put:aStream.
- ^ aStream
- ].
- ]
- ]
+ "/
+ "/ mhmh - seems to be a method which used to be in some
+ "/ class, but has been overwritten by another or removed.
+ "/ (i.e. it has no containing class anyMore)
+ "/ try to guess the class from the sourceFileName.
+ "/ and retry.
+ "/
+ className := Smalltalk classNameForFile:source.
+ className knownAsSymbol ifTrue:[
+ myClass := Smalltalk at:className asSymbol ifAbsent:nil.
+ myClass notNil ifTrue:[
+ aStream := myClass sourceStreamFor:source.
+ aStream notNil ifTrue:[
+ LastSourceFileName := source.
+ LastFileReference at:1 put:aStream.
+ ^ aStream
+ ].
+ ]
+ ]
].
^ nil
@@ -806,18 +807,18 @@
# ifdef F_PRIVATE
case F_PRIVATE:
- RETURN (@symbol(private));
- break;
+ RETURN (@symbol(private));
+ break;
# endif
# ifdef F_CLASSPRIVATE
case F_CLASSPRIVATE:
- RETURN (@symbol(protected));
- break;
+ RETURN (@symbol(protected));
+ break;
# endif
# ifdef F_IGNORED
case F_IGNORED:
- RETURN (@symbol(ignored));
- break;
+ RETURN (@symbol(ignored));
+ break;
# endif
}
#endif
@@ -848,7 +849,7 @@
"/ no need to flush, if changing from private to public
"/
(aSymbol == #public and:[old ~~ #ignored]) ifFalse:[
- ObjectMemory flushCaches.
+ ObjectMemory flushCaches.
]
"Modified: / 27.8.1995 / 22:58:08 / claus"
@@ -915,15 +916,15 @@
INT p;
if (aSymbol == @symbol(public))
- p = 0;
+ p = 0;
else if (aSymbol == @symbol(private))
- p = F_PRIVATE;
+ p = F_PRIVATE;
else if (aSymbol == @symbol(protected))
- p = F_CLASSPRIVATE;
+ p = F_CLASSPRIVATE;
else if (aSymbol == @symbol(ignored))
- p = F_IGNORED;
+ p = F_IGNORED;
else
- RETURN(false); /* illegal symbol */
+ RETURN(false); /* illegal symbol */
f = (f & ~M_PRIVACY) | p;
@@ -981,21 +982,21 @@
|temporaryMethod cls sourceString silent lazy|
byteCode notNil ifTrue:[
- "
- is already a bytecoded method
- "
- ^ self
+ "
+ is already a bytecoded method
+ "
+ ^ self
].
cls := self containingClass.
cls isNil ifTrue:[
- 'Method [warning]: cannot generate bytecode (no class for compilation)' errorPrintCR.
- ^ nil
+ 'Method [warning]: cannot generate bytecode (no class for compilation)' errorPrintCR.
+ ^ nil
].
sourceString := self source.
sourceString isNil ifTrue:[
- 'Method [warning]: cannot generate bytecode (no source for compilation)' errorPrintCR.
- ^ nil
+ 'Method [warning]: cannot generate bytecode (no source for compilation)' errorPrintCR.
+ ^ nil
].
"we have to sequentialize this using a lock-semaphore,
@@ -1005,51 +1006,51 @@
(happened when autoloading animation demos)
"
CompilationLock critical:[
- "
- dont want this to go into the changes file,
- dont want output on Transcript and definitely
- dont want a lazy method ...
- "
- Class withoutUpdatingChangesDo:[
- silent := Smalltalk silentLoading:true.
- lazy := Compiler compileLazy:false.
-
- [
- |compiler|
-
- Class nameSpaceQuerySignal answer:(cls nameSpace)
- do:[
- compiler := cls compilerClass.
-
- "/
- "/ kludge - have to make ST/X's compiler protocol
- "/ be compatible to ST-80's
- "/
- (compiler respondsTo:#compile:forClass:inCategory:notifying:install:skipIfSame:)
- ifTrue:[
- temporaryMethod := compiler
- compile:sourceString
- forClass:cls
- inCategory:(self category)
- notifying:nil
- install:false.
- ] ifFalse:[
- temporaryMethod := compiler new
- compile:sourceString
- in:cls
- notifying:nil
- ifFail:nil
- ].
- ].
- ] valueNowOrOnUnwindDo:[
- Compiler compileLazy:lazy.
- Smalltalk silentLoading:silent.
- ]
- ].
+ "
+ dont want this to go into the changes file,
+ dont want output on Transcript and definitely
+ dont want a lazy method ...
+ "
+ Class withoutUpdatingChangesDo:[
+ silent := Smalltalk silentLoading:true.
+ lazy := Compiler compileLazy:false.
+
+ [
+ |compiler|
+
+ Class nameSpaceQuerySignal answer:(cls nameSpace)
+ do:[
+ compiler := cls compilerClass.
+
+ "/
+ "/ kludge - have to make ST/X's compiler protocol
+ "/ be compatible to ST-80's
+ "/
+ (compiler respondsTo:#compile:forClass:inCategory:notifying:install:skipIfSame:)
+ ifTrue:[
+ temporaryMethod := compiler
+ compile:sourceString
+ forClass:cls
+ inCategory:(self category)
+ notifying:nil
+ install:false.
+ ] ifFalse:[
+ temporaryMethod := compiler new
+ compile:sourceString
+ in:cls
+ notifying:nil
+ ifFail:nil
+ ].
+ ].
+ ] valueNowOrOnUnwindDo:[
+ Compiler compileLazy:lazy.
+ Smalltalk silentLoading:silent.
+ ]
+ ].
].
(temporaryMethod isNil or:[temporaryMethod == #Error]) ifTrue:[
- 'Method [warning]: cannot generate bytecode (contains primitive code or error)' errorPrintCR.
- ^ nil.
+ 'Method [warning]: cannot generate bytecode (contains primitive code or error)' errorPrintCR.
+ ^ nil.
].
"
try to save a bit of memory, by sharing the source (whatever it is)
@@ -1063,8 +1064,8 @@
readBinaryContentsFrom: stream manager: manager
self hasCode ifTrue:[
- "built-in method - already complete"
- ^ self
+ "built-in method - already complete"
+ ^ self
].
^ super readBinaryContentsFrom: stream manager: manager
@@ -1087,26 +1088,26 @@
|storedMethod who|
byteCode isNil ifTrue:[
- self hasCode ifTrue:[
- (who := self who) notNil ifTrue:[
- "
- machine code only - assume its a built-in method,
- and store the class/selector information.
- The restored method may not be exactly the same ...
- "
- manager putIdOfClass:(self class) on:stream.
- stream nextPutByte:0. "means: built-in method"
- manager putIdOf:(who methodClass) on:stream.
- manager putIdOf:(who methodSelector) on:stream.
- ^ self
- ]
- ].
-
- storedMethod := self asByteCodeMethod.
- storedMethod isNil ifTrue:[
- self error:'store of built-in method failed'.
- ].
- ^ storedMethod storeBinaryDefinitionOn:stream manager:manager
+ self hasCode ifTrue:[
+ (who := self who) notNil ifTrue:[
+ "
+ machine code only - assume its a built-in method,
+ and store the class/selector information.
+ The restored method may not be exactly the same ...
+ "
+ manager putIdOfClass:(self class) on:stream.
+ stream nextPutByte:0. "means: built-in method"
+ manager putIdOf:(who methodClass) on:stream.
+ manager putIdOf:(who methodSelector) on:stream.
+ ^ self
+ ]
+ ].
+
+ storedMethod := self asByteCodeMethod.
+ storedMethod isNil ifTrue:[
+ self error:'store of built-in method failed'.
+ ].
+ ^ storedMethod storeBinaryDefinitionOn:stream manager:manager
].
manager putIdOfClass:(self class) on:stream.
@@ -1638,62 +1639,62 @@
privInfo := ''.
self isWrapped ifTrue:[
- (MessageTracer isCounting:self) ifTrue:[
- (MessageTracer isCountingMemoryUsage:self) ifTrue:[
- moreInfo := moreInfo ,
- ' (mem usage avg: ' , (MessageTracer memoryUsageOfMethod:self) printString asText allBold , ' bytes)'.
- ] ifFalse:[
- moreInfo := moreInfo ,
- ' (called ' , (MessageTracer executionCountOfMethod:self) printString asText allBold , ' times)'.
- ]
- ] ifFalse:[
- (MessageTracer isTiming:self) ifTrue:[
- i := MessageTracer executionTimesOfMethod:self.
- (i isNil or:[(n := i at:#count) == 0]) ifTrue:[
- moreInfo := moreInfo ,
- ' (cnt: ' , (i at:#count) printString , ')'
- ] ifFalse:[
- n == 1 ifTrue:[
- moreInfo := moreInfo ,
- ' (t: ' , (i at:#avgTime) printString asText allBold,
- 'ms cnt: ' , (i at:#count) printString , ')'
- ] ifFalse:[
- moreInfo := moreInfo ,
- ' (avg: ' , (i at:#avgTime) printString asText allBold,
- 'ms min: ' , (i at:#minTime) printString ,
- ' max: ' , (i at:#maxTime) printString ,
- ' cnt: ' , (i at:#count) printString , ')'
- ].
- ].
- ] ifFalse:[
- moreInfo := ' !!'
- ]
- ].
+ (MessageTracer isCounting:self) ifTrue:[
+ (MessageTracer isCountingMemoryUsage:self) ifTrue:[
+ moreInfo := moreInfo ,
+ ' (mem usage avg: ' , (MessageTracer memoryUsageOfMethod:self) printString asText allBold , ' bytes)'.
+ ] ifFalse:[
+ moreInfo := moreInfo ,
+ ' (called ' , (MessageTracer executionCountOfMethod:self) printString asText allBold , ' times)'.
+ ]
+ ] ifFalse:[
+ (MessageTracer isTiming:self) ifTrue:[
+ i := MessageTracer executionTimesOfMethod:self.
+ (i isNil or:[(n := i at:#count) == 0]) ifTrue:[
+ moreInfo := moreInfo ,
+ ' (cnt: ' , (i at:#count) printString , ')'
+ ] ifFalse:[
+ n == 1 ifTrue:[
+ moreInfo := moreInfo ,
+ ' (t: ' , (i at:#avgTime) printString asText allBold,
+ 'ms cnt: ' , (i at:#count) printString , ')'
+ ] ifFalse:[
+ moreInfo := moreInfo ,
+ ' (avg: ' , (i at:#avgTime) printString asText allBold,
+ 'ms min: ' , (i at:#minTime) printString ,
+ ' max: ' , (i at:#maxTime) printString ,
+ ' cnt: ' , (i at:#count) printString , ')'
+ ].
+ ].
+ ] ifFalse:[
+ moreInfo := ' !!'
+ ]
+ ].
].
p := self privacy.
p ~~ #public ifTrue:[
- privInfo := (' (* ' , p , ' *)') asText emphasizeAllWith:#italic.
+ privInfo := (' (* ' , p , ' *)') asText emphasizeAllWith:#italic.
].
self isInvalid ifTrue:[
- moreInfo := ' (** not executable **)'.
+ moreInfo := ' (** not executable **)'.
].
(self isLazyMethod not and:[self isUnloaded]) ifTrue:[
- moreInfo := ' (** unloaded **)'
+ moreInfo := ' (** unloaded **)'
].
privInfo size ~~ 0 ifTrue:[
- moreInfo := privInfo , ' ' , moreInfo
+ moreInfo := privInfo , ' ' , moreInfo
].
s := selector.
(cls := aClass) isNil ifTrue:[
- cls := self containingClass
+ cls := self containingClass
].
self package ~= cls package ifTrue:[
- s := s , ' [' , (self package asText emphasizeAllWith:#italic), ']'
+ s := s , ' [' , (self package asText emphasizeAllWith:#italic), ']'
].
moreInfo size == 0 ifTrue:[^ s].
@@ -1701,7 +1702,7 @@
s := selector , moreInfo.
self isInvalid ifTrue:[
- s := s asText emphasizeAllWith:#color->Color red.
+ s := s asText emphasizeAllWith:#color->Color red.
].
^ s
@@ -2095,9 +2096,9 @@
|resources|
(resources := self resources) notNil ifTrue:[
- resources keysAndValuesDo:[:key :val|
- (self class resourceTypes includes:key) ifTrue:[^key]
- ].
+ resources keysAndValuesDo:[:key :val|
+ (self class resourceTypes includes:key) ifTrue:[^key]
+ ].
].
^ nil
@@ -2114,19 +2115,19 @@
src := self source.
src isNil ifTrue:[
- ^ nil "/ actually: dont know
+ ^ nil "/ actually: dont know
].
(src findString:'resource:') == 0 ifTrue:[
- ^ nil "/ actually: error
+ ^ nil "/ actually: error
].
parser := Parser
- parseMethod:src
- in:nil
- ignoreErrors:true
- ignoreWarnings:true.
+ parseMethod:src
+ in:nil
+ ignoreErrors:true
+ ignoreWarnings:true.
parser isNil ifTrue:[
- ^ nil "/ actually error
+ ^ nil "/ actually error
].
^ parser primitiveResources.
@@ -2163,30 +2164,30 @@
nil is returned for unbound methods.
ST/X special notice:
- returns an instance of MethodWhoInfo, which
- responds to #methodClass and #methodSelector query messages.
- For backward- (& ST-80) compatibility, the returned object also
- responds to #at:1 and #at:2 messages.
+ returns an instance of MethodWhoInfo, which
+ responds to #methodClass and #methodSelector query messages.
+ For backward- (& ST-80) compatibility, the returned object also
+ responds to #at:1 and #at:2 messages.
Implementation notice:
- Since there is no information of the containing class
- in the method, we have to do a search here.
-
- Normally, this is not a problem, except when a method is
- accepted in the debugger or redefined from within a method
- (maybe done indirectly, if #doIt is done recursively)
- - the information about which class the original method was
- defined in is lost in this case.
+ Since there is no information of the containing class
+ in the method, we have to do a search here.
+
+ Normally, this is not a problem, except when a method is
+ accepted in the debugger or redefined from within a method
+ (maybe done indirectly, if #doIt is done recursively)
+ - the information about which class the original method was
+ defined in is lost in this case.
Problem:
- this is heavily called for in the debugger to create
- a readable context walkback. For unbound methods, it is
- slow, since the search (over all classes) will always fail.
+ this is heavily called for in the debugger to create
+ a readable context walkback. For unbound methods, it is
+ slow, since the search (over all classes) will always fail.
Q: should we add a backref from the method to the class
- and/or add a subclass of Method for unbound ones ?
+ and/or add a subclass of Method for unbound ones ?
Q2: if so, what about the bad guy then, who copies methods around to
- other classes ?"
+ other classes ?"
|classes cls sel fn clsName|
@@ -2195,23 +2196,23 @@
extract the className from it and try that class first.
"
(fn := self sourceFilename) notNil ifTrue:[
- clsName := fn asFilename withoutSuffix name.
- clsName := clsName asSymbolIfInterned.
- clsName notNil ifTrue:[
- cls := Smalltalk at:clsName ifAbsent:nil.
- cls notNil ifTrue:[
- sel := cls selectorAtMethod:self.
- sel notNil ifTrue:[
- ^ MethodWhoInfo class:cls selector:sel
- ].
-
- cls := cls class.
- sel := cls selectorAtMethod:self.
- sel notNil ifTrue:[
- ^ MethodWhoInfo class:cls selector:sel
- ].
- ]
- ].
+ clsName := fn asFilename withoutSuffix name.
+ clsName := clsName asSymbolIfInterned.
+ clsName notNil ifTrue:[
+ cls := Smalltalk at:clsName ifAbsent:nil.
+ cls notNil ifTrue:[
+ sel := cls selectorAtMethod:self.
+ sel notNil ifTrue:[
+ ^ MethodWhoInfo class:cls selector:sel
+ ].
+
+ cls := cls class.
+ sel := cls selectorAtMethod:self.
+ sel notNil ifTrue:[
+ ^ MethodWhoInfo class:cls selector:sel
+ ].
+ ]
+ ].
].
"
@@ -2221,19 +2222,19 @@
being garbage collected)
"
LastWhoClass notNil ifTrue:[
- cls := Smalltalk at:LastWhoClass ifAbsent:nil.
- cls notNil ifTrue:[
- sel := cls selectorAtMethod:self.
- sel notNil ifTrue:[
- ^ MethodWhoInfo class:cls selector:sel
- ].
-
- cls := cls class.
- sel := cls selectorAtMethod:self.
- sel notNil ifTrue:[
- ^ MethodWhoInfo class:cls selector:sel
- ].
- ]
+ cls := Smalltalk at:LastWhoClass ifAbsent:nil.
+ cls notNil ifTrue:[
+ sel := cls selectorAtMethod:self.
+ sel notNil ifTrue:[
+ ^ MethodWhoInfo class:cls selector:sel
+ ].
+
+ cls := cls class.
+ sel := cls selectorAtMethod:self.
+ sel notNil ifTrue:[
+ ^ MethodWhoInfo class:cls selector:sel
+ ].
+ ]
].
"
@@ -2245,23 +2246,23 @@
instance methods are usually more common - search those first
"
classes do:[:aClass |
- |sel|
-
- sel := aClass selectorAtMethod:self ifAbsent:nil.
- sel notNil ifTrue:[
- LastWhoClass := aClass theNonMetaclass name.
- ^ MethodWhoInfo class:aClass selector:sel
- ].
+ |sel|
+
+ sel := aClass selectorAtMethod:self ifAbsent:nil.
+ sel notNil ifTrue:[
+ LastWhoClass := aClass theNonMetaclass name.
+ ^ MethodWhoInfo class:aClass selector:sel
+ ].
].
classes do:[:aClass |
- |sel|
-
- sel := aClass class selectorAtMethod:self.
- sel notNil ifTrue:[
- LastWhoClass := aClass theNonMetaclass name.
- ^ MethodWhoInfo class:aClass class selector:sel
- ].
+ |sel|
+
+ sel := aClass class selectorAtMethod:self.
+ sel notNil ifTrue:[
+ LastWhoClass := aClass theNonMetaclass name.
+ ^ MethodWhoInfo class:aClass class selector:sel
+ ].
].
LastWhoClass := nil.
@@ -2270,14 +2271,14 @@
in the Smalltalk dictionary). Search all instances of Behavior
"
Behavior allSubInstancesDo:[:someClass |
- |sel|
-
- (classes includes:someClass) ifFalse:[
- sel := someClass selectorAtMethod:self.
- sel notNil ifTrue:[
- ^ MethodWhoInfo class:someClass selector:sel
- ]
- ]
+ |sel|
+
+ (classes includes:someClass) ifFalse:[
+ sel := someClass selectorAtMethod:self.
+ sel notNil ifTrue:[
+ ^ MethodWhoInfo class:someClass selector:sel
+ ]
+ ]
].
"
none found - sorry
@@ -2296,11 +2297,11 @@
|m cls|
Object
- subclass:#FunnyClass
- instanceVariableNames:'foo'
- classVariableNames:''
- poolDictionaries:''
- category:'testing'.
+ subclass:#FunnyClass
+ instanceVariableNames:'foo'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'testing'.
cls := Smalltalk at:#FunnyClass.
Smalltalk removeClass:cls.
@@ -2508,6 +2509,6 @@
!Method class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.185 2000-03-10 18:12:34 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.186 2000-03-24 11:54:40 cg Exp $'
! !
Method initialize!
--- a/Number.st Fri Mar 24 12:53:57 2000 +0100
+++ b/Number.st Fri Mar 24 12:54:44 2000 +0100
@@ -1,6 +1,6 @@
"
COPYRIGHT (c) 1988 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -22,7 +22,7 @@
copyright
"
COPYRIGHT (c) 1988 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -38,12 +38,12 @@
abstract superclass for all kinds of numbers
[author:]
- Claus Gittinger
+ Claus Gittinger
[see also:]
- Integer LargeInteger SmallInteger
- LimitedPrecisionReal Float ShortFloat
- Fraction FixedPoint
+ Integer LargeInteger SmallInteger
+ LimitedPrecisionReal Float ShortFloat
+ Fraction FixedPoint
"
! !
@@ -83,79 +83,79 @@
|value|
ErrorSignal handle:[:ex |
- ^ exceptionBlock value
+ ^ exceptionBlock value
] do:[
- |str nextChar radix negative signExp|
+ |str nextChar radix negative signExp|
- str := aStringOrStream readStream.
+ str := aStringOrStream readStream.
- nextChar := str skipSeparators.
- nextChar isNil ifTrue:[^ exceptionBlock value].
+ nextChar := str skipSeparators.
+ nextChar isNil ifTrue:[^ exceptionBlock value].
- (nextChar == $-) ifTrue:[
- negative := true.
- str next.
- nextChar := str peekOrNil
- ] ifFalse:[
- negative := false.
- (nextChar == $+) ifTrue:[
- str next.
- nextChar := str peekOrNil
- ]
- ].
- (nextChar isDigit or:[nextChar == $.]) ifFalse:[
- ^ exceptionBlock value.
+ (nextChar == $-) ifTrue:[
+ negative := true.
+ str next.
+ nextChar := str peekOrNil
+ ] ifFalse:[
+ negative := false.
+ (nextChar == $+) ifTrue:[
+ str next.
+ nextChar := str peekOrNil
+ ]
+ ].
+ (nextChar isDigit or:[nextChar == $.]) ifFalse:[
+ ^ exceptionBlock value.
"/ value := super readFrom:str.
"/ negative ifTrue:[value := value negated].
"/ ^ value
- ].
- nextChar == $. ifTrue:[
- radix := 10.
- value := 0.0.
- ] ifFalse:[
- value := Integer readFrom:str radix:10.
- nextChar := str peekOrNil.
- ((nextChar == $r) or:[ nextChar == $R]) ifTrue:[
- str next.
- radix := value.
- value := Integer readFrom:str radix:radix.
- ] ifFalse:[
- radix := 10
- ].
- ].
+ ].
+ nextChar == $. ifTrue:[
+ radix := 10.
+ value := 0.0.
+ ] ifFalse:[
+ value := Integer readFrom:str radix:10.
+ nextChar := str peekOrNil.
+ ((nextChar == $r) or:[ nextChar == $R]) ifTrue:[
+ str next.
+ radix := value.
+ value := Integer readFrom:str radix:radix.
+ ] ifFalse:[
+ radix := 10
+ ].
+ ].
- (nextChar == $.) ifTrue:[
- str next.
- nextChar := str peekOrNil.
- (nextChar notNil and:[nextChar isDigitRadix:radix]) ifTrue:[
- value := value asFloat
- + (Number readMantissaFrom:str radix:radix).
- nextChar := str peekOrNil
- ]
- ].
- ((nextChar == $e) or:[nextChar == $E]) ifTrue:[
- str next.
- nextChar := str peekOrNil.
- signExp := 1.
- (nextChar == $+) ifTrue:[
- str next.
- nextChar := str peekOrNil.
- ] ifFalse:[
- (nextChar == $-) ifTrue:[
- str next.
- nextChar := str peekOrNil.
- signExp := -1
- ]
- ].
- (nextChar notNil and:[(nextChar isDigitRadix:radix)]) ifTrue:[
- value := value asFloat
- * (10.0 raisedToInteger:
- ((Integer readFrom:str radix:radix) * signExp))
- ]
- ].
- negative ifTrue:[
- value := value negated
- ].
+ (nextChar == $.) ifTrue:[
+ str next.
+ nextChar := str peekOrNil.
+ (nextChar notNil and:[nextChar isDigitRadix:radix]) ifTrue:[
+ value := value asFloat
+ + (Number readMantissaFrom:str radix:radix).
+ nextChar := str peekOrNil
+ ]
+ ].
+ ((nextChar == $e) or:[nextChar == $E]) ifTrue:[
+ str next.
+ nextChar := str peekOrNil.
+ signExp := 1.
+ (nextChar == $+) ifTrue:[
+ str next.
+ nextChar := str peekOrNil.
+ ] ifFalse:[
+ (nextChar == $-) ifTrue:[
+ str next.
+ nextChar := str peekOrNil.
+ signExp := -1
+ ]
+ ].
+ (nextChar notNil and:[(nextChar isDigitRadix:radix)]) ifTrue:[
+ value := value asFloat
+ * (10.0 raisedToInteger:
+ ((Integer readFrom:str radix:radix) * signExp))
+ ]
+ ].
+ negative ifTrue:[
+ value := value negated
+ ].
].
^ value.
@@ -212,22 +212,22 @@
|msg|
msg := MessageSend
- receiver:someNumber
- selector:sel
- arguments:(Array with:arg).
+ receiver:someNumber
+ selector:sel
+ arguments:(Array with:arg).
^ (self perform:aSignalSymbol)
- raiseRequestWith:msg
- errorString:text
- in:thisContext sender
+ raiseRequestWith:msg
+ errorString:text
+ in:thisContext sender
"
Number
- raise:#domainErrorSignal
- receiver:1.0
- selector:#sin
- arg:nil
- errorString:'foo bar test'
+ raise:#domainErrorSignal
+ receiver:1.0
+ selector:#sin
+ arg:nil
+ errorString:'foo bar test'
"
!
@@ -239,22 +239,22 @@
|msg|
msg := MessageSend
- receiver:someNumber
- selector:sel
- arguments:argArray.
+ receiver:someNumber
+ selector:sel
+ arguments:argArray.
^ (self perform:aSignalSymbol)
- raiseRequestWith:msg
- errorString:text
- in:thisContext sender
+ raiseRequestWith:msg
+ errorString:text
+ in:thisContext sender
"
Number
- raise:#domainErrorSignal
- receiver:1.0
- selector:#sin
- arg:nil
- errorString:'foo bar test'
+ raise:#domainErrorSignal
+ receiver:1.0
+ selector:#sin
+ arg:nil
+ errorString:'foo bar test'
"
!
@@ -266,21 +266,21 @@
|msg|
msg := MessageSend
- receiver:someNumber
- selector:sel
- arguments:#().
+ receiver:someNumber
+ selector:sel
+ arguments:#().
^ (self perform:aSignalSymbol)
- raiseRequestWith:msg
- errorString:text
- in:thisContext sender
+ raiseRequestWith:msg
+ errorString:text
+ in:thisContext sender
"
Number
- raise:#domainErrorSignal
- receiver:1.0
- selector:#foo
- errorString:'foo bar test'
+ raise:#domainErrorSignal
+ receiver:1.0
+ selector:#foo
+ errorString:'foo bar test'
"
! !
@@ -297,10 +297,10 @@
factor := 1.0 / radix.
nextChar := aStream peekOrNil.
[nextChar notNil and:[nextChar isDigitRadix:radix]] whileTrue:[
- value := value + (nextChar digitValue * factor).
- factor := factor / radix.
- aStream next.
- nextChar := aStream peekOrNil
+ value := value + (nextChar digitValue * factor).
+ factor := factor / radix.
+ aStream next.
+ nextChar := aStream peekOrNil
].
^ value
@@ -361,20 +361,20 @@
/*
* I cannot tell if this special code is worth anything
*/
- if (__CanDoQuickNew(sizeof(struct __point))) { /* OBJECT ALLOCATION */
- OBJ newPoint;
- int spc;
+ if (__CanDoQuickNew(sizeof(struct __Point))) { /* OBJECT ALLOCATION */
+ OBJ newPoint;
+ int spc;
- __qCheckedAlignedNew(newPoint, sizeof(struct __point));
- __InstPtr(newPoint)->o_class = @global(Point);
- __PointInstPtr(newPoint)->p_x = self;
- __PointInstPtr(newPoint)->p_y = aNumber;
- if (! __bothSmallInteger(self, aNumber)) {
- spc = __qSpace(newPoint);
- __STORE_SPC(newPoint, aNumber, spc);
- __STORE_SPC(newPoint, self, spc);
- }
- RETURN ( newPoint );
+ __qCheckedAlignedNew(newPoint, sizeof(struct __Point));
+ __InstPtr(newPoint)->o_class = @global(Point);
+ __PointInstPtr(newPoint)->p_x = self;
+ __PointInstPtr(newPoint)->p_y = aNumber;
+ if (! __bothSmallInteger(self, aNumber)) {
+ spc = __qSpace(newPoint);
+ __STORE_SPC(newPoint, aNumber, spc);
+ __STORE_SPC(newPoint, self, spc);
+ }
+ RETURN ( newPoint );
}
%}
.
@@ -397,15 +397,15 @@
%{ /* NOCONTEXT */
- if (__CanDoQuickNew(sizeof(struct __point))) { /* OBJECT ALLOCATION */
- OBJ newPoint;
+ if (__CanDoQuickNew(sizeof(struct __Point))) { /* OBJECT ALLOCATION */
+ OBJ newPoint;
- __qCheckedAlignedNew(newPoint, sizeof(struct __point));
- __InstPtr(newPoint)->o_class = @global(Point);
- __PointInstPtr(newPoint)->p_x = self;
- __PointInstPtr(newPoint)->p_y = self;
- __STORE(newPoint, self);
- RETURN ( newPoint );
+ __qCheckedAlignedNew(newPoint, sizeof(struct __Point));
+ __InstPtr(newPoint)->o_class = @global(Point);
+ __PointInstPtr(newPoint)->p_x = self;
+ __PointInstPtr(newPoint)->p_y = self;
+ __STORE(newPoint, self);
+ RETURN ( newPoint );
}
%}.
^ Point x:self y:self
@@ -467,8 +467,8 @@
count := self.
[count > 0] whileTrue:[
- aBlock value.
- count := count - 1
+ aBlock value.
+ count := count - 1
]
!
@@ -480,15 +480,15 @@
tmp := self.
(incr > 0) ifTrue:[
- [tmp <= stop] whileTrue:[
- aBlock value:tmp.
- tmp := tmp+incr
- ]
+ [tmp <= stop] whileTrue:[
+ aBlock value:tmp.
+ tmp := tmp+incr
+ ]
] ifFalse:[
- [tmp >= stop] whileTrue:[
- aBlock value:tmp.
- tmp := tmp+incr
- ]
+ [tmp >= stop] whileTrue:[
+ aBlock value:tmp.
+ tmp := tmp+incr
+ ]
]
!
@@ -502,23 +502,23 @@
break := [^ self].
tmp := self.
(incr > 0) ifTrue:[
- [tmp <= stop] whileTrue:[
- aBlock value:tmp value:break.
- tmp := tmp+incr
- ]
+ [tmp <= stop] whileTrue:[
+ aBlock value:tmp value:break.
+ tmp := tmp+incr
+ ]
] ifFalse:[
- [tmp >= stop] whileTrue:[
- aBlock value:tmp value:break.
- tmp := tmp+incr
- ]
+ [tmp >= stop] whileTrue:[
+ aBlock value:tmp value:break.
+ tmp := tmp+incr
+ ]
]
"
1 to:100 by:5 doWithBreak:[:index :break |
- Transcript showCR:index printString.
- index > 50 ifTrue:[
- break value
- ].
+ Transcript showCR:index printString.
+ index > 50 ifTrue:[
+ break value
+ ].
]
"
!
@@ -531,8 +531,8 @@
tmp := self.
[tmp <= stop] whileTrue:[
- aBlock value:tmp.
- tmp := tmp+1
+ aBlock value:tmp.
+ tmp := tmp+1
]
!
@@ -546,16 +546,16 @@
break := [^ self].
tmp := self.
[tmp <= stop] whileTrue:[
- aBlock value:tmp value:break.
- tmp := tmp+1
+ aBlock value:tmp value:break.
+ tmp := tmp+1
]
"
1 to:10 doWithBreak:[:index :break |
- Transcript showCR:index printString.
- index > 5 ifTrue:[
- break value
- ].
+ Transcript showCR:index printString.
+ index > 5 ifTrue:[
+ break value
+ ].
]
"
! !
@@ -655,8 +655,8 @@
snap ifTrue: [^ self]. "...or return self"
r2 := self < r1 "Nearest end of dead zone"
- ifTrue: [r1 - (detent asFloat/2)]
- ifFalse: [r1 + (detent asFloat/2)].
+ ifTrue: [r1 - (detent asFloat/2)]
+ ifFalse: [r1 + (detent asFloat/2)].
"Scale values between dead zones to fill range between multiples"
^ r1 + ((self - r2) * grid asFloat / (grid - detent))
@@ -702,5 +702,5 @@
!Number class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Number.st,v 1.58 2000-03-21 10:56:14 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Number.st,v 1.59 2000-03-24 11:54:41 cg Exp $'
! !
--- a/Point.st Fri Mar 24 12:53:57 2000 +0100
+++ b/Point.st Fri Mar 24 12:54:44 2000 +0100
@@ -43,16 +43,16 @@
[Instance variables:]
- x <Number> the x-coordinate of myself
- y <Number> the y-coordinate of myself
+ x <Number> the x-coordinate of myself
+ y <Number> the y-coordinate of myself
[author:]
- Claus Gittinger
+ Claus Gittinger
[see also:]
- Rectangle Polygon
- LayoutOrigin LayoutFrame AlignmentOrigin Layout
- View GraphicsContext
+ Rectangle Polygon
+ LayoutOrigin LayoutFrame AlignmentOrigin Layout
+ View GraphicsContext
"
! !
@@ -75,7 +75,7 @@
"
Point
- decodeFromLiteralArray:#(Point 10 10)
+ decodeFromLiteralArray:#(Point 10 10)
"
"Created: / 28.1.1998 / 17:44:08 / cg"
@@ -139,22 +139,22 @@
if no point can be read."
ErrorSignal handle:[:ex |
- ^ exceptionBlock value
+ ^ exceptionBlock value
] do:[
- |str newX newY|
+ |str newX newY|
- str := aStringOrStream readStream.
+ str := aStringOrStream readStream.
- newX := Number readFrom:str onError:nil.
- newX notNil ifTrue:[
- (str skipSeparators == $@) ifTrue:[
- str next.
- newY := Number readFrom:str onError:nil.
- newY notNil ifTrue:[
- ^ self x:newX y:newY
- ]
- ]
- ].
+ newX := Number readFrom:str onError:nil.
+ newX notNil ifTrue:[
+ (str skipSeparators == $@) ifTrue:[
+ str next.
+ newY := Number readFrom:str onError:nil.
+ newY notNil ifTrue:[
+ ^ self x:newX y:newY
+ ]
+ ]
+ ].
].
^ exceptionBlock value
@@ -176,12 +176,12 @@
/*
* claus: I am no longer certain, if this primitive is worth the effort
*/
- if (__CanDoQuickNew(sizeof(struct __point))) { /* OBJECT ALLOCATION */
+ if (__CanDoQuickNew(sizeof(struct __Point))) { /* OBJECT ALLOCATION */
if (self == @global(Point)) {
OBJ newPoint;
int spc;
- __qCheckedAlignedNew(newPoint, sizeof(struct __point));
+ __qCheckedAlignedNew(newPoint, sizeof(struct __Point));
__InstPtr(newPoint)->o_class = self;
__PointInstPtr(newPoint)->p_x = newX;
__PointInstPtr(newPoint)->p_y = newY;
@@ -305,7 +305,7 @@
p := aPoint asPoint.
x < (p x) ifTrue:[
- y < (p y) ifTrue:[^ true].
+ y < (p y) ifTrue:[^ true].
].
^ false
@@ -347,7 +347,7 @@
p := aPoint asPoint.
(p x) < x ifTrue:[
- (p y) < y ifTrue:[^ true].
+ (p y) < y ifTrue:[^ true].
].
^ false
@@ -509,9 +509,9 @@
The encoding is: (Point xValue yValue)"
^ Array
- with:#Point
- with:x
- with:y
+ with:#Point
+ with:x
+ with:y
"
@@ -534,10 +534,10 @@
consider the case, where a view has a preferred extent of 50@50
and is to be positioned in its superview which has size 100@100.
For absolute origin:
- (10@20) rectangleRelativeTo:(0@0 corner:100@100) preferred:(0@0 corner:50@50)
+ (10@20) rectangleRelativeTo:(0@0 corner:100@100) preferred:(0@0 corner:50@50)
for relative origin:
- (0.5@0.5) rectangleRelativeTo:(0@0 corner:100@100) preferred:(0@0 corner:50@50)
+ (0.5@0.5) rectangleRelativeTo:(0@0 corner:100@100) preferred:(0@0 corner:50@50)
"
"Modified: / 27.5.1998 / 10:20:13 / cg"
@@ -843,19 +843,19 @@
|theta t|
x = 0 ifTrue:[
- y >= 0 ifTrue:[
- ^ Float pi * 0.5
- ].
- ^ Float pi * 1.5.
+ y >= 0 ifTrue:[
+ ^ Float pi * 0.5
+ ].
+ ^ Float pi * 1.5.
].
t := y asFloat / x asFloat.
theta := t arcTan.
x < 0 ifTrue:[
- ^ theta +Float pi
+ ^ theta +Float pi
].
theta < 0 ifTrue:[
- ^ theta + (Float pi * 2.0)
+ ^ theta + (Float pi * 2.0)
].
^ theta.
"
@@ -908,13 +908,13 @@
"speedup for common cases ..."
(scale isMemberOf:Point) ifTrue:[
- ^ Point x:(x * scale x) y:(y * scale y)
+ ^ Point x:(x * scale x) y:(y * scale y)
].
(scale isMemberOf:SmallInteger) ifTrue:[
- ^ Point x:(x * scale) y:(y * scale)
+ ^ Point x:(x * scale) y:(y * scale)
].
scale isNumber ifTrue:[
- ^ Point x:(x * scale) y:(y * scale)
+ ^ Point x:(x * scale) y:(y * scale)
].
"this is the general (& clean) code ..."
@@ -934,14 +934,14 @@
"speedup for common cases ..."
(scale isMemberOf:Point) ifTrue:[
- ^ Point x:(x + scale x) y:(y + scale y)
+ ^ Point x:(x + scale x) y:(y + scale y)
].
(scale isMemberOf:SmallInteger) ifTrue:[
- "/ same as below, but stc can do better here
- ^ Point x:(x + scale) y:(y + scale)
+ "/ same as below, but stc can do better here
+ ^ Point x:(x + scale) y:(y + scale)
].
scale isNumber ifTrue:[
- ^ Point x:(x + scale) y:(y + scale)
+ ^ Point x:(x + scale) y:(y + scale)
].
"this is the general (& clean) code ..."
@@ -961,14 +961,14 @@
"speedup for common cases ..."
(scale isMemberOf:Point) ifTrue:[
- ^ Point x:(x - scale x) y:(y - scale y)
+ ^ Point x:(x - scale x) y:(y - scale y)
].
(scale isMemberOf:SmallInteger) ifTrue:[
- "/ same as below, but stc can do better here
- ^ Point x:(x - scale) y:(y - scale)
+ "/ same as below, but stc can do better here
+ ^ Point x:(x - scale) y:(y - scale)
].
scale isNumber ifTrue:[
- ^ Point x:(x - scale) y:(y - scale)
+ ^ Point x:(x - scale) y:(y - scale)
].
"this is the general (& clean) code ..."
@@ -1061,6 +1061,6 @@
!Point class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Point.st,v 1.53 1999-11-18 20:19:39 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Point.st,v 1.54 2000-03-24 11:54:42 cg Exp $'
! !
Point initialize!
--- a/Smalltalk.st Fri Mar 24 12:53:57 2000 +0100
+++ b/Smalltalk.st Fri Mar 24 12:54:44 2000 +0100
@@ -5414,7 +5414,7 @@
ST/X revision Naming is:
<major>.<minor>.<revision>.<release>"
- ^ 3
+ ^ 4
"
Smalltalk majorVersionNr
@@ -5434,7 +5434,7 @@
ST/X revision Naming is:
<major>.<minor>.<revision>.<release>"
- ^ 6
+ ^ 1
"
Smalltalk minorVersionNr
@@ -5490,7 +5490,7 @@
ST/X revision Naming is:
<major>.<minor>.<revision>.<release>"
- ^ 4
+ ^ 1
"
Smalltalk revisionNr
@@ -5554,5 +5554,5 @@
!Smalltalk class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.439 2000-03-24 08:27:28 ps Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.440 2000-03-24 11:54:44 cg Exp $'
! !