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.
|
|
65 |
(cmd >= $0 and:[cmd <= $9]) ifTrue:[
|
|
66 |
valid := true.
|
|
67 |
self inspectInstvar:(cmd asciiValue - $0 asciiValue) of:inspectedObject
|
|
68 |
].
|
|
69 |
(cmd == $i) ifTrue:[
|
|
70 |
valid := true.
|
|
71 |
self printInstVarsOf:inspectedObject
|
|
72 |
].
|
|
73 |
(cmd == $p) ifTrue:[
|
|
74 |
valid := true.
|
|
75 |
inspectedObject printCR
|
|
76 |
].
|
|
77 |
(cmd == $q) ifTrue:[valid := true. done := true ].
|
|
78 |
valid ifFalse: [
|
|
79 |
'valid commands:
|
74
|
80 |
(i)nstvars
|
|
81 |
(p)rint
|
903
|
82 |
(0-9) inspect instvar
|
1426
|
83 |
(q)uit' errorPrintCR
|
|
84 |
]
|
1
|
85 |
].
|
|
86 |
^ cmd
|
1426
|
87 |
|
|
88 |
"Modified: 20.5.1996 / 10:23:31 / cg"
|
1
|
89 |
!
|
|
90 |
|
618
|
91 |
enter
|
|
92 |
self commandLoop.
|
|
93 |
^ nil
|
|
94 |
!
|
|
95 |
|
1
|
96 |
getCommand
|
|
97 |
|cmd c|
|
|
98 |
'inspector> ' print.
|
|
99 |
cmd := Character fromUser.
|
|
100 |
c := cmd.
|
|
101 |
[ c isEndOfLineCharacter ] whileFalse: [
|
308
|
102 |
c := Character fromUser
|
1
|
103 |
].
|
|
104 |
^ cmd
|
|
105 |
!
|
|
106 |
|
618
|
107 |
initializeFor:anObject
|
|
108 |
inspectedObject := anObject.
|
|
109 |
^self
|
|
110 |
!
|
|
111 |
|
|
112 |
inspectInstvar:which of:anObject
|
|
113 |
which > (anObject class instSize) ifTrue:[
|
1426
|
114 |
which > (anObject basicSize) ifTrue:[
|
|
115 |
'invalid instvar' printCR
|
|
116 |
] ifFalse:[
|
|
117 |
(anObject basicAt:which) inspect
|
|
118 |
]
|
618
|
119 |
] ifFalse: [
|
1426
|
120 |
(anObject instVarAt:which) inspect
|
618
|
121 |
]
|
1426
|
122 |
|
|
123 |
"Modified: 20.5.1996 / 10:27:40 / cg"
|
618
|
124 |
!
|
|
125 |
|
1
|
126 |
printInstVarsOf:anObject
|
903
|
127 |
|n "{ Class: SmallInteger }" |
|
|
128 |
|
1
|
129 |
n := anObject class instSize.
|
1426
|
130 |
'number of instvars: ' print. n printCR.
|
1
|
131 |
1 to:n do:[:i |
|
1426
|
132 |
' ' print. i print. ': ' print.
|
|
133 |
(anObject instVarAt:i) printCR
|
903
|
134 |
].
|
|
135 |
n := anObject basicSize.
|
1426
|
136 |
'number of indexed instvars: ' print. n printCR.
|
903
|
137 |
n > 10 ifTrue:[n := 10].
|
|
138 |
1 to:n do:[:i |
|
1426
|
139 |
' [' print. i print. ']: ' print.
|
|
140 |
(anObject basicAt:i) printCR
|
903
|
141 |
].
|
1426
|
142 |
|
|
143 |
"Modified: 20.5.1996 / 10:27:45 / cg"
|
618
|
144 |
! !
|
1
|
145 |
|
658
|
146 |
!MiniInspector class methodsFor:'documentation'!
|
|
147 |
|
|
148 |
version
|
1426
|
149 |
^ '$Header: /cvs/stx/stx/libbasic/MiniInspector.st,v 1.18 1996-05-20 08:39:37 cg Exp $'
|
658
|
150 |
! !
|