334 orReceiverClass:receiverClassOrNil orProcess:processOrNil |
336 orReceiverClass:receiverClassOrNil orProcess:processOrNil |
335 orIfCalledFromMethod:nil |
337 orIfCalledFromMethod:nil |
336 ! |
338 ! |
337 |
339 |
338 ignoreHaltOrBreakpoint:type method:methodOrNil line:lineNrOfHaltOrNil parameter:parameterOrNil |
340 ignoreHaltOrBreakpoint:type method:methodOrNil line:lineNrOfHaltOrNil parameter:parameterOrNil |
339 forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey |
341 forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey |
340 orReceiverClass:receiverClassOrNil orProcess:processOrNil |
342 orReceiverClass:receiverClassOrNil orProcess:processOrNil |
341 orIfCalledFromMethod:ifCalledFromMethodOrNil |
343 orIfCalledFromMethod:ifCalledFromMethodOrNil |
342 |
344 |
343 "remember to ignore a breakpoint with a parameter (i.e. breakpoint:#cg) for some number of invocations |
345 "remember to ignore a breakpoint with a parameter (i.e. breakpoint:#cg) for some number of invocations |
344 or until some time has elapsed. |
346 or until some time has elapsed. |
345 With nil count and time arguments, such an ignored breakpoint is reactivated" |
347 With nil count and time arguments, such an ignored breakpoint is reactivated" |
346 |
348 |
347 |oldEntry ign| |
349 |oldEntry ign| |
348 |
350 |
349 IgnoredHalts notNil ifTrue:[ |
351 IgnoredHalts notNil ifTrue:[ |
350 self removeInactiveIgnores. |
352 self removeInactiveIgnores. |
351 type == #halt ifTrue:[ |
353 type == #halt ifTrue:[ |
352 oldEntry := IgnoredHalts |
354 oldEntry := IgnoredHalts |
353 detect:[:ign | ign isForMethod:methodOrNil line:lineNrOfHaltOrNil] |
355 detect:[:ign | ign isForMethod:methodOrNil line:lineNrOfHaltOrNil] |
354 ifNone:nil. |
356 ifNone:nil. |
355 ] ifFalse:[ |
357 ] ifFalse:[ |
356 oldEntry := IgnoredHalts |
358 oldEntry := IgnoredHalts |
357 detect:[:ign | ign isForBreakpointWithParameter:parameterOrNil] |
359 detect:[:ign | ign isForBreakpointWithParameter:parameterOrNil] |
358 ifNone:nil. |
360 ifNone:nil. |
359 ]. |
361 ]. |
360 oldEntry notNil ifTrue:[ |
362 oldEntry notNil ifTrue:[ |
361 (processOrNil notNil or:[receiverClassOrNil notNil]) ifTrue:[ |
363 (processOrNil notNil or:[receiverClassOrNil notNil]) ifTrue:[ |
362 receiverClassOrNil notNil ifTrue:[ |
364 receiverClassOrNil notNil ifTrue:[ |
363 oldEntry ignoreForReceiverClass:receiverClassOrNil. |
365 oldEntry ignoreForReceiverClass:receiverClassOrNil. |
364 ]. |
366 ]. |
365 processOrNil notNil ifTrue:[ |
367 processOrNil notNil ifTrue:[ |
366 oldEntry ignoreForProcess:processOrNil. |
368 oldEntry ignoreForProcess:processOrNil. |
367 ]. |
369 ]. |
368 ^ self. |
370 ^ self. |
369 ]. |
371 ]. |
370 IgnoredHalts remove:oldEntry ifAbsent:[]. |
372 IgnoredHalts remove:oldEntry ifAbsent:[]. |
371 ] |
373 ] |
372 ]. |
374 ]. |
373 |
375 |
374 (countOrNil notNil |
376 (countOrNil notNil |
375 or:[dTOrNil notNil |
377 or:[dTOrNil notNil |
376 or:[untilShiftKey == true |
378 or:[untilShiftKey == true |
377 or:[receiverClassOrNil notNil |
379 or:[receiverClassOrNil notNil |
378 or:[processOrNil notNil |
380 or:[processOrNil notNil |
379 or:[ifCalledFromMethodOrNil notNil]]]]] |
381 or:[ifCalledFromMethodOrNil notNil]]]]] |
380 ) ifTrue:[ |
382 ) ifTrue:[ |
381 IgnoredHalts isNil ifTrue:[ |
383 IgnoredHalts isNil ifTrue:[ |
382 IgnoredHalts := OrderedCollection new. |
384 IgnoredHalts := OrderedCollection new. |
383 ]. |
385 ]. |
384 type == #halt ifTrue:[ |
386 type == #halt ifTrue:[ |
385 ign := IgnoredHalt new method:methodOrNil lineNumber:lineNrOfHaltOrNil. |
387 ign := IgnoredHalt new method:methodOrNil lineNumber:lineNrOfHaltOrNil. |
386 ] ifFalse:[ |
388 ] ifFalse:[ |
387 ign := IgnoredHalt new breakpointWithParameter:parameterOrNil. |
389 ign := IgnoredHalt new breakpointWithParameter:parameterOrNil. |
388 ]. |
390 ]. |
389 |
391 |
390 (countOrNil notNil and:[countOrNil > 0]) ifTrue:[ |
392 (countOrNil notNil and:[countOrNil > 0]) ifTrue:[ |
391 ign ignoreCount:countOrNil. |
393 ign ignoreCount:countOrNil. |
392 ]. |
394 ]. |
393 (dTOrNil notNil) ifTrue:[ |
395 (dTOrNil notNil) ifTrue:[ |
394 ign ignoreEndTime:(Timestamp now + dTOrNil). |
396 ign ignoreEndTime:(Timestamp now + dTOrNil). |
395 ]. |
397 ]. |
396 untilShiftKey == true ifTrue:[ |
398 untilShiftKey == true ifTrue:[ |
397 ign ignoreUntilShiftKeyPressed:true. |
399 ign ignoreUntilShiftKeyPressed:true. |
398 ]. |
400 ]. |
399 receiverClassOrNil notNil ifTrue:[ |
401 receiverClassOrNil notNil ifTrue:[ |
400 ign ignoreForReceiverClass:receiverClassOrNil. |
402 ign ignoreForReceiverClass:receiverClassOrNil. |
401 ]. |
403 ]. |
402 processOrNil notNil ifTrue:[ |
404 processOrNil notNil ifTrue:[ |
403 ign ignoreForProcess:processOrNil. |
405 ign ignoreForProcess:processOrNil. |
404 ]. |
406 ]. |
405 ifCalledFromMethodOrNil notNil ifTrue:[ |
407 ifCalledFromMethodOrNil notNil ifTrue:[ |
406 ign ignoreIfCalledFromMethod:ifCalledFromMethodOrNil. |
408 ign ignoreIfCalledFromMethod:ifCalledFromMethodOrNil. |
407 ]. |
409 ]. |
408 IgnoredHalts add:ign. |
410 IgnoredHalts add:ign. |
409 ]. |
411 ]. |
410 Smalltalk changed:#ignoredHalts. |
412 Smalltalk changed:#ignoredHalts. |
411 |
413 |
412 "Created: / 06-03-2012 / 12:37:58 / cg" |
414 "Created: / 06-03-2012 / 12:37:58 / cg" |
413 ! |
415 ! |
8397 (aka: this method is always called with doUnwind==false, these days)" |
8502 (aka: this method is always called with doUnwind==false, these days)" |
8398 |
8503 |
8399 |con newMethod| |
8504 |con newMethod| |
8400 |
8505 |
8401 codeView withWaitCursorDo:[ |
8506 codeView withWaitCursorDo:[ |
8402 " |
8507 " |
8403 find the method-home context for this one |
8508 find the method-home context for this one |
8404 " |
8509 " |
8405 doUnwind ifTrue:[ |
8510 doUnwind ifTrue:[ |
8406 con := selectedContext. |
8511 con := selectedContext. |
8407 top := con. |
8512 top := con. |
8408 [con notNil] whileTrue:[ |
8513 [con notNil] whileTrue:[ |
8409 (con methodHome == selectedContext) ifTrue:[ |
8514 (con methodHome == selectedContext) ifTrue:[ |
8410 top := con |
8515 top := con |
8411 ]. |
8516 ]. |
8412 con := con sender |
8517 con := con sender |
8413 ]. |
8518 ]. |
8414 ]. |
8519 ]. |
8415 |
8520 |
8416 "/ |
8521 "/ |
8417 "/ provide the classes nameSpace and changefile-update answers; |
8522 "/ provide the classes nameSpace and changefile-update answers; |
8418 "/ in case we accept while in another context, to not capture these settings again |
8523 "/ in case we accept while in another context, to not capture these settings again |
8419 "/ |
8524 "/ |
8420 (Class updateChangeFileQuerySignal, |
8525 (Class updateChangeFileQuerySignal, |
8421 Class updateChangeListQuerySignal, |
8526 Class updateChangeListQuerySignal, |
8422 Class updateHistoryLineQuerySignal) answer:true |
8527 Class updateHistoryLineQuerySignal) answer:true |
8423 do:[ |
8528 do:[ |
8424 Class nameSpaceQuerySignal answer:(aClass nameSpace) |
8529 Class nameSpaceQuerySignal answer:(aClass nameSpace) |
8425 do:[ |
8530 do:[ |
8426 "/ the compiler nowadays already cares for the package... |
8531 "/ the compiler nowadays already cares for the package... |
8427 "/ no, actually, it does not in case we are in the middle of a fileIn, |
8532 "/ no, actually, it does not in case we are in the middle of a fileIn, |
8428 "/ and packageQuery is already answered by someone else. |
8533 "/ and packageQuery is already answered by someone else. |
8429 "/ Better make it unpackaged, in case the user makes changes to other |
8534 "/ Better make it unpackaged, in case the user makes changes to other |
8430 "/ classes here (actually, I often change compiler, debugger, inspector here) |
8535 "/ classes here (actually, I often change compiler, debugger, inspector here) |
8431 Class packageQuerySignal |
8536 Class packageQuerySignal |
8432 answer:nil |
8537 answer:nil |
8433 do:[ |
8538 do:[ |
8434 codeView contents:someCode. |
8539 codeView contents:someCode. |
8435 Class methodRedefinitionNotification |
8540 Class methodRedefinitionNotification |
8436 answer:#keep |
8541 answer:#keep |
8437 do:[ |
8542 do:[ |
8438 | breakpoints | |
8543 | breakpoints newMethodOrClass | |
8439 |
8544 |
8440 breakpoints := nil. |
8545 breakpoints := nil. |
8441 codeView isCodeView2 ifTrue:[ |
8546 codeView isCodeView2 ifTrue:[ |
8442 breakpoints := codeView breakpoints. |
8547 breakpoints := codeView breakpoints. |
8443 ]. |
8548 ]. |
8444 |
8549 |
8445 BreakpointQuery answer: breakpoints do:[ |
8550 BreakpointQuery answer: breakpoints do:[ |
8446 "/ Use original method's programming language instead of class's one. |
8551 "/ Use original method's programming language instead of class's one. |
8447 "/ In most cases it's the same, but it may be that the method edited |
8552 "/ In most cases it's the same, but it may be that the method edited |
8448 "/ and accepted was an extension method written in another languages |
8553 "/ and accepted was an extension method written in another languages |
8449 "/ (such as Smalltalk extension to Java class or Ruby extension to |
8554 "/ (such as Smalltalk extension to Java class or Ruby extension to |
8450 "/ Smalltalk class. |
8555 "/ Smalltalk class. |
8451 newMethod := selectedContext programmingLanguage compilerClassForInteractiveTools |
8556 newMethodOrClass := selectedContext programmingLanguage |
8452 compile:someCode |
8557 compilerClassForInteractiveTools |
8453 forClass:aClass |
8558 compile:someCode |
8454 inCategory:category |
8559 forClass:aClass |
8455 notifying:codeView. |
8560 inCategory:category |
8456 "/ Kludge for accepting Java code in a debugger. The Java compiler |
8561 notifying:codeView. |
8457 "/ does not compile single classes by always a full class and returns |
8562 "/ Kludge for accepting Java code in a debugger. The Java compiler |
8458 "/ the compiled class(es) rather than a method. However, we need to update |
8563 "/ does not compile single methods but always a full class and returns |
8459 "/ method holder of a codeView. |
8564 "/ the compiled class(es) rather than a method. |
8460 "/ |
8565 "/ However, we need to update the method holder of a codeView. |
8461 "/ So, here we check whether the retuned `newMethod` is really a method, |
8566 "/ |
8462 "/ if it's a class, try to search that class for a method with the |
8567 "/ So, here we check whether the returned `newMethod` is really a method, |
8463 "/ same selector as selector of currently selected context. If found, |
8568 "/ if it's a class, try to search that class for a method with the |
8464 "/ thet's the 'new' method we are going to show. |
8569 "/ same selector as selector of currently selected context. If found, |
8465 newMethod isBehavior ifTrue:[ |
8570 "/ that's the 'new' method we are going to show. |
8466 | selector | |
8571 newMethodOrClass isBehavior ifTrue:[ |
8467 |
8572 | selector | |
8468 selector := selectedContext selector. |
8573 |
8469 newMethod := newMethod"actually a class" compiledMethodAt: selector ifAbsent: nil. |
8574 selector := selectedContext selector. |
8470 ]. |
8575 newMethod := newMethodOrClass compiledMethodAt: selector ifAbsent: nil. |
8471 ]. |
8576 ] ifFalse:[ |
8472 ]. |
8577 newMethod := newMethodOrClass. |
8473 ]. |
8578 newMethod == #Error ifTrue:[ |
8474 ]. |
8579 "/ should now be obsolete |
8475 ]. |
8580 newMethod := nil |
8476 |
8581 ]. |
8477 methodCodeToggleSelectionHolder value:2. "/ showing current code |
8582 ]. |
8478 methodCodeToggle beVisible. |
8583 ]. |
8479 |
8584 ]. |
8480 inspecting ifFalse:[ |
8585 ]. |
8481 (newMethod notNil and:[newMethod ~~ #Error]) ifTrue:[ |
8586 ]. |
8482 codeView modified:false. |
8587 ]. |
8483 codeView isCodeView2 ifTrue:[ |
8588 |
8484 codeView methodHolder value: newMethod. |
8589 methodCodeToggleSelectionHolder value:2. "/ showing current code |
8485 ]. |
8590 methodCodeToggle beVisible. |
8486 |
8591 |
8487 doUnwind ifTrue:[ |
8592 inspecting ifFalse:[ |
8488 "/ if it worked, and doUnwind is true, |
8593 (newMethod isNil) ifTrue:[^ cancelAction value]. |
8489 "/ remove everything up to and including top |
8594 |
8490 "/ from the context chain |
8595 codeView modified:false. |
8491 |
8596 codeView isCodeView2 ifTrue:[ |
8492 selectedContext canReturn ifTrue:[ |
8597 codeView methodHolder value: newMethod. |
8493 self setContext:(top "sender"). |
8598 ]. |
8494 exitAction := #restart. |
8599 currentMethod := newMethod. |
8495 selectedContext setLineNumber:1. |
8600 |
8496 self doRestart. |
8601 doUnwind ifTrue:[ |
8497 ] ifFalse:[ |
8602 "/ if it worked, and doUnwind is true, |
8498 self setContext:(top sender). |
8603 "/ remove everything up to and including top |
8499 exitAction := #return. |
8604 "/ from the context chain |
8500 ]. |
8605 |
8501 ]. |
8606 selectedContext canReturn ifTrue:[ |
8502 ] ifFalse:[ |
8607 self setContext:(top "sender"). |
8503 ^ cancelAction value |
8608 exitAction := #restart. |
8504 ] |
8609 selectedContext setLineNumber:1. |
8505 ]. |
8610 self doRestart. |
|
8611 ] ifFalse:[ |
|
8612 self setContext:(top sender). |
|
8613 exitAction := #return. |
|
8614 ]. |
|
8615 ]. |
|
8616 ]. |
8506 ]. |
8617 ]. |
8507 |
8618 |
8508 "Created: / 17-11-2001 / 21:50:55 / cg" |
8619 "Created: / 17-11-2001 / 21:50:55 / cg" |
8509 "Modified: / 29-08-2006 / 14:22:22 / cg" |
8620 "Modified: / 29-08-2006 / 14:22:22 / cg" |
8510 "Modified: / 17-08-2014 / 11:44:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
8621 "Modified: / 17-08-2014 / 11:44:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
8511 ! |
8622 ! |
8512 |
8623 |
8513 codeAccept:someCode unwind:doUnwind category:givenCategoryOrNil onCancel:cancelAction |
8624 codeAccept:someCode unwind:doUnwind category:givenCategoryOrNil onCancel:cancelAction |
8514 "user wants some code to be recompiled" |
8625 "user wants some code to be recompiled" |
8515 |
8626 |
8516 |sel implementorClass receiverClass method category| |
8627 |sel implementorClass receiverClass method category wrapper| |
8517 |
8628 |
8518 codeView withWaitCursorDo:[ |
8629 codeView withWaitCursorDo:[ |
8519 "/ " |
8630 "/ " |
8520 "/ find the method-home context for this one |
8631 "/ find the method-home context for this one |
8521 "/ " |
8632 "/ " |
8843 |
8957 |
8844 canDefine := cannotAcceptDueToOutdatedClass := false. |
8958 canDefine := cannotAcceptDueToOutdatedClass := false. |
8845 self setCurrentMethod:nil. |
8959 self setCurrentMethod:nil. |
8846 |
8960 |
8847 contextArray notNil ifTrue:[ |
8961 contextArray notNil ifTrue:[ |
8848 lineNr <= contextArray size ifTrue:[ |
8962 lineNr <= contextArray size ifTrue:[ |
8849 con := contextArray at:lineNr. |
8963 con := contextArray at:lineNr. |
8850 callee := contextArray at:lineNr-1 ifAbsent:nil. |
8964 callee := contextArray at:lineNr-1 ifAbsent:nil. |
8851 ]. |
8965 ]. |
8852 " |
8966 " |
8853 clicking on the '** ...'-line shows more ... |
8967 clicking on the '** ...'-line shows more ... |
8854 " |
8968 " |
8855 con isNil ifTrue:[ |
8969 con isNil ifTrue:[ |
8856 line := contextView list at:lineNr. |
8970 line := contextView list at:lineNr. |
8857 (line startsWith:'**') ifTrue:[ |
8971 (line startsWith:'**') ifTrue:[ |
8858 self showMore. |
8972 self showMore. |
8859 lineNr >= contextArray size ifTrue:[ |
8973 lineNr >= contextArray size ifTrue:[ |
8860 contextView setSelection:lineNr. |
8974 contextView setSelection:lineNr. |
8861 con := contextArray at:lineNr ifAbsent:nil |
8975 con := contextArray at:lineNr ifAbsent:nil |
8862 ] |
8976 ] |
8863 ]. |
8977 ]. |
8864 con isNil ifTrue:[ |
8978 con isNil ifTrue:[ |
8865 codeView contents:nil. |
8979 codeView contents:nil. |
8866 ^ self |
8980 ^ self |
8867 ]. |
8981 ]. |
8868 ]. |
8982 ]. |
8869 |
8983 |
8870 selectedContext := con. |
8984 selectedContext := con. |
8871 m := contextView middleButtonMenu. |
8985 m := contextView middleButtonMenu. |
8872 (m notNil and:[selectedContext notNil]) ifTrue:[ |
8986 (m notNil and:[selectedContext notNil]) ifTrue:[ |
8873 m enableAll:#(browseImplementors browseSenders inspectContext) |
8987 m enableAll:#(browseImplementors browseSenders inspectContext) |
8874 ]. |
8988 ]. |
8875 |
8989 |
8876 self withExecuteCursorDo:[ |
8990 self withExecuteCursorDo:[ |
8877 codeSet := false. |
8991 codeSet := false. |
8878 |
8992 |
8879 " |
8993 " |
8880 give it to the (lower right) inspector |
8994 give it to the (lower right) inspector |
8881 " |
8995 " |
8882 Error handle:[:ex | |
8996 Error handle:[:ex | |
8883 'DebugView [warning]: error while accessing context: ' errorPrint. |
8997 'DebugView [warning]: error while accessing context: ' errorPrint. |
8884 ex description errorPrintCR. |
8998 ex description errorPrintCR. |
8885 contextInspector inspect:nil. |
8999 contextInspector inspect:nil. |
8886 contextInspector fieldListLabel:('Context'). |
9000 contextInspector fieldListLabel:('Context'). |
8887 ex suspendedContext fullPrintAllOn: Transcript. |
9001 ex suspendedContext fullPrintAllOn: Transcript. |
8888 "/ ex reject. |
9002 "/ ex reject. |
8889 ] do:[ |
9003 ] do:[ |
8890 contextInspector inspect:con. |
9004 contextInspector inspect:con. |
8891 "/ contextInspector fieldListLabel:('Context: ',con method whoString). |
9005 "/ contextInspector fieldListLabel:('Context: ',con method whoString). |
8892 contextInspector tryToSelectKeyNamed:lastSelectionInContextInspector. |
9006 contextInspector tryToSelectKeyNamed:lastSelectionInContextInspector. |
8893 ]. |
9007 ]. |
8894 |
9008 |
8895 "/ show a stack inspector sometimes |
9009 "/ show a stack inspector sometimes |
8896 |
9010 |
8897 con hasStackToShow ifTrue:[ |
9011 con hasStackToShow ifTrue:[ |
8898 self showStackInspectorFor:con |
9012 self showStackInspectorFor:con |
8899 ] ifFalse:[ |
9013 ] ifFalse:[ |
8900 self hideStackInspector |
9014 self hideStackInspector |
8901 ]. |
9015 ]. |
8902 |
9016 |
8903 homeContext := con methodHome. |
9017 homeContext := con methodHome. |
8904 con canReturn ifTrue:[ |
9018 con canReturn ifTrue:[ |
8905 returnButton enable. restartButton enable. |
9019 returnButton enable. restartButton enable. |
8906 ] ifFalse:[ |
9020 ] ifFalse:[ |
8907 returnButton disable. restartButton disable. |
9021 returnButton disable. restartButton disable. |
8908 ]. |
9022 ]. |
8909 |
9023 |
8910 lineNrInMethod := con lineNumber. |
9024 lineNrInMethod := con lineNumber. |
8911 |
9025 |
8912 canAccept := false. |
9026 canAccept := false. |
8913 |
9027 |
8914 homeContext isNil ifTrue:[ |
9028 homeContext isNil ifTrue:[ |
8915 " |
9029 " |
8916 mhmh - an optimized block |
9030 mhmh - an optimized block |
8917 should get the block here, and get the method from |
9031 should get the block here, and get the method from |
8918 that one ... |
9032 that one ... |
8919 But in the current version, there is no easy way to get to the block |
9033 But in the current version, there is no easy way to get to the block |
8920 since that one is not in the context. |
9034 since that one is not in the context. |
8921 A future new block calling scheme will fix this |
9035 A future new block calling scheme will fix this |
8922 (passing the block instead of the home as block argument). |
9036 (passing the block instead of the home as block argument). |
8923 " |
9037 " |
8924 (method := con method) isNil ifTrue:[ |
9038 (method := con method) isNil ifTrue:[ |
8925 "temporary kludge - peek into the sender context. |
9039 "temporary kludge - peek into the sender context. |
8926 If its a do-like method and there is a single block variable |
9040 If its a do-like method and there is a single block variable |
8927 in the args or temporaries, that must be the one. |
9041 in the args or temporaries, that must be the one. |
8928 This helps in some cases. |
9042 This helps in some cases. |
8929 " |
9043 " |
8930 (sender := con sender) notNil ifTrue:[ |
9044 (sender := con sender) notNil ifTrue:[ |
8931 tryVars := false. |
9045 tryVars := false. |
8932 (selSender := sender selector) notNil ifTrue:[ |
9046 (selSender := sender selector) notNil ifTrue:[ |
8933 ((selSender endsWith:'do:') or:[selSender endsWith:'Do:']) ifTrue:[ |
9047 ((selSender endsWith:'do:') or:[selSender endsWith:'Do:']) ifTrue:[ |
8934 tryVars := true. |
9048 tryVars := true. |
8935 ] |
9049 ] |
8936 ]. |
9050 ]. |
8937 tryVars ifTrue:[ |
9051 tryVars ifTrue:[ |
8938 possibleBlocks := sender argsAndVars select:[:v | v isBlock]. |
9052 possibleBlocks := sender argsAndVars select:[:v | v isBlock]. |
8939 possibleBlocks := possibleBlocks select:[:b | b home isNil]. |
9053 possibleBlocks := possibleBlocks select:[:b | b home isNil]. |
8940 possibleBlocks size == 1 ifTrue:[ |
9054 possibleBlocks size == 1 ifTrue:[ |
8941 method := possibleBlocks first method. |
9055 method := possibleBlocks first method. |
8942 ]. |
9056 ]. |
8943 ] |
9057 ] |
8944 ]. |
9058 ]. |
8945 ] |
9059 ] |
8946 ] ifFalse:[ |
9060 ] ifFalse:[ |
8947 "fetch rec here - so we won't need context in doItAction" |
9061 "fetch rec here - so we won't need context in doItAction" |
8948 rec := homeContext receiver. |
9062 rec := homeContext receiver. |
8949 sel := homeContext selector. |
9063 sel := homeContext selector. |
8950 sel notNil ifTrue:[ |
9064 sel notNil ifTrue:[ |
8951 canAccept := true. |
9065 canAccept := true. |
8952 |
9066 |
8953 implementorClass := homeContext methodClass. |
9067 implementorClass := homeContext methodClass. |
8954 implementorClass isNil ifTrue:[ |
9068 implementorClass isNil ifTrue:[ |
8955 homeContext method notNil ifTrue:[ |
9069 homeContext method notNil ifTrue:[ |
8956 WrappedMethod allInstancesDo:[:wrapped | |
9070 WrappedMethod allInstancesDo:[:wrapped | |
8957 wrapped originalMethod == homeContext method ifTrue:[ |
9071 wrapped originalMethod == homeContext method ifTrue:[ |
8958 implementorClass := wrapped mclass |
9072 implementorClass := wrapped mclass |
8959 ] |
9073 ] |
8960 ]. |
9074 ]. |
8961 implementorClass isNil ifTrue:[ |
9075 implementorClass isNil ifTrue:[ |
8962 (homeContext searchClass notNil |
9076 (homeContext searchClass notNil |
8963 and:[homeContext searchClass isObsolete]) ifTrue:[ |
9077 and:[homeContext searchClass isObsolete]) ifTrue:[ |
8964 cannotAcceptDueToOutdatedClass := true. |
9078 cannotAcceptDueToOutdatedClass := true. |
8965 ] |
9079 ] |
8966 ]. |
9080 ]. |
8967 ]. |
9081 ]. |
8968 ]. |
9082 ]. |
8969 implementorClass isNil ifTrue:[ |
9083 implementorClass isNil ifTrue:[ |
8970 Error handle:[:ex | |
9084 Error handle:[:ex | |
8971 "/ not covered by Error, anyway |
9085 "/ not covered by Error, anyway |
8972 "/ ex signal == BreakPointInterrupt ifTrue:[ |
9086 "/ ex signal == BreakPointInterrupt ifTrue:[ |
8973 "/ ex proceed. |
9087 "/ ex proceed. |
8974 "/ ]. |
9088 "/ ]. |
8975 code := 'error while asking method for its source'. |
9089 code := 'error while asking method for its source'. |
8976 code := code , Character cr , ex creator printString. |
9090 code := code , Character cr , ex creator printString. |
8977 code := code , Character cr , 'in: ' , ex suspendedContext printString. |
9091 code := code , Character cr , 'in: ' , ex suspendedContext printString. |
8978 |
9092 |
8979 canAccept := false. |
9093 canAccept := false. |
8980 ex return. |
9094 ex return. |
8981 ] do:[ |
9095 ] do:[ |
8982 " |
9096 " |
8983 special: look if this context was created by |
9097 special: look if this context was created by |
8984 valueWithReceiver kind of method invocation; |
9098 valueWithReceiver kind of method invocation; |
8985 if so, grab the method from the sender and show it |
9099 if so, grab the method from the sender and show it |
8986 " |
9100 " |
8987 ((sender := homeContext sender) notNil |
9101 ((sender := homeContext sender) notNil |
8988 and:[((sender selector ? '') startsWith:'valueWithReceiver:') |
9102 and:[((sender selector ? '') startsWith:'valueWithReceiver:') |
8989 and:[sender receiver isMethod]]) ifTrue:[ |
9103 and:[sender receiver isMethod]]) ifTrue:[ |
8990 method := sender receiver. |
9104 method := sender receiver. |
8991 canAccept := false. |
9105 canAccept := false. |
8992 ] ifFalse:[ |
9106 ] ifFalse:[ |
8993 (method := con method) notNil ifTrue:[ |
9107 (method := con method) notNil ifTrue:[ |
8994 canAccept := false. |
9108 canAccept := false. |
8995 ] |
9109 ] |
8996 ]. |
9110 ]. |
8997 ] |
9111 ] |
8998 ] ifFalse:[ |
9112 ] ifFalse:[ |
8999 method := implementorClass compiledMethodAt:sel. |
9113 method := implementorClass compiledMethodAt:sel. |
9000 ]. |
9114 ]. |
9001 ] |
9115 ] |
9002 ]. |
9116 ]. |
9003 |
9117 |
9004 homeContext notNil ifTrue:[ |
9118 homeContext notNil ifTrue:[ |
9005 searchClass := homeContext searchClass ? rec class. |
9119 searchClass := homeContext searchClass ? rec class. |
9006 currentMethod := searchClass lookupMethodFor:sel. |
9120 currentMethod := searchClass lookupMethodFor:sel. |
9007 ]. |
9121 ]. |
9008 originalMethod := currentMethod. |
9122 originalMethod := currentMethod. |
9009 (currentMethod notNil |
9123 (currentMethod notNil |
9010 and:[currentMethod ~~ method |
9124 and:[currentMethod ~~ method |
9011 and:[ (currentMethod isWrapped and:[ method == currentMethod originalMethod]) not ]]) ifTrue:[ |
9125 and:[ (currentMethod isWrapped and:[ method == currentMethod originalMethod]) not ]] |
9012 originalMethod := method. |
9126 ) ifTrue:[ |
9013 methodCodeToggleSelectionHolder value = 1 ifTrue:[ |
9127 originalMethod := method. |
9014 method := originalMethod. "/ the one which is suspended / was executing |
9128 methodCodeToggleSelectionHolder value = 1 ifTrue:[ |
9015 ] ifFalse:[ |
9129 method := originalMethod. "/ the one which is suspended / was executing |
9016 method := currentMethod. "/ the one which has already been accepted/modified. |
9130 ] ifFalse:[ |
9017 lineNrInMethod := nil. |
9131 method := currentMethod. "/ the one which has already been accepted/modified. |
9018 canAccept := true. |
9132 lineNrInMethod := nil. |
9019 ]. |
9133 canAccept := true. |
9020 methodCodeToggle beVisible. |
9134 ]. |
9021 ] ifFalse:[ |
9135 methodCodeToggle beVisible. |
9022 methodCodeToggle beInvisible. |
9136 ] ifFalse:[ |
9023 ]. |
9137 methodCodeToggle beInvisible. |
9024 |
9138 ]. |
9025 code isNil ifTrue:[ |
9139 |
9026 errMsg := nil. |
9140 code isNil ifTrue:[ |
9027 method isNil ifTrue:[ |
9141 errMsg := nil. |
9028 "/ fall back heuristics (see how this was called, fetch block from caller) |
9142 method isNil ifTrue:[ |
9029 sender := con sender. |
9143 "/ fall back heuristics (see how this was called, fetch block from caller) |
9030 con isBlockContext ifTrue:[ |
9144 sender := con sender. |
9031 (sender notNil |
9145 con isBlockContext ifTrue:[ |
9032 and:[((sender selector ? '') startsWith:'value') |
9146 (sender notNil |
9033 and:[sender receiver isBlock]]) ifTrue:[ |
9147 and:[((sender selector ? '') startsWith:'value') |
9034 code := sender receiver source. |
9148 and:[sender receiver isBlock]]) ifTrue:[ |
9035 ] |
9149 code := sender receiver source. |
9036 ] ifFalse:[ |
9150 ] |
9037 (sender notNil |
9151 ] ifFalse:[ |
9038 and:[((sender selector ? '') startsWith:'valueWith') |
9152 (sender notNil |
9039 and:[sender receiver isMethod]]) ifTrue:[ |
9153 and:[((sender selector ? '') startsWith:'valueWith') |
9040 method := sender receiver. |
9154 and:[sender receiver isMethod]]) ifTrue:[ |
9041 ] |
9155 method := sender receiver. |
9042 ] |
9156 ] |
9043 ]. |
9157 ] |
9044 method notNil ifTrue:[ |
9158 ]. |
9045 contextInspector fieldListLabel:(method selector "whoString"). |
9159 method notNil ifTrue:[ |
9046 Error handle:[:ex | |
9160 contextInspector fieldListLabel:(method selector "whoString"). |
|
9161 Error handle:[:ex | |
9047 "/ not covered by Error, anyway |
9162 "/ not covered by Error, anyway |
9048 "/ ex signal isControlInterrupt ifTrue:[ |
9163 "/ ex signal isControlInterrupt ifTrue:[ |
9049 "/ ex proceed. |
9164 "/ ex proceed. |
9050 "/ ]. |
9165 "/ ]. |
9051 code := 'error while asking method for its source'. |
9166 code := 'error while asking method for its source'. |
9052 code := code , Character cr , ex creator printString. |
9167 code := code , Character cr , ex creator printString. |
9053 code := code , Character cr , 'in: ' , ex suspendedContext printString. |
9168 code := code , Character cr , 'in: ' , ex suspendedContext printString. |
9054 |
9169 |
9055 canAccept := false. |
9170 canAccept := false. |
9056 ex return. |
9171 ex return. |
9057 ] do:[ |
9172 ] do:[ |
9058 self sensor shiftDown ifTrue:[ |
9173 self sensor shiftDown ifTrue:[ |
9059 code := method decompiledSource |
9174 code := method decompiledSource |
9060 ] ifFalse:[ |
9175 ] ifFalse:[ |
9061 code := method source. |
9176 code := method source. |
9062 ]. |
9177 ]. |
9063 ]. |
9178 ]. |
9064 |
9179 |
9065 code isNil ifTrue:[ |
9180 code isNil ifTrue:[ |
9066 method sourceFilename notNil ifTrue:[ |
9181 method sourceFilename notNil ifTrue:[ |
9067 codeView contents:(resources |
9182 codeView contents:(resources |
9068 string:'** no sourcefile: %1 **' |
9183 string:'** no sourcefile: %1 **' |
9069 with:method sourceFilename). |
9184 with:method sourceFilename). |
9070 codeView realized ifTrue:[ |
9185 codeView realized ifTrue:[ |
9071 "codeView is not realized on initial startup" |
9186 "codeView is not realized on initial startup" |
9072 codeView flash:'no source'. |
9187 codeView flash:'no source'. |
9073 ]. |
9188 ]. |
9074 codeSet := true. |
9189 codeSet := true. |
9075 ] ifFalse:[ |
9190 ] ifFalse:[ |
9076 [ |
9191 [ |
9077 |src| |
9192 |src| |
9078 |
9193 |
9079 src := String streamContents:[:s | Decompiler decompile:method to:s]. |
9194 src := String streamContents:[:s | Decompiler decompile:method to:s]. |
9080 codeView contents:src. |
9195 codeView contents:src. |
9081 codeSet := true. |
9196 codeSet := true. |
9082 ] on: Error do:[ |
9197 ] on: Error do:[ |
9083 errMsg := '** no source **' |
9198 errMsg := '** no source **' |
9084 ]. |
9199 ]. |
9085 ] |
9200 ] |
9086 ]. |
9201 ]. |
9087 ] ifFalse:[ |
9202 ] ifFalse:[ |
9088 contextInspector fieldListLabel:'Context'. |
9203 contextInspector fieldListLabel:'Context'. |
9089 homeContext isNil ifTrue:[ |
9204 homeContext isNil ifTrue:[ |
9090 errMsg := '** sorry; cannot show code of all optimized blocks (yet) **'. |
9205 errMsg := '** sorry; cannot show code of all optimized blocks (yet) **'. |
9091 ] ifFalse:[ |
9206 ] ifFalse:[ |
9092 errMsg := '** no method - no source **'. |
9207 errMsg := '** no method - no source **'. |
9093 canDefine := false. "/ true. |
9208 canDefine := false. "/ true. |
9094 ] |
9209 ] |
9095 ]. |
9210 ]. |
9096 errMsg notNil ifTrue:[ |
9211 errMsg notNil ifTrue:[ |
9097 self showError:errMsg. |
9212 self showError:errMsg. |
9098 codeSet := true. |
9213 codeSet := true. |
9099 ] |
9214 ] |
9100 ]. |
9215 ]. |
9101 |
9216 |
9102 code isNil ifTrue:[ |
9217 code isNil ifTrue:[ |
9103 "/ canAccept := false. |
9218 "/ canAccept := false. |
9104 codeSet ifFalse:[ |
9219 codeSet ifFalse:[ |
9105 codeView contents:nil. |
9220 codeView contents:nil. |
9106 ] |
9221 ] |
9107 ] ifFalse:[ |
9222 ] ifFalse:[ |
9108 lineNrInMethod notNil ifTrue:[ |
9223 lineNrInMethod notNil ifTrue:[ |
9109 lineNrInMethod == 0 ifTrue:[ |
9224 lineNrInMethod == 0 ifTrue:[ |
9110 (method notNil and:[method isJavaMethod]) ifTrue:[ |
9225 (method notNil and:[method isJavaMethod]) ifTrue:[ |
9111 lineNrInMethod := method lineNumber |
9226 lineNrInMethod := method lineNumber |
9112 ]. |
9227 ]. |
9113 "/ guess lineNumber from sent-messages selector |
9228 "/ guess lineNumber from sent-messages selector |
9114 "/ kludge to fix lineNr-display of shared subclassResponsibility methods. |
9229 "/ kludge to fix lineNr-display of shared subclassResponsibility methods. |
9115 lineNrInMethod == 0 ifTrue:[ |
9230 lineNrInMethod == 0 ifTrue:[ |
9116 |conIdx sentContext messages| |
9231 |conIdx sentContext messages| |
9117 |
9232 |
9118 conIdx := contextArray identityIndexOf:con. |
9233 conIdx := contextArray identityIndexOf:con. |
9119 conIdx > 1 ifTrue:[ |
9234 conIdx > 1 ifTrue:[ |
9120 sentContext := contextArray at:conIdx-1. |
9235 sentContext := contextArray at:conIdx-1. |
9121 sentContext isBlockContext ifFalse:[ |
9236 sentContext isBlockContext ifFalse:[ |
9122 (method notNil and:[code notNil]) ifTrue:[ |
9237 (method notNil and:[code notNil]) ifTrue:[ |
9123 messages := method messagesSent. |
9238 messages := method messagesSent. |
9124 messages size == 1 ifTrue:[ |
9239 messages size == 1 ifTrue:[ |
9125 sentContext selector == messages first ifTrue:[ |
9240 sentContext selector == messages first ifTrue:[ |
9126 lineNrInMethod := code asStringCollection findFirst:[:l | l includesString:sentContext selector]. |
9241 lineNrInMethod := code asStringCollection findFirst:[:l | l includesString:sentContext selector]. |
9127 ] |
9242 ] |
9128 ] |
9243 ] |
9129 ]. |
9244 ]. |
9130 ]. |
9245 ]. |
9131 ]. |
9246 ]. |
9132 ]. |
9247 ]. |
9133 ]. |
9248 ]. |
9134 ]. |
9249 ]. |
9135 codeView isCodeView2 ifTrue:[ |
9250 codeView isCodeView2 ifTrue:[ |
9136 codeView model |
9251 codeView model |
9137 setValue: code; |
9252 setValue: code; |
9138 changed. |
9253 changed. |
9139 codeView methodHolder value: method. |
9254 codeView methodHolder value: method. |
9140 codeView classHolder value: ((method respondsTo: #mclass) ifTrue:[method mclass] ifFalse:[rec class]) |
9255 codeView classHolder value: ((method respondsTo: #mclass) ifTrue:[method mclass] ifFalse:[rec class]) |
9141 ] ifFalse:[ |
9256 ] ifFalse:[ |
9142 UserPreferences current syntaxColoring ifTrue:[ |
9257 UserPreferences current syntaxColoring ifTrue:[ |
9143 implementorClass isNil ifTrue:[ |
9258 implementorClass isNil ifTrue:[ |
9144 (con isBlockContext |
9259 (con isBlockContext |
9145 and:[con home isNil |
9260 and:[con home isNil |
9146 and:[con guessedHome notNil]]) |
9261 and:[con guessedHome notNil]]) |
9147 ifTrue:[ |
9262 ifTrue:[ |
9148 implementorClass := con guessedHome mclass |
9263 implementorClass := con guessedHome mclass |
9149 ] |
9264 ] |
9150 ]. |
9265 ]. |
9151 implementorClass notNil ifTrue:[ |
9266 implementorClass notNil ifTrue:[ |
9152 (highlighter := implementorClass syntaxHighlighterClass) notNil ifTrue:[ |
9267 (highlighter := implementorClass syntaxHighlighterClass) notNil ifTrue:[ |
9153 code size < 100000 ifTrue:[ |
9268 code size < 100000 ifTrue:[ |
9154 Error catch:[ |
9269 Error catch:[ |
9155 code := highlighter formatMethodSource:code in:implementorClass. |
9270 code := highlighter formatMethodSource:code in:implementorClass. |
9156 ] |
9271 ] |
9157 ] |
9272 ] |
9158 ] |
9273 ] |
9159 ] |
9274 ] |
9160 ]. |
9275 ]. |
9161 |
9276 |
9162 "/ code ~= (codeView contents) ifTrue:[ |
9277 "/ code ~= (codeView contents) ifTrue:[ |
9163 cannotAcceptDueToOutdatedClass ifTrue:[ |
9278 cannotAcceptDueToOutdatedClass ifTrue:[ |
9164 codeView setContents:(('Obsolete code (outdated due to class change). Use Browser.' colorizeAllWith:Color red),Character cr,Character cr,code asString). |
9279 codeView setContents:(('Obsolete code (outdated due to class change). Use Browser.' colorizeAllWith:Color red),Character cr,Character cr,code asString). |
9165 ] ifFalse:[ |
9280 ] ifFalse:[ |
9166 codeView setContents:code. |
9281 codeView setContents:code. |
9167 ]. |
9282 ]. |
9168 "/ ]. |
9283 "/ ]. |
9169 ]. |
9284 ]. |
9170 (lineNrInMethod notNil |
9285 (lineNrInMethod notNil |
9171 and:[lineNrInMethod ~~ 0 |
9286 and:[lineNrInMethod ~~ 0 |
9172 and:[lineNrInMethod <= codeView list size]]) ifTrue:[ |
9287 and:[lineNrInMethod <= codeView list size]]) ifTrue:[ |
9173 lineNrInMethod == 255 ifFalse:[ |
9288 lineNrInMethod == 255 ifFalse:[ |
9174 (lineNrInMethod == 255 |
9289 (lineNrInMethod == 255 |
9175 and:[method notNil |
9290 and:[method notNil |
9176 and:[method hasCode not]]) ifTrue:[ |
9291 and:[method hasCode not]]) ifTrue:[ |
9177 "/ means: do not really know in interpreted methods |
9292 "/ means: do not really know in interpreted methods |
9178 codeView selectFromLine:255 col:1 toLine:codeView list size + 1 col:0. |
9293 codeView selectFromLine:255 col:1 toLine:codeView list size + 1 col:0. |
9179 ] ifFalse:[ |
9294 ] ifFalse:[ |
9180 codeView selectLine:lineNrInMethod. |
9295 codeView selectLine:lineNrInMethod. |
9181 ]. |
9296 ]. |
9182 codeView makeSelectionVisible |
9297 codeView makeSelectionVisible |
9183 ]. |
9298 ]. |
9184 ] ifFalse:[ |
9299 ] ifFalse:[ |
9185 codeView unselect. |
9300 codeView unselect. |
9186 codeView scrollToTop |
9301 codeView scrollToTop |
9187 ] |
9302 ] |
9188 ]. |
9303 ]. |
9189 |
9304 |
9190 codeView acceptEnabled:canAccept. |
9305 codeView acceptEnabled:canAccept. |
9191 canAccept ifTrue:[ |
9306 canAccept ifTrue:[ |
9192 codeView acceptAction:[:code | self codeAccept:code asString] |
9307 codeView acceptAction:[:code | self codeAccept:code asString] |
9193 ] ifFalse:[ |
9308 ] ifFalse:[ |
9194 codeView acceptAction:[:code | self beep] |
9309 codeView acceptAction:[:code | self beep] |
9195 ]. |
9310 ]. |
9196 |
9311 |
9197 receiverInspector inspect:rec. |
9312 receiverInspector inspect:rec. |
9198 receiverInspector fieldListLabel:("'Receiver: ',"rec classNameWithArticle). |
9313 receiverInspector fieldListLabel:("'Receiver: ',"rec classNameWithArticle). |
9199 receiverInspector tryToSelectKeyNamed:lastSelectionInReceiverInspector. |
9314 receiverInspector tryToSelectKeyNamed:lastSelectionInReceiverInspector. |
9200 |
9315 |
9201 " |
9316 " |
9202 the one below is wrong: currently, the |
9317 the one below is wrong: currently, the |
9203 evaluator cannot handle passed contexts. |
9318 evaluator cannot handle passed contexts. |
9204 Once it does, pass con as in:-arg |
9319 Once it does, pass con as in:-arg |
9205 " |
9320 " |
9206 (rec isJavaObject |
9321 (rec isJavaObject |
9207 and:[method isNil or:[method isJavaMethod not]]) ifTrue:[ |
9322 and:[method isNil or:[method isJavaMethod not]]) ifTrue:[ |
9208 "/ although a java object, use the smalltalk parser here for doIts. |
9323 "/ although a java object, use the smalltalk parser here for doIts. |
9209 evaluatorClass := Parser. |
9324 evaluatorClass := Parser. |
9210 codeView commentStrings:#( '//' ( '/*' '*/' ) ). |
9325 codeView commentStrings:#( '//' ( '/*' '*/' ) ). |
9211 ] ifFalse:[ |
9326 ] ifFalse:[ |
9212 (method notNil and:[method mclass notNil]) ifTrue:[ |
9327 (method notNil and:[method mclass notNil]) ifTrue:[ |
9213 evaluatorClass := method mclass evaluatorClass. |
9328 evaluatorClass := method mclass evaluatorClass. |
9214 codeView commentStrings:method mclass programmingLanguage commentStrings. |
9329 codeView commentStrings:method mclass programmingLanguage commentStrings. |
9215 ] ifFalse:[ |
9330 ] ifFalse:[ |
9216 evaluatorClass := rec class evaluatorClass. |
9331 evaluatorClass := rec class evaluatorClass. |
9217 codeView commentStrings:rec class programmingLanguage commentStrings. |
9332 codeView commentStrings:rec class programmingLanguage commentStrings. |
9218 ]. |
9333 ]. |
9219 ]. |
9334 ]. |
9220 |
9335 |
9221 codeView |
9336 codeView |
9222 doItAction: |
9337 doItAction: |
9223 [:theCode | |
9338 [:theCode | |
9224 evaluatorClass |
9339 evaluatorClass |
9225 evaluate:theCode |
9340 evaluate:theCode |
9226 in:actualContext "/ (selectedContext ? actualContext) |
9341 in:actualContext "/ (selectedContext ? actualContext) |
9227 receiver:rec |
9342 receiver:rec |
9228 notifying:codeView |
9343 notifying:codeView |
9229 logged:true |
9344 logged:true |
9230 ifFail:nil |
9345 ifFail:nil |
9231 ]; |
9346 ]; |
9232 editedMethodOrClass:(method ? rec class). |
9347 editedMethodOrClass:(method ? rec class). |
9233 |
9348 |
9234 |
9349 |
9235 self setCurrentMethod:method. |
9350 self setCurrentMethod:method. |
9236 |
9351 |
9237 selectedContext := homeContext ? con. |
9352 selectedContext := homeContext ? con. |
9238 actualContext := con |
9353 actualContext := con |
9239 ]. |
9354 ]. |
9240 ] ifFalse:[ |
9355 ] ifFalse:[ |
9241 codeView contents:nil. |
9356 codeView contents:nil. |
9242 ]. |
9357 ]. |
9243 codeView modified:false. |
9358 codeView modified:false. |
9244 |
9359 |
9245 con isContext ifFalse:[ |
9360 con isContext ifFalse:[ |
9246 sendButton disable. |
9361 sendButton disable. |
9247 ] ifTrue:[ |
9362 ] ifTrue:[ |
9248 sendButton enable. |
9363 sendButton enable. |
9249 ]. |
9364 ]. |
9250 self updateContextInfoFor:con. |
9365 self updateContextInfoFor:con. |
9251 |
9366 |
9252 "clear out locals to prevent keeping around unneeded contexts |
9367 "clear out locals to prevent keeping around unneeded contexts |
9253 (due to the block held in codeView). |
9368 (due to the block held in codeView). |