author | Claus Gittinger <cg@exept.de> |
Thu, 23 Nov 1995 02:16:37 +0100 | |
changeset 605 | 8b17f96bf05a |
parent 530 | 07d0bce293c9 |
child 618 | 9048d43527d2 |
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 |
||
13 |
Object subclass:#MiniInspector |
|
14 |
instanceVariableNames:'inspectedObject' |
|
15 |
classVariableNames: '' |
|
16 |
poolDictionaries:'' |
|
308 | 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 |
version |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
384
diff
changeset
|
37 |
^ '$Header: /cvs/stx/stx/libbasic/MiniInspector.st,v 1.11 1995-11-11 15:24:31 cg Exp $' |
89 | 38 |
! |
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
a primitive (non graphical) inspector for use on systems without |
|
43 |
graphics or when the real inspector dies. |
|
44 |
" |
|
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 |
initializeFor:anObject |
|
58 |
inspectedObject := anObject. |
|
59 |
^self |
|
60 |
! |
|
61 |
||
62 |
enter |
|
63 |
self commandLoop. |
|
64 |
^ nil |
|
65 |
! |
|
66 |
||
67 |
commandLoop |
|
68 |
|cmd done valid| |
|
69 |
||
70 |
'Inspector:' printNewline. |
|
71 |
' ' printNewline. |
|
72 |
done := false. |
|
73 |
[done] whileFalse:[ |
|
308 | 74 |
valid := false. |
75 |
cmd := self getCommand. |
|
76 |
(cmd == $0) ifTrue:[ |
|
77 |
valid := true. |
|
78 |
self inspectInstvar:0 of:inspectedObject |
|
79 |
]. |
|
80 |
(cmd == $1) ifTrue:[ |
|
81 |
valid := true. |
|
82 |
self inspectInstvar:1 of:inspectedObject |
|
83 |
]. |
|
84 |
(cmd == $2) ifTrue:[ |
|
85 |
valid := true. |
|
86 |
self inspectInstvar:2 of:inspectedObject |
|
87 |
]. |
|
88 |
(cmd == $3) ifTrue:[ |
|
89 |
valid := true. |
|
90 |
self inspectInstvar:3 of:inspectedObject |
|
91 |
]. |
|
92 |
(cmd == $i) ifTrue:[ |
|
93 |
valid := true. |
|
94 |
self printInstVarsOf:inspectedObject |
|
95 |
]. |
|
96 |
(cmd == $p) ifTrue:[ |
|
97 |
valid := true. |
|
98 |
inspectedObject printNewline |
|
99 |
]. |
|
100 |
(cmd == $q) ifTrue:[valid := true. done := true ]. |
|
101 |
valid ifFalse: [ |
|
102 |
'valid commands: |
|
74 | 103 |
(i)nstvars |
104 |
(p)rint |
|
105 |
(1-9) inspect instvar |
|
106 |
(q)uit' errorPrintNewline |
|
308 | 107 |
] |
1 | 108 |
]. |
109 |
^ cmd |
|
110 |
! |
|
111 |
||
112 |
getCommand |
|
113 |
|cmd c| |
|
114 |
'inspector> ' print. |
|
115 |
cmd := Character fromUser. |
|
116 |
c := cmd. |
|
117 |
[ c isEndOfLineCharacter ] whileFalse: [ |
|
308 | 118 |
c := Character fromUser |
1 | 119 |
]. |
120 |
^ cmd |
|
121 |
! |
|
122 |
||
123 |
printInstVarsOf:anObject |
|
124 |
|n| |
|
125 |
n := anObject class instSize. |
|
126 |
'number of instvars: ' print. n printNewline. |
|
127 |
1 to:n do:[:i | |
|
308 | 128 |
' ' print. i print. ': ' print. |
129 |
(anObject instVarAt:i) printNewline |
|
1 | 130 |
] |
131 |
! |
|
132 |
||
133 |
inspectInstvar:which of:anObject |
|
134 |
which > (anObject class instSize) ifTrue:[ |
|
308 | 135 |
'invalid instvar' printNewline |
1 | 136 |
] ifFalse: [ |
308 | 137 |
(anObject instVarAt:which) inspect |
1 | 138 |
] |
139 |
! ! |