author | Claus Gittinger <cg@exept.de> |
Mon, 24 Aug 1998 18:32:06 +0200 | |
changeset 3777 | f351744c575f |
parent 2775 | acdd73312418 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
308 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
720 | 13 |
Object subclass:#MiniInspector |
1297 | 14 |
instanceVariableNames:'inspectedObject' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'System-Debugging-Support' |
|
1 | 18 |
! |
19 |
||
89 | 20 |
!MiniInspector class methodsFor:'documentation'! |
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
308 | 25 |
All Rights Reserved |
1 | 26 |
|
89 | 27 |
This software is furnished under a license and may be used |
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
1 | 35 |
|
89 | 36 |
documentation |
37 |
" |
|
38 |
a primitive (non graphical) inspector for use on systems without |
|
39 |
graphics or when the real inspector dies. |
|
1297 | 40 |
|
41 |
[author:] |
|
42 |
Claus Gittinger |
|
89 | 43 |
" |
44 |
! ! |
|
1 | 45 |
|
46 |
!MiniInspector class methodsFor:'instance creation'! |
|
47 |
||
48 |
openOn:anObject |
|
49 |
|anInspector| |
|
50 |
anInspector := (self new) initializeFor:anObject. |
|
51 |
anInspector enter |
|
52 |
! ! |
|
53 |
||
54 |
!MiniInspector methodsFor:'private'! |
|
55 |
||
56 |
commandLoop |
|
57 |
|cmd done valid| |
|
58 |
||
1426 | 59 |
'Inspector:' printCR. |
60 |
' ' printCR. |
|
1 | 61 |
done := false. |
62 |
[done] whileFalse:[ |
|
1426 | 63 |
valid := false. |
64 |
cmd := self getCommand. |
|
2775
acdd73312418
handle EOF when fetching a command.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
65 |
cmd isNil ifTrue:[ "/ EOF -> quit |
acdd73312418
handle EOF when fetching a command.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
66 |
cmd := $q |
acdd73312418
handle EOF when fetching a command.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
67 |
]. |
1426 | 68 |
(cmd >= $0 and:[cmd <= $9]) ifTrue:[ |
69 |
valid := true. |
|
70 |
self inspectInstvar:(cmd asciiValue - $0 asciiValue) of:inspectedObject |
|
71 |
]. |
|
72 |
(cmd == $i) ifTrue:[ |
|
73 |
valid := true. |
|
74 |
self printInstVarsOf:inspectedObject |
|
75 |
]. |
|
76 |
(cmd == $p) ifTrue:[ |
|
77 |
valid := true. |
|
78 |
inspectedObject printCR |
|
79 |
]. |
|
80 |
(cmd == $q) ifTrue:[valid := true. done := true ]. |
|
81 |
valid ifFalse: [ |
|
82 |
'valid commands: |
|
74 | 83 |
(i)nstvars |
84 |
(p)rint |
|
903 | 85 |
(0-9) inspect instvar |
1426 | 86 |
(q)uit' errorPrintCR |
87 |
] |
|
1 | 88 |
]. |
89 |
^ cmd |
|
1426 | 90 |
|
2775
acdd73312418
handle EOF when fetching a command.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
91 |
"Modified: 24.7.1997 / 10:00:24 / cg" |
1 | 92 |
! |
93 |
||
618 | 94 |
enter |
95 |
self commandLoop. |
|
96 |
^ nil |
|
97 |
! |
|
98 |
||
1 | 99 |
getCommand |
100 |
|cmd c| |
|
101 |
'inspector> ' print. |
|
102 |
cmd := Character fromUser. |
|
103 |
c := cmd. |
|
104 |
[ c isEndOfLineCharacter ] whileFalse: [ |
|
308 | 105 |
c := Character fromUser |
1 | 106 |
]. |
107 |
^ cmd |
|
108 |
! |
|
109 |
||
618 | 110 |
initializeFor:anObject |
111 |
inspectedObject := anObject. |
|
112 |
^self |
|
113 |
! |
|
114 |
||
115 |
inspectInstvar:which of:anObject |
|
116 |
which > (anObject class instSize) ifTrue:[ |
|
1426 | 117 |
which > (anObject basicSize) ifTrue:[ |
118 |
'invalid instvar' printCR |
|
119 |
] ifFalse:[ |
|
120 |
(anObject basicAt:which) inspect |
|
121 |
] |
|
618 | 122 |
] ifFalse: [ |
1426 | 123 |
(anObject instVarAt:which) inspect |
618 | 124 |
] |
1426 | 125 |
|
126 |
"Modified: 20.5.1996 / 10:27:40 / cg" |
|
618 | 127 |
! |
128 |
||
1 | 129 |
printInstVarsOf:anObject |
903 | 130 |
|n "{ Class: SmallInteger }" | |
131 |
||
1 | 132 |
n := anObject class instSize. |
1426 | 133 |
'number of instvars: ' print. n printCR. |
1 | 134 |
1 to:n do:[:i | |
1426 | 135 |
' ' print. i print. ': ' print. |
136 |
(anObject instVarAt:i) printCR |
|
903 | 137 |
]. |
138 |
n := anObject basicSize. |
|
1426 | 139 |
'number of indexed instvars: ' print. n printCR. |
903 | 140 |
n > 10 ifTrue:[n := 10]. |
141 |
1 to:n do:[:i | |
|
1426 | 142 |
' [' print. i print. ']: ' print. |
143 |
(anObject basicAt:i) printCR |
|
903 | 144 |
]. |
1426 | 145 |
|
146 |
"Modified: 20.5.1996 / 10:27:45 / cg" |
|
618 | 147 |
! ! |
1 | 148 |
|
658 | 149 |
!MiniInspector class methodsFor:'documentation'! |
150 |
||
151 |
version |
|
2775
acdd73312418
handle EOF when fetching a command.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
152 |
^ '$Header: /cvs/stx/stx/libbasic/Attic/MiniIns.st,v 1.19 1997-07-24 11:38:43 cg Exp $' |
658 | 153 |
! ! |