SnapShotImageMemory.st
changeset 1420 9a649c1bb8cf
parent 1419 f808d17ff6f5
child 1422 948a90b76e72
equal deleted inserted replaced
1419:f808d17ff6f5 1420:9a649c1bb8cf
   343 
   343 
   344 printStringOfSymbol:aSymbolRef
   344 printStringOfSymbol:aSymbolRef
   345     |nBytes|
   345     |nBytes|
   346 
   346 
   347     (aSymbolRef isImageSymbol) ifFalse:[self halt].
   347     (aSymbolRef isImageSymbol) ifFalse:[self halt].
   348 ^ self fetchStringFor:aSymbolRef.
   348     ^ self fetchStringFor:aSymbolRef.
   349 "/    nBytes := aSymbolRef size - (intSize * 3).
   349 "/    nBytes := aSymbolRef size - (intSize * 3).
   350 "/    ^ ((ByteArray new:nBytes-1) replaceFrom:1 to:nBytes-1 with:aSymbolRef startingAt:1) asString.
   350 "/    ^ ((ByteArray new:nBytes-1) replaceFrom:1 to:nBytes-1 with:aSymbolRef startingAt:1) asString.
   351 !
   351 !
   352 
   352 
   353 readGlobalEntries
   353 readGlobalEntries
   636             stream nextUnsignedLongMSB:msb. "/ 0-litRef
   636             stream nextUnsignedLongMSB:msb. "/ 0-litRef
   637             oldConstTable := stream nextUnsignedLongMSB:msb.  
   637             oldConstTable := stream nextUnsignedLongMSB:msb.  
   638             nConsts := stream nextUnsignedLongMSB:msb.
   638             nConsts := stream nextUnsignedLongMSB:msb.
   639             nConsts timesRepeat:[ stream nextUnsignedLongMSB:msb ].
   639             nConsts timesRepeat:[ stream nextUnsignedLongMSB:msb ].
   640 
   640 
   641             Transcript showCR:className.
   641             "/ Transcript showCR:className.
   642         ].
   642         ].
   643 !
   643 !
   644 
   644 
   645 readSymbolEntries
   645 readSymbolEntries
   646         |refPointer theSymbolPtr theSymbolRef pos|
   646         |refPointer theSymbolPtr theSymbolRef pos|
   764 
   764 
   765     flags := classRef flags.
   765     flags := classRef flags.
   766     ^ flags bitTest:Behavior flagSymbol 
   766     ^ flags bitTest:Behavior flagSymbol 
   767 !
   767 !
   768 
   768 
       
   769 isJavaMethod    
       
   770     |nm|
       
   771 
       
   772     nm := classRef name.
       
   773     ^ (nm = 'JavaMethod'
       
   774       or:[ nm = 'JavaMethodWithException' 
       
   775       or:[ nm = 'JavaMethodWithHandler' 
       
   776       or:[ nm = 'JavaNativeMethod' ]]])
       
   777 !
       
   778 
   769 isLazyMethod                               
   779 isLazyMethod                               
   770     ^ classRef name = 'LazyMethod'!
   780     ^ classRef name = 'LazyMethod'!
   771 
   781 
   772 isMeta
   782 isMeta
   773     ^ false
   783     ^ false
   774 !
   784 !
   775 
   785 
   776 isMethod                               
   786 isMethod                               
   777     ^ classRef name = 'Method'
   787     |cls|
       
   788 
       
   789     cls := classRef.
       
   790     [cls notNil] whileTrue:[
       
   791         cls name = 'Method' ifTrue:[^ true].
       
   792         cls := cls superclass
       
   793     ].
       
   794     ^ false.
   778 !
   795 !
   779 
   796 
   780 isMethodDictionary
   797 isMethodDictionary
   781     ^ classRef name = 'MethodDictionary'
   798     ^ classRef name = 'MethodDictionary'
   782 !
   799 !
   783 
   800 
   784 isMethodOrLazyMethod                 
   801 isMethodOrLazyMethod                 
   785     classRef name = 'LazyMethod' ifTrue:[^ true].
   802     classRef name = 'LazyMethod' ifTrue:[^ true].
   786     ^ classRef name = 'Method'
   803     ^ self isMethod
   787 !
   804 !
   788 
   805 
   789 isString                               
   806 isString                               
   790     ^ classRef name = 'String'
   807     ^ classRef name = 'String'
   791 ! !
   808 ! !
   926     self halt.!
   943     self halt.!
   927 
   944 
   928 isIgnored
   945 isIgnored
   929     ^ false!
   946     ^ false!
   930 
   947 
   931 isJavaMethod
       
   932     ^ self class name = 'JavaMethod'!
       
   933 
       
   934 isPrivate
   948 isPrivate
   935     ^ false!
   949     ^ false!
   936 
   950 
   937 isProtected
   951 isProtected
   938     ^ false!
   952     ^ false!
   953 mclass
   967 mclass
   954     |mclassSlotOffset mclassPtr mclass|
   968     |mclassSlotOffset mclassPtr mclass|
   955 
   969 
   956     self isMethod ifTrue:[
   970     self isMethod ifTrue:[
   957         mclassSlotOffset := Method instVarOffsetOf:'mclass'.
   971         mclassSlotOffset := Method instVarOffsetOf:'mclass'.
       
   972     ] ifFalse:[
       
   973         self isJavaMethod ifTrue:[
       
   974             mclassSlotOffset := JavaMethod instVarOffsetOf:'javaClass'.
       
   975         ]
       
   976     ].
       
   977 
       
   978     mclassSlotOffset notNil ifTrue:[
   958         mclassPtr := self at:mclassSlotOffset.
   979         mclassPtr := self at:mclassSlotOffset.
   959         mclassPtr ~~ 0 ifTrue:[
   980         mclassPtr ~~ 0 ifTrue:[
   960             mclass := memory fetchObjectAt:mclassPtr.
   981             mclassPtr isInteger ifTrue:[
       
   982                 mclass := memory fetchObjectAt:mclassPtr.
       
   983                 self at:mclassSlotOffset put:mclass.    
       
   984             ] ifFalse:[
       
   985                 mclass := mclassPtr.
       
   986             ].
   961             mclass isImageBehavior ifFalse:[
   987             mclass isImageBehavior ifFalse:[
   962                 self halt
   988                 self halt
   963             ].
   989             ].
   964             ^ mclass
   990             ^ mclass
   965         ].
   991         ].
   978                     ^ eachClass theMetaclass
  1004                     ^ eachClass theMetaclass
   979                 ].
  1005                 ].
   980             ]
  1006             ]
   981         ].
  1007         ].
   982         self halt.
  1008         self halt.
   983     ].
  1009         ^ nil.
       
  1010     ].
       
  1011     ^ nil.
   984     self halt.
  1012     self halt.
   985 !
  1013 !
   986 
  1014 
   987 numArgs
  1015 numArgs
   988     |flagsSlotOffset flagsPtr flags|
  1016     |flagsSlotOffset flagsPtr flags|
  1005     self isImageBehavior ifTrue:[
  1033     self isImageBehavior ifTrue:[
  1006         self isMeta ifTrue:[
  1034         self isMeta ifTrue:[
  1007             ^ self theNonMetaclass package
  1035             ^ self theNonMetaclass package
  1008         ].
  1036         ].
  1009         packageSlotOffset := Class instVarOffsetOf:'package'.
  1037         packageSlotOffset := Class instVarOffsetOf:'package'.
  1010     ].
  1038     ] ifFalse:[
  1011     self isMethod ifTrue:[
  1039         self isMethod ifTrue:[
  1012         packageSlotOffset := Method instVarOffsetOf:'package'.
  1040             packageSlotOffset := Method instVarOffsetOf:'package'.
       
  1041         ] ifFalse:[
       
  1042             self isLazyMethod ifTrue:[
       
  1043                 packageSlotOffset := Method instVarOffsetOf:'package'.
       
  1044             ].
       
  1045         ].
  1013     ].
  1046     ].
  1014     packageSlotOffset notNil ifTrue:[
  1047     packageSlotOffset notNil ifTrue:[
  1015         packagePtr := self at:packageSlotOffset.
  1048         packagePtr := self at:packageSlotOffset.
  1016         packageRef := memory fetchObjectAt:packagePtr.
  1049         packageRef := memory fetchObjectAt:packagePtr.
  1017         packageRef isNil ifTrue:[^ nil].
  1050         packageRef isNil ifTrue:[^ nil].
  1018 
  1051 
  1019         packageRef isImageSymbol ifFalse:[
  1052         packageRef isImageSymbol ifFalse:[
  1020             self halt.
  1053             packageRef isImageBytes ifFalse:[
       
  1054                 self halt.
       
  1055             ].
       
  1056             "/ mhmh - can be a string sometimes ...
  1021         ].
  1057         ].
  1022         package := memory fetchStringFor:packageRef.
  1058         package := memory fetchStringFor:packageRef.
  1023         ^ package asSymbol
  1059         ^ package asSymbol
  1024     ].
  1060     ].
  1025     self isMeta ifTrue:[
  1061     self isMeta ifTrue:[
  1026         self halt
  1062         self halt
  1027     ].
  1063     ].
  1028 
  1064 
  1029     self halt.
  1065     ^ nil
  1030 !
  1066 !
  1031 
  1067 
  1032 previousVersion
  1068 previousVersion
  1033     ^ nil!
  1069     ^ nil!
  1034 
  1070 
  3494 isFloats
  3530 isFloats
  3495     ^ (self flags bitAnd:Behavior maskIndexType) == Behavior flagFloats.
  3531     ^ (self flags bitAnd:Behavior maskIndexType) == Behavior flagFloats.
  3496 !
  3532 !
  3497 
  3533 
  3498 isLoaded
  3534 isLoaded
       
  3535     |superclass|
       
  3536 
       
  3537     superclass := self superclass.
       
  3538     superclass isNil ifTrue:[^ true].
  3499     ^ self superclass name ~= 'Autoload'
  3539     ^ self superclass name ~= 'Autoload'
  3500 !
  3540 !
  3501 
  3541 
  3502 isLongLongs
  3542 isLongLongs
  3503     ^ (self flags bitAnd:Behavior maskIndexType) == Behavior flagLongLongs.
  3543     ^ (self flags bitAnd:Behavior maskIndexType) == Behavior flagLongLongs.