SnapShotImage.st
author Claus Gittinger <cg@exept.de>
Mon, 25 Jun 2001 18:51:08 +0200
changeset 1470 7b20694c92e7
parent 1448 42ec8770d09f
child 1476 b6b941f16e63
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1448
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
     1
"{ Package: 'stx:libtool2' }"
1415
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
Object subclass:#SnapShotImage
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
	instanceVariableNames:'memory globals'
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	classVariableNames:''
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
	poolDictionaries:''
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
	category:'System-Support'
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
!
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
1448
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    10
!SnapShotImage class methodsFor:'documentation'!
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    11
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    12
documentation
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    13
"
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    14
    I simulate a Smalltalk environment as present in a snapshot image.
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    15
    My protocol mimics the NameSpace (i.e. class-environment) protocol,
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    16
    and I can be used as a Browsers environment, in order to open a
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    17
    browser into an old snapShot image (st.img - file).
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    18
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    19
    I am not used directly; instead, via the SystemBrowsers entry:
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    20
        SystemBrowser openOnSnapShotImage:'/export/home/cg/work/stx/projects/smalltalk/st.img'
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    21
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    22
    [author:]
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    23
        Claus Gittinger
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    24
"
1470
7b20694c92e7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1448
diff changeset
    25
!
7b20694c92e7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1448
diff changeset
    26
7b20694c92e7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1448
diff changeset
    27
examples
7b20694c92e7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1448
diff changeset
    28
"
7b20694c92e7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1448
diff changeset
    29
    |i m|
7b20694c92e7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1448
diff changeset
    30
7b20694c92e7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1448
diff changeset
    31
    i := self for:'st.img'.
7b20694c92e7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1448
diff changeset
    32
    m := i memory.
7b20694c92e7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1448
diff changeset
    33
    m  fetchObjectAt:16r38000000
7b20694c92e7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1448
diff changeset
    34
"
1448
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    35
! !
1415
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
!SnapShotImage class methodsFor:'instance creation'!
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
for:aFilename
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
    ^ self new for:aFilename
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
! !
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
1470
7b20694c92e7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1448
diff changeset
    43
!SnapShotImage methodsFor:'accessing'!
7b20694c92e7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1448
diff changeset
    44
7b20694c92e7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1448
diff changeset
    45
memory
7b20694c92e7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1448
diff changeset
    46
    ^ memory
7b20694c92e7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1448
diff changeset
    47
! !
7b20694c92e7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1448
diff changeset
    48
1415
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
!SnapShotImage methodsFor:'private'!
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
fetchGlobals
1417
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    52
    globals := IdentityDictionary new.
1415
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    memory globalEntries do:[:eachEntry |
1417
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    54
        |nameSymRef valRef nameSym value|
1415
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
1417
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    56
        nameSymRef := eachEntry key.
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    57
        valRef := eachEntry value.
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    58
        nameSymRef isImageSymbol ifFalse:[self halt].
1415
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
1417
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    60
        nameSym := (memory printStringOfSymbol:nameSymRef) asSymbol.
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    61
        globals at:nameSym put:valRef
1415
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    ].
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
!
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
for:aFilename
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    memory := SnapShotImageMemory for:aFilename.
1418
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    67
    memory image:self.
1448
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    68
    memory readHeader
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    69
! !
1415
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
!SnapShotImage methodsFor:'smalltalk protocol'!
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
allClassesDo:aBlock
1417
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    74
    self keysAndValuesDo:[:key :valRef |
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    75
        valRef isInteger ifFalse:[
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    76
            valRef ~~ true ifTrue:[
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    77
                valRef ~~ false ifTrue:[
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    78
                    valRef notNil ifTrue:[
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    79
                        valRef isImageBehavior ifTrue:[
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    80
                            aBlock value:valRef
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    81
                        ]
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    82
                    ]
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    83
                ]
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    84
            ]
1415
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
        ]
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    ].
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
!
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
1418
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    89
allClassesInCategory:aCategory
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    90
    |coll|
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    91
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    92
    coll := OrderedCollection new.
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    93
    self allClassesInCategory:aCategory do:[:aClass |
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    94
        coll add:aClass
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    95
    ].
1448
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    96
    ^ coll
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    97
!
1418
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    98
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    99
allClassesInCategory:aCategory do:aBlock
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   100
    "evaluate the argument, aBlock for all classes in the aCategory;
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   101
     The order of the classes is not defined."
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   102
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   103
    aCategory notNil ifTrue:[
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   104
        self allClassesDo:[:aClass |
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   105
            aClass isMeta ifFalse:[
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   106
                (aClass category = aCategory) ifTrue:[
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   107
                    aBlock value:aClass
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   108
                ]
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   109
            ]
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   110
        ]
1448
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   111
    ]
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   112
!
1418
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   113
1417
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   114
at:aKey
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   115
    globals isNil ifTrue:[
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   116
        self fetchGlobals
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   117
    ].
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   118
    ^ globals at:aKey
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   119
!
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   120
1418
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   121
at:aKey ifAbsent:exceptionValue
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   122
    globals isNil ifTrue:[
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   123
        self fetchGlobals
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   124
    ].
1448
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   125
    ^ globals at:aKey ifAbsent:exceptionValue
42ec8770d09f comment added
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   126
!
1418
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   127
1415
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
keysAndValuesDo:aTwoArgBlock
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    globals isNil ifTrue:[
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
        self fetchGlobals
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    ].
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    globals keysAndValuesDo:aTwoArgBlock
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
! !
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
!SnapShotImage class methodsFor:'documentation'!
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
version
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    ^ '$Header$'
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
! !