1
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
1
|
3 |
All Rights Reserved
|
|
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:''
|
|
17 |
category:'System-Support'
|
|
18 |
!
|
|
19 |
|
|
20 |
MiniInspector comment:'
|
|
21 |
|
5
|
22 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
1
|
23 |
All Rights Reserved
|
|
24 |
|
|
25 |
a primitive (non graphical) inspector for use on systems without
|
|
26 |
graphics or when the real inspector dies.
|
|
27 |
|
74
|
28 |
$Header: /cvs/stx/stx/libbasic/MiniInspector.st,v 1.5 1994-03-30 10:29:13 claus Exp $
|
1
|
29 |
'!
|
|
30 |
|
|
31 |
!MiniInspector class methodsFor:'instance creation'!
|
|
32 |
|
|
33 |
openOn:anObject
|
|
34 |
|anInspector|
|
|
35 |
anInspector := (self new) initializeFor:anObject.
|
|
36 |
anInspector enter
|
|
37 |
! !
|
|
38 |
|
|
39 |
!MiniInspector methodsFor:'private'!
|
|
40 |
|
|
41 |
initializeFor:anObject
|
|
42 |
inspectedObject := anObject.
|
|
43 |
^self
|
|
44 |
!
|
|
45 |
|
|
46 |
enter
|
|
47 |
self commandLoop.
|
|
48 |
^ nil
|
|
49 |
!
|
|
50 |
|
|
51 |
commandLoop
|
|
52 |
|cmd done valid|
|
|
53 |
|
|
54 |
'Inspector:' printNewline.
|
|
55 |
' ' printNewline.
|
|
56 |
done := false.
|
|
57 |
[done] whileFalse:[
|
|
58 |
valid := false.
|
|
59 |
cmd := self getCommand.
|
|
60 |
(cmd == $0) ifTrue:[
|
|
61 |
valid := true.
|
|
62 |
self inspectInstvar:0 of:inspectedObject
|
|
63 |
].
|
|
64 |
(cmd == $1) ifTrue:[
|
|
65 |
valid := true.
|
|
66 |
self inspectInstvar:1 of:inspectedObject
|
|
67 |
].
|
|
68 |
(cmd == $2) ifTrue:[
|
|
69 |
valid := true.
|
|
70 |
self inspectInstvar:2 of:inspectedObject
|
|
71 |
].
|
|
72 |
(cmd == $3) ifTrue:[
|
|
73 |
valid := true.
|
|
74 |
self inspectInstvar:3 of:inspectedObject
|
|
75 |
].
|
|
76 |
(cmd == $i) ifTrue:[
|
|
77 |
valid := true.
|
|
78 |
self printInstVarsOf:inspectedObject
|
|
79 |
].
|
|
80 |
(cmd == $p) ifTrue:[
|
|
81 |
valid := true.
|
|
82 |
inspectedObject printNewline
|
|
83 |
].
|
|
84 |
(cmd == $q) ifTrue:[valid := true. done := true ].
|
|
85 |
valid ifFalse: [
|
74
|
86 |
'valid commands:
|
|
87 |
(i)nstvars
|
|
88 |
(p)rint
|
|
89 |
(1-9) inspect instvar
|
|
90 |
(q)uit' errorPrintNewline
|
1
|
91 |
]
|
|
92 |
].
|
|
93 |
^ cmd
|
|
94 |
!
|
|
95 |
|
|
96 |
getCommand
|
|
97 |
|cmd c|
|
|
98 |
'inspector> ' print.
|
|
99 |
cmd := Character fromUser.
|
|
100 |
c := cmd.
|
|
101 |
[ c isEndOfLineCharacter ] whileFalse: [
|
|
102 |
c := Character fromUser
|
|
103 |
].
|
|
104 |
^ cmd
|
|
105 |
!
|
|
106 |
|
|
107 |
printInstVarsOf:anObject
|
|
108 |
|n|
|
|
109 |
n := anObject class instSize.
|
|
110 |
'number of instvars: ' print. n printNewline.
|
|
111 |
1 to:n do:[:i |
|
|
112 |
' ' print. i print. ': ' print.
|
|
113 |
(anObject instVarAt:i) printNewline
|
|
114 |
]
|
|
115 |
!
|
|
116 |
|
|
117 |
inspectInstvar:which of:anObject
|
|
118 |
which > (anObject class instSize) ifTrue:[
|
|
119 |
'invalid instvar' printNewline
|
|
120 |
] ifFalse: [
|
|
121 |
(anObject instVarAt:which) inspect
|
|
122 |
]
|
|
123 |
! !
|