27 classVariableNames:'' |
27 classVariableNames:'' |
28 poolDictionaries:'' |
28 poolDictionaries:'' |
29 privateIn:SnapShotImageMemory |
29 privateIn:SnapShotImageMemory |
30 ! |
30 ! |
31 |
31 |
|
32 SnapShotImageMemory::ImageObject variableSubclass:#ImageMethodObject |
|
33 instanceVariableNames:'cachedPackage' |
|
34 classVariableNames:'' |
|
35 poolDictionaries:'' |
|
36 privateIn:SnapShotImageMemory |
|
37 ! |
|
38 |
32 SnapShotImageMemory::ImageObject variableSubclass:#ImageClassObject |
39 SnapShotImageMemory::ImageObject variableSubclass:#ImageClassObject |
33 instanceVariableNames:'' |
40 instanceVariableNames:'cachedCategory cachedFlags cachedName' |
34 classVariableNames:'' |
41 classVariableNames:'' |
35 poolDictionaries:'' |
42 poolDictionaries:'' |
36 privateIn:SnapShotImageMemory |
43 privateIn:SnapShotImageMemory |
37 ! |
44 ! |
38 |
45 |
164 o memory:self. |
171 o memory:self. |
165 ^ o |
172 ^ o |
166 ! |
173 ! |
167 |
174 |
168 fetchObjectAt:baseAddr |
175 fetchObjectAt:baseAddr |
169 |addr classPtr classRef size bits o nBytes nInsts flags imgAddr| |
176 |addr classPtr classRef size bits o nBytes nInsts flags indexTypeFlags imgAddr |
|
177 | |
170 |
178 |
171 baseAddr == 0 ifTrue:[^ nil]. |
179 baseAddr == 0 ifTrue:[^ nil]. |
172 (baseAddr bitAnd:1) == 1 ifTrue:[(baseAddr bitTest:16r80000000) ifTrue:[ |
180 (baseAddr bitAnd:1) == 1 ifTrue:[(baseAddr bitTest:16r80000000) ifTrue:[ |
173 ^ (baseAddr - 16r100000000) bitShift32:-1 |
181 ^ (baseAddr - 16r100000000) bitShift32:-1 |
174 ] ifFalse:[ |
182 ] ifFalse:[ |
192 self halt |
200 self halt |
193 ]. |
201 ]. |
194 |
202 |
195 classRef := self fetchClassObjectAt:classPtr. |
203 classRef := self fetchClassObjectAt:classPtr. |
196 |
204 |
197 flags := classRef flags bitAnd:Behavior maskIndexType. |
205 flags := classRef flags. |
198 (flags = Behavior flagBytes) ifTrue:[ |
206 indexTypeFlags := flags bitAnd:Behavior maskIndexType. |
|
207 (indexTypeFlags = Behavior flagBytes) ifTrue:[ |
199 nBytes := (size - (intSize * 3)). |
208 nBytes := (size - (intSize * 3)). |
200 o := ImageByteObject new:nBytes. |
209 o := ImageByteObject new:nBytes. |
201 o classRef:classRef. |
210 o classRef:classRef. |
202 size > 8000 ifTrue:[self halt]. |
211 size > 8000 ifTrue:[self halt]. |
203 o byteSize:size. |
212 o byteSize:size. |
214 "/Transcript show:'#'. |
223 "/Transcript show:'#'. |
215 "/Transcript show:((ByteArray new:nBytes-1) replaceFrom:1 to:nBytes-1 with:o startingAt:1) asString. |
224 "/Transcript show:((ByteArray new:nBytes-1) replaceFrom:1 to:nBytes-1 with:o startingAt:1) asString. |
216 "/Transcript cr. |
225 "/Transcript cr. |
217 |
226 |
218 ] ifFalse:[ |
227 ] ifFalse:[ |
219 (flags = Behavior flagNotIndexed) ifFalse:[ |
228 (indexTypeFlags = Behavior flagNotIndexed) ifFalse:[ |
220 (flags ~= Behavior flagPointers) ifTrue:[ |
229 (indexTypeFlags ~= Behavior flagPointers) ifTrue:[ |
221 (flags ~= Behavior flagWeakPointers) ifTrue:[ |
230 (indexTypeFlags ~= Behavior flagWeakPointers) ifTrue:[ |
222 self halt |
231 self halt |
223 ] |
232 ] |
224 ]. |
233 ]. |
225 ]. |
234 ]. |
226 |
235 |
227 nInsts := (size - (intSize * 3)) // intSize. |
236 nInsts := (size - (intSize * 3)) // intSize. |
228 (classRef flags bitTest:Behavior flagBehavior) |
237 (flags bitTest:Behavior flagBehavior) |
229 "/ classRef isImageBehavior |
238 "/ classRef isImageBehavior |
230 ifTrue:[ |
239 ifTrue:[ |
231 o := ImageClassObject new:nInsts. |
240 o := ImageClassObject new:nInsts. |
232 ] ifFalse:[ |
241 ] ifFalse:[ |
233 o := ImageObject new:nInsts. |
242 (flags bitTest:Behavior flagMethod) ifTrue:[ |
|
243 o := ImageMethodObject new:nInsts. |
|
244 ] ifFalse:[ |
|
245 o := ImageObject new:nInsts. |
|
246 ] |
234 ]. |
247 ]. |
235 o classRef:classRef. |
248 o classRef:classRef. |
236 size > 8000 ifTrue:[self halt]. |
249 size > 8000 ifTrue:[self halt]. |
237 o byteSize:size. |
250 o byteSize:size. |
238 o bits:bits. |
251 o bits:bits. |
1069 resources |
1086 resources |
1070 ^ nil |
1087 ^ nil |
1071 ! |
1088 ! |
1072 |
1089 |
1073 source |
1090 source |
1074 |sourcePosition sourcePositionPtr sourcePtr sourceRef source aStream junk| |
1091 self halt:'unimplemented'. |
1075 |
|
1076 self isMethodOrLazyMethod ifTrue:[ |
|
1077 sourcePositionPtr := self at:(Method instVarOffsetOf:'sourcePosition'). |
|
1078 sourcePtr := self at:(Method instVarOffsetOf:'source'). |
|
1079 sourceRef := memory fetchObjectAt:sourcePtr. |
|
1080 sourceRef isString ifFalse:[ |
|
1081 self halt. |
|
1082 ]. |
|
1083 source := memory printStringOfString:sourceRef. |
|
1084 sourcePosition := memory fetchObjectAt:sourcePositionPtr. |
|
1085 sourcePosition isNil ifTrue:[ |
|
1086 ^ source |
|
1087 ]. |
|
1088 |
|
1089 aStream := self sourceStream. |
|
1090 aStream notNil ifTrue:[ |
|
1091 Stream positionErrorSignal handle:[:ex | |
|
1092 ^ nil |
|
1093 ] do:[ |
|
1094 aStream position:sourcePosition abs. |
|
1095 ]. |
|
1096 junk := aStream nextChunk. |
|
1097 |
|
1098 aStream close. |
|
1099 ^ junk |
|
1100 ]. |
|
1101 ]. |
|
1102 self halt. |
|
1103 ! |
1092 ! |
1104 |
1093 |
1105 sourceFilename |
1094 sourceFilename |
1106 "return the sourcefilename if source is extern; nil otherwise" |
1095 "return the sourcefilename if source is extern; nil otherwise" |
1107 |
1096 |
1335 |
1324 |
1336 size |
1325 size |
1337 ^ byteSize |
1326 ^ byteSize |
1338 ! ! |
1327 ! ! |
1339 |
1328 |
|
1329 !SnapShotImageMemory::ImageMethodObject methodsFor:'method protocol'! |
|
1330 |
|
1331 package |
|
1332 |packageSlotOffset packagePtr packageRef package| |
|
1333 |
|
1334 cachedPackage isNil ifTrue:[ |
|
1335 packageSlotOffset := Method instVarOffsetOf:'package'. |
|
1336 |
|
1337 packagePtr := self at:packageSlotOffset. |
|
1338 packageRef := memory fetchObjectAt:packagePtr. |
|
1339 packageRef isNil ifTrue:[^ nil]. |
|
1340 |
|
1341 packageRef isImageSymbol ifFalse:[ |
|
1342 packageRef isImageBytes ifFalse:[ |
|
1343 self halt. |
|
1344 ]. |
|
1345 "/ mhmh - can be a string sometimes ... |
|
1346 ]. |
|
1347 package := memory fetchStringFor:packageRef. |
|
1348 cachedPackage := package asSymbol |
|
1349 ]. |
|
1350 ^ cachedPackage |
|
1351 ! |
|
1352 |
|
1353 source |
|
1354 |sourcePosition sourcePositionPtr sourcePtr sourceRef source aStream junk| |
|
1355 |
|
1356 sourcePositionPtr := self at:(Method instVarOffsetOf:'sourcePosition'). |
|
1357 sourcePtr := self at:(Method instVarOffsetOf:'source'). |
|
1358 sourceRef := memory fetchObjectAt:sourcePtr. |
|
1359 sourceRef isString ifFalse:[ |
|
1360 self halt. |
|
1361 ]. |
|
1362 source := memory printStringOfString:sourceRef. |
|
1363 sourcePosition := memory fetchObjectAt:sourcePositionPtr. |
|
1364 sourcePosition isNil ifTrue:[ |
|
1365 ^ source |
|
1366 ]. |
|
1367 |
|
1368 aStream := self sourceStream. |
|
1369 aStream notNil ifTrue:[ |
|
1370 Stream positionErrorSignal handle:[:ex | |
|
1371 ^ nil |
|
1372 ] do:[ |
|
1373 aStream position:sourcePosition abs. |
|
1374 ]. |
|
1375 junk := aStream nextChunk. |
|
1376 |
|
1377 aStream close. |
|
1378 ^ junk |
|
1379 ]. |
|
1380 self halt. |
|
1381 ! ! |
|
1382 |
|
1383 !SnapShotImageMemory::ImageMethodObject methodsFor:'queries'! |
|
1384 |
|
1385 isMethod |
|
1386 ^ true |
|
1387 ! ! |
|
1388 |
1340 !SnapShotImageMemory::ImageClassObject methodsFor:'accessing - slots'! |
1389 !SnapShotImageMemory::ImageClassObject methodsFor:'accessing - slots'! |
1341 |
1390 |
1342 category |
1391 category |
1343 |categoryRef category| |
1392 |categoryRef| |
1344 |
1393 |
1345 categoryRef := self categorySlot. |
1394 cachedCategory isNil ifTrue:[ |
1346 categoryRef isInteger ifTrue:[ |
1395 categoryRef := self categorySlot. |
1347 categoryRef := memory fetchObjectAt:categoryRef. |
1396 categoryRef isInteger ifTrue:[ |
1348 ]. |
1397 categoryRef := memory fetchObjectAt:categoryRef. |
1349 categoryRef notNil ifTrue:[ |
1398 ]. |
1350 category := memory fetchStringFor:categoryRef. |
1399 categoryRef notNil ifTrue:[ |
1351 ]. |
1400 cachedCategory := memory fetchStringFor:categoryRef. |
1352 ^ category |
1401 ]. |
|
1402 ]. |
|
1403 ^ cachedCategory |
1353 ! |
1404 ! |
1354 |
1405 |
1355 categorySlot |
1406 categorySlot |
1356 ^ self at:(Class instVarOffsetOf:'category') |
1407 ^ self at:(Class instVarOffsetOf:'category') |
1357 ! |
1408 ! |
1504 methodDictionarySlot |
1558 methodDictionarySlot |
1505 ^ self at:(Class instVarOffsetOf:'methodDictionary') |
1559 ^ self at:(Class instVarOffsetOf:'methodDictionary') |
1506 ! |
1560 ! |
1507 |
1561 |
1508 name |
1562 name |
1509 |nameRef name| |
1563 |nameRef| |
1510 |
1564 |
1511 self isMeta ifTrue:[ |
1565 cachedName isNil ifTrue:[ |
1512 ^ self theNonMetaclass name , ' class' |
1566 self isMeta ifTrue:[ |
1513 ]. |
1567 cachedName := self theNonMetaclass name , ' class' |
1514 |
1568 ] ifFalse:[ |
1515 nameRef := self nameSlot. |
1569 nameRef := self nameSlot. |
1516 nameRef isInteger ifTrue:[ |
1570 nameRef isInteger ifTrue:[ |
1517 nameRef := memory fetchObjectAt:nameRef. |
1571 nameRef := memory fetchObjectAt:nameRef. |
1518 ]. |
1572 ]. |
1519 nameRef notNil ifTrue:[ |
1573 nameRef notNil ifTrue:[ |
1520 name := memory fetchStringFor:nameRef. |
1574 cachedName := memory fetchStringFor:nameRef. |
1521 ]. |
1575 cachedName := cachedName asSymbol |
1522 nameRef notNil ifTrue:[ |
1576 ]. |
1523 name := name asSymbol. |
1577 ]. |
1524 ]. |
1578 ]. |
1525 ^ name |
1579 ^ cachedName |
1526 ! |
1580 ! |
1527 |
1581 |
1528 nameSlot |
1582 nameSlot |
1529 ^ self at:(Class instVarOffsetOf:'name') |
1583 ^ self at:(Class instVarOffsetOf:'name') |
1530 ! |
1584 ! |
1632 |
1686 |
1633 self isMeta ifTrue:[ |
1687 self isMeta ifTrue:[ |
1634 "/ metaclasses are not found via Smalltalk allClassesDo: |
1688 "/ metaclasses are not found via Smalltalk allClassesDo: |
1635 "/ here, walk over classes and enumerate corresponding metas. |
1689 "/ here, walk over classes and enumerate corresponding metas. |
1636 self soleInstance allSubclassesDo:[:aSubClass | |
1690 self soleInstance allSubclassesDo:[:aSubClass | |
1637 aBlock value:(aSubClass class) |
1691 aBlock value:(aSubClass theMetaclass) |
1638 ]. |
1692 ]. |
1639 ] ifFalse:[ |
1693 ] ifFalse:[ |
1640 Smalltalk allClassesDo:[:aClass | |
1694 Smalltalk allClassesDo:[:aClass | |
1641 (aClass isSubclassOf:self) ifTrue:[ |
1695 (aClass isSubclassOf:self) ifTrue:[ |
1642 aBlock value:aClass |
1696 aBlock value:aClass |
2311 self name printOn:aStream. |
2365 self name printOn:aStream. |
2312 ] ifFalse:[ |
2366 ] ifFalse:[ |
2313 self printClassNameOn:aStream. |
2367 self printClassNameOn:aStream. |
2314 ]. |
2368 ]. |
2315 aStream nextPutAll:' class instanceVariableNames:'''. |
2369 aStream nextPutAll:' class instanceVariableNames:'''. |
2316 self class printInstVarNamesOn:aStream indent:8. |
2370 self theMetaclass printInstVarNamesOn:aStream indent:8. |
2317 aStream nextPutAll:''''. |
2371 aStream nextPutAll:''''. |
2318 |
2372 |
2319 "mhmh - good idea; saw this in SmallDraw sourcecode ..." |
2373 "mhmh - good idea; saw this in SmallDraw sourcecode ..." |
2320 |
2374 |
2321 anySuperClassInstVar := false. |
2375 anySuperClassInstVar := false. |
2322 self allSuperclassesDo:[:aSuperClass | |
2376 self allSuperclassesDo:[:aSuperClass | |
2323 aSuperClass class instVarNames do:[:ignored | anySuperClassInstVar := true]. |
2377 aSuperClass theMetaclass instVarNames do:[:ignored | anySuperClassInstVar := true]. |
2324 ]. |
2378 ]. |
2325 |
2379 |
2326 aStream cr; cr; nextPut:(Character doubleQuote); cr; space. |
2380 aStream cr; cr; nextPut:(Character doubleQuote); cr; space. |
2327 anySuperClassInstVar ifFalse:[ |
2381 anySuperClassInstVar ifFalse:[ |
2328 aStream |
2382 aStream |
2331 aStream |
2385 aStream |
2332 nextPutLine:'The following class instance variables are inherited by this class:'. |
2386 nextPutLine:'The following class instance variables are inherited by this class:'. |
2333 aStream cr. |
2387 aStream cr. |
2334 self allSuperclassesDo:[:aSuperClass | |
2388 self allSuperclassesDo:[:aSuperClass | |
2335 aStream tab; nextPutAll:aSuperClass name; nextPutAll:' - '. |
2389 aStream tab; nextPutAll:aSuperClass name; nextPutAll:' - '. |
2336 aStream nextPutLine:(aSuperClass class instanceVariableString). |
2390 aStream nextPutLine:(aSuperClass theMetaclass instanceVariableString). |
2337 ]. |
2391 ]. |
2338 |
2392 |
2339 ]. |
2393 ]. |
2340 aStream nextPut:(Character doubleQuote); cr. |
2394 aStream nextPut:(Character doubleQuote); cr. |
2341 |
2395 |
2781 " |
2835 " |
2782 |
2836 |
2783 "Modified: 22.8.1997 / 14:59:14 / cg" |
2837 "Modified: 22.8.1997 / 14:59:14 / cg" |
2784 ! |
2838 ! |
2785 |
2839 |
2786 isObsolete |
2840 isObsolete |
2787 ^ false |
2841 "return true, if the receiver is obsolete |
|
2842 (i.e. has been replaced by a different class or was removed, |
|
2843 but is still referenced by instanced)" |
|
2844 |
|
2845 |cat| |
|
2846 |
|
2847 cat := self category. |
|
2848 |
|
2849 ^ cat = 'obsolete' |
|
2850 or:[cat = 'removed' |
|
2851 or:[cat = '* removed *' |
|
2852 or:[cat = '* obsolete *']]] |
2788 ! |
2853 ! |
2789 |
2854 |
2790 isSubclassOf:aClass |
2855 isSubclassOf:aClass |
2791 "return true, if I am a subclass of the argument, aClass" |
2856 "return true, if I am a subclass of the argument, aClass" |
2792 |
2857 |
2910 ] |
2975 ] |
2911 ]. |
2976 ]. |
2912 ^ nil |
2977 ^ nil |
2913 |
2978 |
2914 "Modified: / 18.7.1998 / 22:53:19 / cg" |
2979 "Modified: / 18.7.1998 / 22:53:19 / cg" |
|
2980 ! |
|
2981 |
|
2982 lookupMethodFor:aSelector |
|
2983 "return the method, which would be executed if aSelector was sent to |
|
2984 an instance of the receiver. I.e. the selector arrays of the receiver |
|
2985 and all of its superclasses are searched for aSelector. |
|
2986 Return the method, or nil if instances do not understand aSelector. |
|
2987 EXPERIMENTAL: take care of multiple superclasses." |
|
2988 |
|
2989 |m cls| |
|
2990 |
|
2991 cls := self. |
|
2992 [cls notNil] whileTrue:[ |
|
2993 m := cls compiledMethodAt:aSelector. |
|
2994 m notNil ifTrue:[^ m]. |
|
2995 cls := cls superclass |
|
2996 ]. |
|
2997 ^ nil |
2915 ! |
2998 ! |
2916 |
2999 |
2917 nameWithoutNameSpacePrefix |
3000 nameWithoutNameSpacePrefix |
2918 |nm owner| |
3001 |nm owner| |
2919 |
3002 |
3588 self isMeta ifTrue:[ |
3671 self isMeta ifTrue:[ |
3589 self halt. |
3672 self halt. |
3590 "/ metaclasses are not found via Smalltalk allClassesDo: |
3673 "/ metaclasses are not found via Smalltalk allClassesDo: |
3591 "/ here, walk over classes and enumerate corresponding metas. |
3674 "/ here, walk over classes and enumerate corresponding metas. |
3592 self soleInstance subclassesDo:[:aSubClass | |
3675 self soleInstance subclassesDo:[:aSubClass | |
3593 aBlock value:(aSubClass class) |
3676 aBlock value:(aSubClass theMetaclass) |
3594 ]. |
3677 ]. |
3595 ^ self |
3678 ^ self |
3596 ]. |
3679 ]. |
3597 |
3680 |
3598 "/ use cached information (avoid class hierarchy search) |
3681 "/ use cached information (avoid class hierarchy search) |
3646 against the version string as contained in the version method" |
3729 against the version string as contained in the version method" |
3647 |
3730 |
3648 ^ true |
3731 ^ true |
3649 ! |
3732 ! |
3650 |
3733 |
|
3734 whichClassDefinesClassVar:aVariableName |
|
3735 "return the class which defines the class variable |
|
3736 named aVariableName. This method should not be used for |
|
3737 repeated searches (i.e. in the compiler/parser), since it creates |
|
3738 many throw away intermediate objects." |
|
3739 |
|
3740 |cls| |
|
3741 |
|
3742 cls := self. |
|
3743 [cls notNil] whileTrue:[ |
|
3744 (cls classVarNames includes:aVariableName) ifTrue:[ ^ cls]. |
|
3745 cls := cls superclass |
|
3746 ]. |
|
3747 ^ nil |
|
3748 ! |
|
3749 |
|
3750 whichClassIncludesSelector:aSelector |
|
3751 "return the class in the inheritance chain, which implements the method |
|
3752 for aSelector; return nil if none." |
|
3753 |
|
3754 |cls| |
|
3755 |
|
3756 cls := self. |
|
3757 [cls notNil] whileTrue:[ |
|
3758 (cls includesSelector:aSelector) ifTrue:[^ cls]. |
|
3759 cls := cls superclass |
|
3760 ]. |
|
3761 ^ nil |
|
3762 ! |
|
3763 |
3651 withAllSuperclasses |
3764 withAllSuperclasses |
3652 "return a collection containing the receiver and all |
3765 "return a collection containing the receiver and all |
3653 of the receivers accumulated superclasses" |
3766 of the receivers accumulated superclasses" |
3654 |
3767 |
3655 |aCollection theSuperClass| |
3768 |aCollection theSuperClass| |