SnapShotImage.st
author ps
Thu, 26 Oct 2000 19:47:05 +0200
changeset 1423 5bb61f51152d
parent 1422 948a90b76e72
child 1448 42ec8770d09f
permissions -rw-r--r--
checkin from browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1422
948a90b76e72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
     1
"{ Package: 'stx:libtool' }"
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
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
!SnapShotImage class methodsFor:'instance creation'!
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
for:aFilename
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
    ^ self new for:aFilename
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
! !
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
!SnapShotImage methodsFor:'private'!
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
fetchGlobals
1417
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    20
    globals := IdentityDictionary new.
1415
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
    memory globalEntries do:[:eachEntry |
1417
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    22
        |nameSymRef valRef nameSym value|
1415
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
1417
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    24
        nameSymRef := eachEntry key.
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    25
        valRef := eachEntry value.
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    26
        nameSymRef isImageSymbol ifFalse:[self halt].
1415
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
1417
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    28
        nameSym := (memory printStringOfSymbol:nameSymRef) asSymbol.
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    29
        globals at:nameSym put:valRef
1415
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
    ].
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
!
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
for:aFilename
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
    memory := SnapShotImageMemory for:aFilename.
1418
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    35
    memory image:self.
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    36
    memory readHeader! !
1415
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
!SnapShotImage methodsFor:'smalltalk protocol'!
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
allClassesDo:aBlock
1417
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    41
    self keysAndValuesDo:[:key :valRef |
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    42
        valRef isInteger ifFalse:[
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    43
            valRef ~~ true ifTrue:[
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    44
                valRef ~~ false ifTrue:[
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    45
                    valRef notNil ifTrue:[
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    46
                        valRef isImageBehavior ifTrue:[
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    47
                            aBlock value:valRef
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    48
                        ]
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    49
                    ]
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    50
                ]
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    51
            ]
1415
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
        ]
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    ].
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
!
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
1418
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    56
allClassesInCategory:aCategory
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    57
    |coll|
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    58
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    59
    coll := OrderedCollection new.
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    60
    self allClassesInCategory:aCategory do:[:aClass |
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    61
        coll add:aClass
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    62
    ].
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    63
    ^ coll!
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    64
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    65
allClassesInCategory:aCategory do:aBlock
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    66
    "evaluate the argument, aBlock for all classes in the aCategory;
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    67
     The order of the classes is not defined."
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    68
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    69
    aCategory notNil ifTrue:[
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    70
        self allClassesDo:[:aClass |
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    71
            aClass isMeta ifFalse:[
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    72
                (aClass category = aCategory) ifTrue:[
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    73
                    aBlock value:aClass
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    74
                ]
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    75
            ]
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    76
        ]
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    77
    ]!
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    78
1417
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    79
at:aKey
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    80
    globals isNil ifTrue:[
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    81
        self fetchGlobals
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
    ^ globals at:aKey
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    84
!
28d6026fe30c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    85
1418
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    86
at:aKey ifAbsent:exceptionValue
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    87
    globals isNil ifTrue:[
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    88
        self fetchGlobals
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    89
    ].
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    90
    ^ globals at:aKey ifAbsent:exceptionValue!
7466259d8bb5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
    91
1415
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
keysAndValuesDo:aTwoArgBlock
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    globals isNil ifTrue:[
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
        self fetchGlobals
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    ].
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    globals keysAndValuesDo:aTwoArgBlock
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
! !
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
!SnapShotImage class methodsFor:'documentation'!
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
version
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    ^ '$Header$'
77abca16cfa3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
! !