ContextInspectorView.st
changeset 296 b480a51cfb5f
parent 200 01ce3d3636d5
child 297 3d34ce6e2b22
equal deleted inserted replaced
295:92bcaa9996ae 296:b480a51cfb5f
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 InspectorView subclass:#ContextInspectorView
    13 InspectorView subclass:#ContextInspectorView
    14 	 instanceVariableNames:'inspectedContext values names showingTemporaries'
    14 	instanceVariableNames:'inspectedContext names showingTemporaries argsOnly'
    15 	 classVariableNames:''
    15 	classVariableNames:''
    16 	 poolDictionaries:''
    16 	poolDictionaries:''
    17 	 category:'Interface-Inspector'
    17 	category:'Interface-Inspector'
    18 !
    18 !
    19 
    19 
    20 !ContextInspectorView class methodsFor:'documentation'!
    20 !ContextInspectorView class methodsFor:'documentation'!
    21 
    21 
    22 copyright
    22 copyright
    45     "set the context to be inspected"
    45     "set the context to be inspected"
    46 
    46 
    47     |homeContext method homeNames rec sel implementorClass 
    47     |homeContext method homeNames rec sel implementorClass 
    48      argNames varNames tmpNames m argsOnly|
    48      argNames varNames tmpNames m argsOnly|
    49 
    49 
    50     hasMore := false.
    50     (con == inspectedContext) ifTrue:[
       
    51         listView selection notNil ifTrue:[
       
    52             self showSelection:(listView selection).
       
    53         ].
       
    54         ^ self
       
    55     ].
       
    56 
       
    57     hasMore := argsOnly := false.
    51     inspectedObject := nil.
    58     inspectedObject := nil.
    52     inspectedContext := con.
    59     inspectedContext := con.
    53     argsOnly := false.
       
    54 
    60 
    55     con isNil ifTrue:[
    61     con isNil ifTrue:[
    56 	names := nil.
    62         names := nil.
    57 	values := nil.
    63         listView list:nil. 
    58 	listView list:nil. 
    64         ^ self
    59 	^ self
       
    60     ].
    65     ].
    61 
    66 
    62 "/    realized ifFalse:[^ self].
    67 "/    realized ifFalse:[^ self].
    63 
    68 
    64     homeContext := con methodHome.
    69     homeContext := con methodHome.
    65 
    70 
    66     homeContext isNil ifTrue:[
    71     homeContext isNil ifTrue:[
    67 	"its a cheap blocks context"
    72         "its a cheap blocks context"
    68 	rec := con receiver.
    73         rec := con receiver.
    69 	sel := con selector.
    74         sel := con selector.
    70 	homeNames := OrderedCollection new.
    75         homeNames := OrderedCollection new.
    71     ] ifFalse:[
    76     ] ifFalse:[
    72 	rec := homeContext receiver.
    77         rec := homeContext receiver.
    73 	sel := homeContext selector.
    78         sel := homeContext selector.
    74 
    79 
    75 	implementorClass := homeContext methodClass.
    80         implementorClass := homeContext methodClass.
    76 	implementorClass notNil ifTrue:[
    81         implementorClass notNil ifTrue:[
    77 	    method := implementorClass compiledMethodAt:sel.
    82             method := implementorClass compiledMethodAt:sel.
    78 	    method notNil ifTrue:[
    83             method notNil ifTrue:[
    79 		method isWrapped ifTrue:[
    84                 method isWrapped ifTrue:[
    80 		    "
    85                     "
    81 		     in a wrapped context, locals are something different
    86                      in a wrapped context, locals are something different
    82 		    "
    87                     "
    83 "/                    argsOnly := true.
    88 "/                    argsOnly := true.
    84 		    m := method originalMethod.
    89                     m := method originalMethod.
    85 		    m notNil ifTrue:[
    90                     m notNil ifTrue:[
    86 			method := m.
    91                         method := m.
    87 		    ] ifFalse:[
    92                     ] ifFalse:[
    88 			argsOnly := true.
    93                         argsOnly := true.
    89 		    ].
    94                     ].
    90 		].
    95                 ].
    91 	    ].
    96             ].
    92 	    method notNil ifTrue:[
    97             method notNil ifTrue:[
    93 		method source notNil ifTrue:[
    98                 method source notNil ifTrue:[
    94 		    argsOnly ifTrue:[
    99                     argsOnly ifTrue:[
    95 			homeNames := method methodArgNames
   100                         homeNames := method methodArgNames
    96 		    ] ifFalse:[
   101                     ] ifFalse:[
    97 			homeNames := method methodArgAndVarNames.
   102                         homeNames := method methodArgAndVarNames.
    98 		    ]
   103                     ]
    99 		]
   104                 ]
   100 	    ].
   105             ].
   101 	].
   106         ].
   102 
   107 
   103 	"
   108         "
   104 	 create dummy names for method vars (if there is no source available)
   109          create dummy names for method vars (if there is no source available)
   105 	"
   110         "
   106 	homeNames isNil ifTrue:[
   111         homeNames isNil ifTrue:[
   107 	    homeNames := OrderedCollection new.
   112             homeNames := OrderedCollection new.
   108 	    1 to:homeContext numArgs do:[:index |
   113             1 to:homeContext numArgs do:[:index |
   109 		homeNames add:('mArg' , index printString)
   114                 homeNames add:('mArg' , index printString)
   110 	    ].
   115             ].
   111 	    argsOnly ifFalse:[
   116             argsOnly ifFalse:[
   112 		1 to:homeContext nvars do:[:index |
   117                 1 to:homeContext nvars do:[:index |
   113 		    homeNames add:('mVar' , index printString)
   118                     homeNames add:('mVar' , index printString)
   114 		].
   119                 ].
   115 		showingTemporaries ifTrue:[
   120                 showingTemporaries ifTrue:[
   116 		    1 to:homeContext ntemp do:[:index |
   121                     1 to:homeContext ntemp do:[:index |
   117 			homeNames add:('mTmp' , index printString)
   122                         homeNames add:('mTmp' , index printString)
   118 		    ]
   123                     ]
   119 		]
   124                 ]
   120 	    ]
   125             ]
   121 	].
   126         ].
   122     ].
   127     ].
   123 
   128 
   124     "
   129     "
   125      stupid: should find the block via the contexts
   130      stupid: should find the block via the contexts
   126      method-home and put real names in here
   131      method-home and put real names in here
   127     "
   132     "
   128     con isBlockContext ifTrue:[
   133     con isBlockContext ifTrue:[
   129 	names := OrderedCollection new.
   134         names := OrderedCollection new.
   130 
   135 
   131 	argNames := (1 to:(con numArgs)) collect:[:i | 'arg' , i printString].
   136         argNames := (1 to:(con numArgs)) collect:[:i | 'arg' , i printString].
   132 	names addAll:argNames.
   137         names addAll:argNames.
   133 	varNames := (1 to:(con nvars)) collect:[:i | 'var' , i printString].
   138         varNames := (1 to:(con nvars)) collect:[:i | 'var' , i printString].
   134 	names addAll:varNames.
   139         names addAll:varNames.
   135 
   140 
   136 	showingTemporaries ifTrue:[
   141         showingTemporaries ifTrue:[
   137 	    tmpNames := (1 to:(con ntemp)) collect:[:i | 'tmp' , i printString].
   142             tmpNames := (1 to:(con ntemp)) collect:[:i | 'tmp' , i printString].
   138 	    names addAll:tmpNames.
   143             names addAll:tmpNames.
   139 	].
   144         ].
   140 
   145 
   141 	names addAll:homeNames.
   146         names addAll:homeNames.
   142 
       
   143 	values := Array withAll:(con argsAndVars).
       
   144 	(showingTemporaries and:[con ntemp ~~ 0]) ifTrue:[
       
   145 	    values := values , con temporaries
       
   146 	].
       
   147 	homeContext notNil ifTrue:[
       
   148 	    values := values , homeContext args.
       
   149 	    argsOnly ifFalse:[
       
   150 		values := values , homeContext vars.
       
   151 		(showingTemporaries and:[homeContext ntemp ~~ 0])ifTrue:[
       
   152 		    values := values , homeContext temporaries
       
   153 		]
       
   154 	    ].
       
   155 	].
       
   156 
       
   157     ] ifFalse:[
   147     ] ifFalse:[
   158 	names := homeNames.
   148         names := homeNames.
   159 	argsOnly ifTrue:[
       
   160 	    values := homeContext args
       
   161 	] ifFalse:[
       
   162 	    values := homeContext argsAndVars
       
   163 	]
       
   164     ].
   149     ].
   165 
   150 
   166     listView list:names. 
   151     listView list:names. 
   167 
   152 
   168     workspace contents:nil.
   153     workspace contents:nil.
   169     self setDoitActionIn:workspace for:con.
   154     self setDoitActionIn:workspace for:con.
       
   155 
       
   156     "Modified: 14.12.1995 / 19:34:35 / cg"
   170 !
   157 !
   171 
   158 
   172 release
   159 release
   173     "release inspected object"
   160     "release inspected object"
   174 
   161 
       
   162 'released' printNL.
   175     inspectedContext := nil.
   163     inspectedContext := nil.
   176     names := values := nil.
   164     names := nil.
   177     super release
   165     super release
       
   166 
       
   167     "Modified: 14.12.1995 / 19:34:39 / cg"
   178 ! !
   168 ! !
   179 
   169 
   180 !ContextInspectorView methodsFor:'initialization'!
   170 !ContextInspectorView methodsFor:'initialization'!
   181 
   171 
   182 fieldMenu
   172 fieldMenu
   225 
   215 
   226 fieldList
   216 fieldList
   227     ^ names
   217     ^ names
   228 !
   218 !
   229 
   219 
       
   220 hasSelfEntry
       
   221     ^ false
       
   222 
       
   223     "Created: 14.12.1995 / 19:29:47 / cg"
       
   224 !
       
   225 
   230 setDoitActionIn:aWorkspace for:aContext
   226 setDoitActionIn:aWorkspace for:aContext
   231     aWorkspace doItAction:[:theCode |
   227     aWorkspace doItAction:[:theCode |
   232 	Compiler evaluate:theCode
   228 	Compiler evaluate:theCode
   233 		       in:aContext
   229 		       in:aContext
   234 		 receiver:nil
   230 		 receiver:nil
   239 !
   235 !
   240 
   236 
   241 valueAtLine:lineNr
   237 valueAtLine:lineNr
   242     "helper - return the value of the selected entry"
   238     "helper - return the value of the selected entry"
   243 
   239 
       
   240     |homeContext con values|
       
   241 
       
   242     inspectedContext isNil ifTrue:[^ nil].
       
   243 
       
   244     argsOnly := false.
       
   245     con := inspectedContext.
       
   246     homeContext := con methodHome.
       
   247 
       
   248     con isBlockContext ifTrue:[
       
   249         values := Array withAll:(con argsAndVars).
       
   250         (showingTemporaries and:[con ntemp ~~ 0]) ifTrue:[
       
   251             values := values , con temporaries
       
   252         ].
       
   253         homeContext notNil ifTrue:[
       
   254             values := values , homeContext args.
       
   255             argsOnly ifFalse:[
       
   256                 values := values , homeContext vars.
       
   257                 (showingTemporaries and:[homeContext ntemp ~~ 0])ifTrue:[
       
   258                     values := values , homeContext temporaries
       
   259                 ]
       
   260             ].
       
   261         ].
       
   262     ] ifFalse:[
       
   263         argsOnly ifTrue:[
       
   264             values := homeContext args
       
   265         ] ifFalse:[
       
   266             values := homeContext argsAndVars
       
   267         ]
       
   268     ].
       
   269 
       
   270 values printNL.
   244     ^ values at:lineNr.
   271     ^ values at:lineNr.
   245 
   272 
   246 
   273     "Modified: 14.12.1995 / 19:28:10 / cg"
   247 ! !
   274 ! !
   248 
   275 
   249 !ContextInspectorView methodsFor:'user actions'!
   276 !ContextInspectorView methodsFor:'user actions'!
   250 
   277 
   251 doAccept:theText
   278 doAccept:theText
   260 	inspectedContext at:selectedLine put:value.
   287 	inspectedContext at:selectedLine put:value.
   261     ].
   288     ].
   262 !
   289 !
   263 
   290 
   264 hideTemporaries
   291 hideTemporaries
       
   292     "do not show contexts temporaries"
       
   293 
   265     showingTemporaries := false.
   294     showingTemporaries := false.
   266     self inspect:inspectedContext
   295     self inspect:inspectedContext
   267 !
   296 
   268 
   297     "Modified: 14.12.1995 / 19:24:44 / cg"
   269 showSelection:lineNr
       
   270     "user clicked on an entry - show value in workspace"
       
   271 
       
   272     self showValue:(values at:lineNr).
       
   273     selectedLine := lineNr
       
   274 !
   298 !
   275 
   299 
   276 showTemporaries
   300 showTemporaries
       
   301     "show contexts temporaries"
       
   302 
   277     showingTemporaries := true.
   303     showingTemporaries := true.
   278     self inspect:inspectedContext
   304     self inspect:inspectedContext
       
   305 
       
   306     "Modified: 14.12.1995 / 19:24:49 / cg"
   279 ! !
   307 ! !
   280 
   308 
   281 !ContextInspectorView class methodsFor:'documentation'!
   309 !ContextInspectorView class methodsFor:'documentation'!
   282 
   310 
   283 version
   311 version
   284     ^ '$Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.18 1995-11-23 17:44:21 cg Exp $'
   312     ^ '$Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.19 1995-12-14 20:22:39 cg Exp $'
   285 ! !
   313 ! !