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 |
|
|
13 |
Object subclass:#MiniInspector
|
618
|
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.
|
|
40 |
"
|
618
|
41 |
!
|
|
42 |
|
|
43 |
version
|
|
44 |
^ '$Header: /cvs/stx/stx/libbasic/MiniInspector.st,v 1.12 1995-11-23 02:11:36 cg Exp $'
|
89
|
45 |
! !
|
1
|
46 |
|
|
47 |
!MiniInspector class methodsFor:'instance creation'!
|
|
48 |
|
|
49 |
openOn:anObject
|
|
50 |
|anInspector|
|
|
51 |
anInspector := (self new) initializeFor:anObject.
|
|
52 |
anInspector enter
|
|
53 |
! !
|
|
54 |
|
|
55 |
!MiniInspector methodsFor:'private'!
|
|
56 |
|
|
57 |
commandLoop
|
|
58 |
|cmd done valid|
|
|
59 |
|
|
60 |
'Inspector:' printNewline.
|
|
61 |
' ' printNewline.
|
|
62 |
done := false.
|
|
63 |
[done] whileFalse:[
|
308
|
64 |
valid := false.
|
|
65 |
cmd := self getCommand.
|
|
66 |
(cmd == $0) ifTrue:[
|
|
67 |
valid := true.
|
|
68 |
self inspectInstvar:0 of:inspectedObject
|
|
69 |
].
|
|
70 |
(cmd == $1) ifTrue:[
|
|
71 |
valid := true.
|
|
72 |
self inspectInstvar:1 of:inspectedObject
|
|
73 |
].
|
|
74 |
(cmd == $2) ifTrue:[
|
|
75 |
valid := true.
|
|
76 |
self inspectInstvar:2 of:inspectedObject
|
|
77 |
].
|
|
78 |
(cmd == $3) ifTrue:[
|
|
79 |
valid := true.
|
|
80 |
self inspectInstvar:3 of:inspectedObject
|
|
81 |
].
|
|
82 |
(cmd == $i) ifTrue:[
|
|
83 |
valid := true.
|
|
84 |
self printInstVarsOf:inspectedObject
|
|
85 |
].
|
|
86 |
(cmd == $p) ifTrue:[
|
|
87 |
valid := true.
|
|
88 |
inspectedObject printNewline
|
|
89 |
].
|
|
90 |
(cmd == $q) ifTrue:[valid := true. done := true ].
|
|
91 |
valid ifFalse: [
|
|
92 |
'valid commands:
|
74
|
93 |
(i)nstvars
|
|
94 |
(p)rint
|
|
95 |
(1-9) inspect instvar
|
|
96 |
(q)uit' errorPrintNewline
|
308
|
97 |
]
|
1
|
98 |
].
|
|
99 |
^ cmd
|
|
100 |
!
|
|
101 |
|
618
|
102 |
enter
|
|
103 |
self commandLoop.
|
|
104 |
^ nil
|
|
105 |
!
|
|
106 |
|
1
|
107 |
getCommand
|
|
108 |
|cmd c|
|
|
109 |
'inspector> ' print.
|
|
110 |
cmd := Character fromUser.
|
|
111 |
c := cmd.
|
|
112 |
[ c isEndOfLineCharacter ] whileFalse: [
|
308
|
113 |
c := Character fromUser
|
1
|
114 |
].
|
|
115 |
^ cmd
|
|
116 |
!
|
|
117 |
|
618
|
118 |
initializeFor:anObject
|
|
119 |
inspectedObject := anObject.
|
|
120 |
^self
|
|
121 |
!
|
|
122 |
|
|
123 |
inspectInstvar:which of:anObject
|
|
124 |
which > (anObject class instSize) ifTrue:[
|
|
125 |
'invalid instvar' printNewline
|
|
126 |
] ifFalse: [
|
|
127 |
(anObject instVarAt:which) inspect
|
|
128 |
]
|
|
129 |
!
|
|
130 |
|
1
|
131 |
printInstVarsOf:anObject
|
|
132 |
|n|
|
|
133 |
n := anObject class instSize.
|
|
134 |
'number of instvars: ' print. n printNewline.
|
|
135 |
1 to:n do:[:i |
|
308
|
136 |
' ' print. i print. ': ' print.
|
|
137 |
(anObject instVarAt:i) printNewline
|
1
|
138 |
]
|
618
|
139 |
! !
|
1
|
140 |
|