4475 |
4475 |
4476 codeAccept:someCode |
4476 codeAccept:someCode |
4477 "user wants some code to be recompiled - must unwind stack since everything above |
4477 "user wants some code to be recompiled - must unwind stack since everything above |
4478 and including selected method cannot be continued." |
4478 and including selected method cannot be continued." |
4479 |
4479 |
4480 ^ self codeAccept:someCode unwind:true |
4480 ^ self codeAccept:someCode unwind:true onCancel:nil |
4481 ! |
4481 |
4482 |
4482 "Modified: / 17.11.2001 / 12:24:37 / cg" |
4483 codeAccept:someCode unwind:doUnwind |
|
4484 "user wants some code to be recompiled - must unwind stack since everything above |
|
4485 and including selected method cannot be continued." |
|
4486 |
|
4487 " |
|
4488 actually, this is not true, since the active methods will still be |
|
4489 executed correctly - however, the code shown in the debugger is no |
|
4490 longer in sync (showing the new code) with the executed code. |
|
4491 Therefore, we hide those contexts to avoid confusion .... |
|
4492 If you dont like this behavior, remove the 'inspecting ifFalse:' check below" |
|
4493 |
|
4494 "walk up context chain and find highest context which is either the selected context, |
|
4495 or - if its a block-context - whose home is the selected context" |
|
4496 |
|
4497 |con top sel implementorClass method newMethod category| |
|
4498 |
|
4499 |
|
4500 codeView withWaitCursorDo:[ |
|
4501 " |
|
4502 find the method-home context for this one |
|
4503 " |
|
4504 con := selectedContext. |
|
4505 top := con. |
|
4506 [con notNil] whileTrue:[ |
|
4507 (con methodHome == selectedContext) ifTrue:[ |
|
4508 top := con |
|
4509 ]. |
|
4510 con := con sender |
|
4511 ]. |
|
4512 " |
|
4513 use class&selector to find the method for the compilation |
|
4514 and compile. |
|
4515 " |
|
4516 sel := selectedContext selector. |
|
4517 implementorClass := selectedContext methodClass. |
|
4518 implementorClass notNil ifTrue:[ |
|
4519 method := implementorClass compiledMethodAt:sel. |
|
4520 category := method category |
|
4521 ] ifFalse:[ |
|
4522 implementorClass := selectedContext receiver class. |
|
4523 implementorClass ~~ Object ifTrue:[ |
|
4524 implementorClass := Dialog |
|
4525 request:'Accept in which class:' |
|
4526 initialAnswer:implementorClass name |
|
4527 list:(implementorClass withAllSuperclasses collect:[:each| each name]). |
|
4528 implementorClass size == 0 ifTrue:[ |
|
4529 ^ self "/ cancelled |
|
4530 ]. |
|
4531 implementorClass := Smalltalk at:implementorClass asSymbol. |
|
4532 implementorClass isNil ifTrue:[ |
|
4533 Dialog warn:'no such class'. |
|
4534 ^ self "/ cancelled |
|
4535 ]. |
|
4536 ]. |
|
4537 category := '* As yet uncategorized *'. |
|
4538 ]. |
|
4539 |
|
4540 "/ |
|
4541 "/ provide the classes nameSpace on a query; |
|
4542 "/ in case we accept while in another nameSpace context, |
|
4543 "/ (but for a class which is somewhere else) |
|
4544 "/ |
|
4545 Class updateChangeFileQuerySignal answer:true |
|
4546 do:[ |
|
4547 Class updateChangeListQuerySignal answer:true |
|
4548 do:[ |
|
4549 Class nameSpaceQuerySignal |
|
4550 answer:(implementorClass nameSpace) |
|
4551 do:[ |
|
4552 newMethod := implementorClass compilerClass |
|
4553 compile:someCode |
|
4554 forClass:implementorClass |
|
4555 inCategory:category |
|
4556 notifying:codeView. |
|
4557 ]. |
|
4558 ]. |
|
4559 ]. |
|
4560 |
|
4561 inspecting ifFalse:[ |
|
4562 " |
|
4563 if it worked, remove everything up to and including top |
|
4564 from context chain |
|
4565 " |
|
4566 (newMethod notNil and:[newMethod ~~ #Error]) ifTrue:[ |
|
4567 codeView modified:false. |
|
4568 |
|
4569 doUnwind ifTrue:[ |
|
4570 self setContext:(top sender). |
|
4571 |
|
4572 " |
|
4573 continue/step is no longer possible |
|
4574 " |
|
4575 canContinue := false. |
|
4576 exitAction := #return. |
|
4577 ]. |
|
4578 self showSelection:1. |
|
4579 ]. |
|
4580 ]. |
|
4581 ]. |
|
4582 |
|
4583 "Modified: / 15.11.2001 / 17:07:29 / cg" |
|
4584 ! |
4483 ! |
4585 |
4484 |
4586 codeAccept:someCode unwind:doUnwind onCancel:cancelAction |
4485 codeAccept:someCode unwind:doUnwind onCancel:cancelAction |
4587 "user wants some code to be recompiled - must unwind stack since everything above |
4486 "user wants some code to be recompiled - must unwind stack since everything above |
4588 and including selected method cannot be continued." |
4487 and including selected method cannot be continued." |