ContextInspectorView.st
changeset 45 950b84ba89e6
parent 37 50f59bad66b1
child 49 6fe62433cfa3
equal deleted inserted replaced
44:5f101bc4a0ca 45:950b84ba89e6
     1 "{ Package: 'Programming Tools' }"
     1 "{ Package: 'Programming Tools' }"
     2 
     2 
     3 "
     3 "
     4  COPYRIGHT (c) 1993 by Claus Gittinger
     4  COPYRIGHT (c) 1993 by Claus Gittinger
     5               All Rights Reserved
     5 	      All Rights Reserved
     6 
     6 
     7  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
     8  only in accordance with the terms of that license and with the
     8  only in accordance with the terms of that license and with the
     9  inclusion of the above copyright notice.   This software may not
     9  inclusion of the above copyright notice.   This software may not
    10  be provided or otherwise made available to, or used by, any
    10  be provided or otherwise made available to, or used by, any
    11  other person.  No title to or ownership of the software is
    11  other person.  No title to or ownership of the software is
    12  hereby transferred.
    12  hereby transferred.
    13 "
    13 "
    14 
    14 
    15 InspectorView subclass:#ContextInspectorView
    15 InspectorView subclass:#ContextInspectorView
    16          instanceVariableNames:'inspectedContext'
    16 	 instanceVariableNames:'inspectedContext'
    17          classVariableNames:''
    17 	 classVariableNames:''
    18          poolDictionaries:''
    18 	 poolDictionaries:''
    19          category:'Interface-Inspector'
    19 	 category:'Interface-Inspector'
    20 !
    20 !
    21 
    21 
    22 ContextInspectorView comment:'
    22 ContextInspectorView comment:'
    23 COPYRIGHT (c) 1993 by Claus Gittinger
    23 COPYRIGHT (c) 1993 by Claus Gittinger
    24               All Rights Reserved
    24 	      All Rights Reserved
    25 
    25 
    26 $Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.2 1994-08-22 18:07:00 claus Exp $
    26 $Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.3 1994-10-10 03:15:23 claus Exp $
    27 '!
    27 '!
    28 
    28 
    29 !ContextInspectorView class methodsFor:'documentation'!
    29 !ContextInspectorView class methodsFor:'documentation'!
    30 
    30 
    31 copyright
    31 copyright
    32 "
    32 "
    33  COPYRIGHT (c) 1993 by Claus Gittinger
    33  COPYRIGHT (c) 1993 by Claus Gittinger
    34               All Rights Reserved
    34 	      All Rights Reserved
    35 
    35 
    36  This software is furnished under a license and may be used
    36  This software is furnished under a license and may be used
    37  only in accordance with the terms of that license and with the
    37  only in accordance with the terms of that license and with the
    38  inclusion of the above copyright notice.   This software may not
    38  inclusion of the above copyright notice.   This software may not
    39  be provided or otherwise made available to, or used by, any
    39  be provided or otherwise made available to, or used by, any
    42 "
    42 "
    43 !
    43 !
    44 
    44 
    45 version
    45 version
    46 "
    46 "
    47 $Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.2 1994-08-22 18:07:00 claus Exp $
    47 $Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.3 1994-10-10 03:15:23 claus Exp $
    48 "
    48 "
    49 !
    49 !
    50 
    50 
    51 documentation
    51 documentation
    52 "
    52 "
    64     realized ifFalse:[^ self].
    64     realized ifFalse:[^ self].
    65 
    65 
    66     inspectedObject := nil.
    66     inspectedObject := nil.
    67     inspectedContext := con.
    67     inspectedContext := con.
    68     con isNil ifTrue:[
    68     con isNil ifTrue:[
    69         inspectedValues := nil.
    69 	inspectedValues := nil.
    70         listView contents:nil.
    70 	listView contents:nil.
    71         ^ self
    71 	^ self
    72     ].
    72     ].
    73 
    73 
    74     homeContext := con methodHome.
    74     homeContext := con methodHome.
       
    75 homeContext isNil ifTrue:[
       
    76     "its a cheap blocks context"
       
    77     rec := con receiver.
       
    78     sel := con selector.
       
    79     names := OrderedCollection new.
       
    80 ] ifFalse:[
    75     rec := homeContext receiver.
    81     rec := homeContext receiver.
    76     sel := homeContext selector.
    82     sel := homeContext selector.
    77 
    83 
    78     implementorClass := homeContext searchClass whichClassImplements:sel.
    84     implementorClass := homeContext searchClass whichClassImplements:sel.
    79     implementorClass notNil ifTrue:[
    85     implementorClass notNil ifTrue:[
    80         method := implementorClass compiledMethodAt:sel.
    86 	method := implementorClass compiledMethodAt:sel.
    81         names := method methodArgAndVarNames
    87 	names := method methodArgAndVarNames
    82     ].
    88     ].
    83 
    89 ].
    84     "create dummy names (if there is no source available)"
    90     "create dummy names (if there is no source available)"
    85     names isNil ifTrue:[
    91     names isNil ifTrue:[
    86         names := OrderedCollection new.
    92 	names := OrderedCollection new.
    87         1 to:homeContext nargs do:[:index |
    93 	1 to:homeContext numArgs do:[:index |
    88             names add:('mArg' , index printString)
    94 	    names add:('mArg' , index printString)
    89         ].
    95 	].
    90         1 to:homeContext nvars do:[:index |
    96 	1 to:homeContext nvars do:[:index |
    91             names add:('mVar' , index printString)
    97 	    names add:('mVar' , index printString)
    92         ].
    98 	].
    93     ].
    99     ].
    94 
   100 
    95     aList := OrderedCollection new.
   101     aList := OrderedCollection new.
    96 
   102 
    97     "
   103     "
    98      stupid: should find the block via the contexts
   104      stupid: should find the block via the contexts
    99      method-home and put real names in here
   105      method-home and put real names in here
   100     "
   106     "
   101     con isBlockContext ifTrue:[
   107     con isBlockContext ifTrue:[
   102         argNames := (1 to:(con nargs)) collect:[:i | 'arg' , i printString].
   108 	argNames := (1 to:(con numArgs)) collect:[:i | 'arg' , i printString].
   103         aList addAll:argNames.
   109 	aList addAll:argNames.
   104         varNames := (1 to:(con nvars)) collect:[:i | 'var' , i printString].
   110 	varNames := (1 to:(con nvars)) collect:[:i | 'var' , i printString].
   105         aList addAll:varNames.
   111 	aList addAll:varNames.
   106         aList addAll:names.
   112 	aList addAll:names.
   107         inspectedValues := (Array withAll:(con argsAndVars)) , homeContext argsAndVars
   113 	homeContext isNil ifTrue:[
       
   114 	    inspectedValues := Array withAll:(con argsAndVars)
       
   115 	] ifFalse:[
       
   116 	    inspectedValues := (Array withAll:(con argsAndVars)) , homeContext argsAndVars
       
   117 	]
   108     ] ifFalse:[
   118     ] ifFalse:[
   109         aList addAll:names.
   119 	aList addAll:names.
   110         inspectedValues := homeContext argsAndVars
   120 	inspectedValues := homeContext argsAndVars
   111     ].
   121     ].
   112     listView contents:aList.
   122     listView contents:aList.
   113 
   123 
   114     workspace contents:nil.
   124     workspace contents:nil.
   115     self setDoitActionIn:workspace for:con.
   125     self setDoitActionIn:workspace for:con.
   124 
   134 
   125 !ContextInspectorView methodsFor:'private'!
   135 !ContextInspectorView methodsFor:'private'!
   126 
   136 
   127 setDoitActionIn:aWorkspace for:aContext
   137 setDoitActionIn:aWorkspace for:aContext
   128     aWorkspace doItAction:[:theCode |
   138     aWorkspace doItAction:[:theCode |
   129         Compiler evaluate:theCode
   139 	Compiler evaluate:theCode
   130                        in:aContext
   140 		       in:aContext
   131                  receiver:nil
   141 		 receiver:nil
   132                 notifying:aWorkspace
   142 		notifying:aWorkspace
   133                    logged:true 
   143 		   logged:true 
   134                    ifFail:nil
   144 		   ifFail:nil
   135     ]
   145     ]
   136 ! !
   146 ! !
   137 
   147 
   138 !ContextInspectorView methodsFor:'user actions'!
   148 !ContextInspectorView methodsFor:'user actions'!
   139 
   149 
   140 doAccept:theText
   150 doAccept:theText
   141     |value|
   151     |value|
   142 
   152 
   143     selectedLine notNil ifTrue:[
   153     selectedLine notNil ifTrue:[
   144         value := Compiler evaluate:theText
   154 	value := Compiler evaluate:theText
   145                           receiver:inspectedObject 
   155 			  receiver:inspectedObject 
   146                          notifying:workspace.
   156 			 notifying:workspace.
   147 
   157 
   148         "yes, you can do that with a context"
   158 	"yes, you can do that with a context"
   149         inspectedContext at:selectedLine put:value.
   159 	inspectedContext at:selectedLine put:value.
   150     ].
   160     ].
   151 ! !
   161 ! !