ContextInspectorView.st
branchjv
changeset 13173 e9da2324940d
parent 12807 ba8c5416aa28
parent 12935 2149c6971ded
child 13491 b3afe831ff0a
equal deleted inserted replaced
13172:06656434532b 13173:e9da2324940d
    55 
    55 
    56 inspect:aContext
    56 inspect:aContext
    57     "set the context to be inspected"
    57     "set the context to be inspected"
    58 
    58 
    59     |methodHomeContext method homeNames rec sel 
    59     |methodHomeContext method homeNames rec sel 
    60      m argsOnly blockNode 
    60      m blockNode 
    61      numVarsInSource numVarsInContext isDoIt
    61      numVarsInSource numVarsInContext isDoIt
    62      numArgs numVars n tempNames realTempNames 
    62      numArgs numVars n tempNames realTempNames 
    63      oldSelection oldSelectedName hCon keepList newList|
    63      oldSelection oldSelectedName hCon keepList newList|
    64 
    64 
    65     oldSelection := selectionIndex.
    65     oldSelection := selectionIndex.
   109 
   109 
   110             "/ #doIt needs special handling below
   110             "/ #doIt needs special handling below
   111             isDoIt := (sel == #doIt) or:[sel == #doIt:].
   111             isDoIt := (sel == #doIt) or:[sel == #doIt:].
   112             method := methodHomeContext method.
   112             method := methodHomeContext method.
   113 
   113 
   114 "/        implementorClass := methodHomeContext methodClass.
       
   115 "/        implementorClass notNil ifTrue:[
       
   116 "/            method := implementorClass compiledMethodAt:sel.
       
   117 "/        ] ifFalse:[
       
   118 "/            "/ mhm - an unbound method;
       
   119 "/            "/ see if it was invoked by a direct call
       
   120 "/            "/ consider this a kludge
       
   121 "/
       
   122 "/            methodHomeContext sender notNil ifTrue:[
       
   123 "/                (methodHomeContext sender selector startsWith:'valueWithReceiver:') ifTrue:[
       
   124 "/                    method := methodHomeContext sender receiver
       
   125 "/                ]
       
   126 "/            ]
       
   127 "/        ].
       
   128 
       
   129             (method notNil and:[method isWrapped]) ifTrue:[
   114             (method notNil and:[method isWrapped]) ifTrue:[
   130             "
   115                 "/ in a wrapped context, locals are something different
   131              in a wrapped context, locals are something different
   116                 argsOnly := true.
   132             "
       
   133 "/            argsOnly := true.
       
   134 
   117 
   135                 m := method originalMethod.
   118                 m := method originalMethod.
   136                 m notNil ifTrue:[
   119                 m notNil ifTrue:[
   137                     method := m.
   120                     method := m.
   138                 ] ifFalse:[
   121                 ] ifFalse:[
   139                     argsOnly := true.
   122                     argsOnly := true.
   140                 ].
   123                 ].
   141             ].
   124             ].
   142 
   125 
   143             method notNil ifTrue:[
   126             method notNil ifTrue:[
   144                 "/ method source notNil ifTrue:[
   127                 argsOnly ifFalse:[
   145 
   128                     homeNames := method methodArgAndVarNames.
   146                     argsOnly ifTrue:[
   129 
   147                         homeNames := method methodArgNames
   130                     "/ did it already allocate its locals ?
   148                     ] ifFalse:[
   131                     (homeNames size > (methodHomeContext numArgs + methodHomeContext numVars)) ifTrue:[
   149                         homeNames := method methodArgAndVarNames.
   132                         argsOnly := true.
   150 
       
   151                         "/ did it already allocate its locals ?
       
   152                         homeNames size > (methodHomeContext numArgs + methodHomeContext numVars)
       
   153                         ifTrue:[
       
   154                             homeNames := method methodArgNames.
       
   155                             argsOnly := true.
       
   156                         ].
       
   157                     ].
   133                     ].
   158 
   134                 ].
   159                     "/ there is one case, where the above is by purpose:
   135                 argsOnly ifTrue:[
   160                     "/ the #doIt - method, which has been given an invalid
   136                     homeNames := method methodArgNames
   161                     "/ source.
   137                 ].
   162                     "/ care for this here.
   138 
   163 
   139                 "/ there is one case, where the above is by purpose:
   164                     isDoIt ifTrue:[
   140                 "/ the #doIt - method, which has been given an invalid
   165                         homeNames := #().
   141                 "/ source.
   166                     ] ifFalse:[
   142                 "/ care for this here.
   167 
   143 
   168                         "/ check
   144                 isDoIt ifTrue:[
   169 
   145                     homeNames := #().
   170                         numVarsInContext := methodHomeContext argsAndVars size.
   146                 ] ifFalse:[
   171                         numVarsInSource := homeNames size.
   147                     "/ check
   172 
   148                     numVarsInContext := methodHomeContext argsAndVars size.
   173                         numVarsInSource > 0 ifTrue:[
   149                     numVarsInSource := homeNames size.
   174                             numVarsInContext < numVarsInSource ifTrue:[
   150 
   175 
   151                     numVarsInSource > 0 ifTrue:[
   176                                 "/ the methods source does not correctly reflect
   152                         numVarsInContext < numVarsInSource ifTrue:[
   177                                 "/ the number of args&vars in the context.
   153                             "/ the methods source does not correctly reflect
   178                                 "/ either outDated, or somehow strange.
   154                             "/ the number of args&vars in the context.
   179                                 "/ (happens with wrapped methods, which are not
   155                             "/ either outDated, or somehow strange.
   180                                 "/  what they look)
   156                             "/ (happens with wrapped methods, which are not
   181 
   157                             "/  what they look)
   182                                 numVarsInSource > numVarsInContext ifTrue:[
   158 
   183                                     homeNames := homeNames copyTo:numVarsInContext.
   159                             numVarsInSource > numVarsInContext ifTrue:[
       
   160                                 homeNames := homeNames copyTo:numVarsInContext.
       
   161                             ] ifFalse:[
       
   162                                 numVarsInContext >= methodHomeContext numArgs ifTrue:[
       
   163                                     homeNames := homeNames copyTo:methodHomeContext numArgs
   184                                 ] ifFalse:[
   164                                 ] ifFalse:[
   185                                     numVarsInContext >= methodHomeContext numArgs ifTrue:[
   165                                     homeNames := nil
   186                                         homeNames := homeNames copyTo:methodHomeContext numArgs
   166                                 ]    
   187                                     ] ifFalse:[
       
   188                                         homeNames := nil
       
   189                                     ]    
       
   190                                 ]
       
   191                             ]
   167                             ]
   192                         ]
   168                         ]
   193                     ]
   169                     ]
   194                 "/ ]
   170                 ]
   195             ].
   171             ].
   196 
   172 
   197             "
   173             "
   198              create dummy names for method vars (if there is no source available)
   174              create dummy names for method vars (if there is no source available)
   199             "
   175             "
   219                     homeNames add:('mTmp' , index printString)
   195                     homeNames add:('mTmp' , index printString)
   220                 ]
   196                 ]
   221             ].
   197             ].
   222 
   198 
   223             n := homeNames size.
   199             n := homeNames size.
   224             n < (methodHomeContext numVars + methodHomeContext numArgs) ifTrue:[
   200             n < ((argsOnly ifTrue:[0] ifFalse:[ methodHomeContext numVars]) + methodHomeContext numArgs) ifTrue:[
   225                 "/ its a context which includes locals from
   201                 "/ its a context which includes locals from
   226                 "/ inlined sub-blocks.
   202                 "/ inlined sub-blocks.
   227                 "/ First, generate synthetic varNames ...
   203                 "/ First, generate synthetic varNames ...
   228 
   204 
   229                 homeNames := homeNames asOrderedCollection.
   205                 homeNames := homeNames asOrderedCollection.
   403                    ('-')
   379                    ('-')
   404                    ('Browse'                #browse)
   380                    ('Browse'                #browse)
   405               ).
   381               ).
   406 
   382 
   407     sel := self selection.
   383     sel := self selection.
       
   384 
       
   385     (sel isSymbol) ifTrue:[
       
   386         items := items , #(
       
   387                        ('Browse Implementors'           #browseImplementorsOfSymbolValue)
       
   388               ).
       
   389     ].
       
   390 
   408     Error 
   391     Error 
   409         handle:[:ex| ]
   392         handle:[:ex| ]
   410         do:[
   393         do:[
   411             (sel isBlock or:[sel isContext]) ifTrue:[
   394             (sel isBlock or:[sel isContext]) ifTrue:[
   412                 items := items , #(
   395                 items := items , #(
   443     m := PopUpMenu
   426     m := PopUpMenu
   444           itemList:items
   427           itemList:items
   445           resources:resources.
   428           resources:resources.
   446 
   429 
   447     selectionIndex isNil ifTrue:[
   430     selectionIndex isNil ifTrue:[
   448         m disableAll:#(doInspect doBasicInspect browse browseHome)
   431         m disableAll:#(doInspect doBasicInspect browse browseHome browseImplementorsOfSymbolValue)
   449     ] ifFalse:[
   432     ] ifFalse:[
   450         sel isBlock ifFalse:[
   433         sel isBlock ifFalse:[
   451             m disable:#browseHome
   434             m disable:#browseHome
   452         ].
   435         ].
   453         sel class hasImmediateInstances ifTrue:[
   436         sel class hasImmediateInstances ifTrue:[
   551 
   534 
   552     |methodHomeContext hCon theContext values|
   535     |methodHomeContext hCon theContext values|
   553 
   536 
   554     inspectedContext isNil ifTrue:[^ nil].
   537     inspectedContext isNil ifTrue:[^ nil].
   555 
   538 
   556     argsOnly := false.
   539     "/ argsOnly := false.
   557     theContext := inspectedContext.
   540     theContext := inspectedContext.
   558     methodHomeContext := theContext methodHome.
   541     methodHomeContext := theContext methodHome.
   559 
   542 
   560     theContext isBlockContext ifTrue:[
   543     theContext isBlockContext ifTrue:[
   561         values := Array withAll:(theContext argsAndVars).
   544         values := Array withAll:(theContext argsAndVars).
   668 ! !
   651 ! !
   669 
   652 
   670 !ContextInspectorView class methodsFor:'documentation'!
   653 !ContextInspectorView class methodsFor:'documentation'!
   671 
   654 
   672 version
   655 version
   673     ^ '$Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.81 2013-05-28 18:23:50 cg Exp $'
   656     ^ '$Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.85 2013-06-20 11:24:29 cg Exp $'
   674 !
   657 !
   675 
   658 
   676 version_CVS
   659 version_CVS
   677     ^ '$Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.81 2013-05-28 18:23:50 cg Exp $'
   660     ^ '$Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.85 2013-06-20 11:24:29 cg Exp $'
   678 !
   661 !
   679 
   662 
   680 version_HG
   663 version_HG
   681 
   664 
   682     ^ '$Changeset: <not expanded> $'
   665     ^ '$Changeset: <not expanded> $'