365 "Modified: 12.6.1996 / 11:49:08 / stefan" |
365 "Modified: 12.6.1996 / 11:49:08 / stefan" |
366 "Created: 3.6.1997 / 11:55:05 / cg" |
366 "Created: 3.6.1997 / 11:55:05 / cg" |
367 ! ! |
367 ! ! |
368 |
368 |
369 !ClassDescription methodsFor:'adding/removing'! |
369 !ClassDescription methodsFor:'adding/removing'! |
|
370 |
|
371 addSelector:newSelector withMethod:newMethod |
|
372 "add the method given by 2nd argument under the selector given by |
|
373 1st argument to the methodDictionary. |
|
374 Append a change record to the changes file and tell dependents." |
|
375 |
|
376 |oldMethod| |
|
377 |
|
378 oldMethod := self compiledMethodAt:newSelector. |
|
379 |
|
380 CatchMethodRedefinitions ifTrue:[ |
|
381 "check for attempts to redefine a method |
|
382 in a different package. Signal a resumable error if so. |
|
383 This allows tracing redefinitions of existing system methods |
|
384 when filing in alien code .... |
|
385 (which we may want to forbit sometimes) |
|
386 " |
|
387 oldMethod notNil ifTrue:[ |
|
388 oldMethod package ~= newMethod package ifTrue:[ |
|
389 " |
|
390 attempt to redefine an existing method, which was |
|
391 defined in another package. |
|
392 If you continue in the debugger, the new method gets installed. |
|
393 Otherwise, the existing (old) method remains valid. |
|
394 |
|
395 You can turn of the catching of redefinitions by setting |
|
396 CatchMethodRedefinitions to false |
|
397 (also found in the Launchers 'settings-misc' menu) |
|
398 " |
|
399 (MethodRedefinitionSignal |
|
400 raiseRequestWith:(oldMethod -> newMethod) |
|
401 errorString:('redefinition of ' , self name , '>>' , newSelector) |
|
402 ) == #keep ifTrue:[ |
|
403 newMethod package:oldMethod package |
|
404 ]. |
|
405 |
|
406 "/ if proceeded, install as usual. |
|
407 ] |
|
408 ] |
|
409 ]. |
|
410 |
|
411 "/ remember new->old association in the OldMethods dictionary (if non-nil) |
|
412 |
|
413 OldMethods notNil ifTrue:[ |
|
414 oldMethod notNil ifTrue:[ |
|
415 "/ oldMethod source:(oldMethod source). |
|
416 OldMethods at:newMethod put:oldMethod |
|
417 ] |
|
418 ]. |
|
419 |
|
420 "/ remember in the projects overwritten dictionary |
|
421 |
|
422 oldMethod notNil ifTrue:[ |
|
423 oldMethod package ~= newMethod package ifTrue:[ |
|
424 Project notNil ifTrue:[ |
|
425 "/ allow configurations without Project |
|
426 Project rememberOverwrittenMethod:newMethod from:oldMethod |
|
427 ] |
|
428 ] |
|
429 ]. |
|
430 |
|
431 (super addSelector:newSelector withMethod:newMethod) ifTrue:[ |
|
432 self addChangeRecordForMethod:newMethod. |
|
433 ] |
|
434 |
|
435 "Modified: 9.9.1996 / 22:39:32 / stefan" |
|
436 "Modified: 4.6.1997 / 14:47:06 / cg" |
|
437 "Created: 4.6.1997 / 14:47:10 / cg" |
|
438 ! |
370 |
439 |
371 basicAddSelector:newSelector withMethod:newMethod |
440 basicAddSelector:newSelector withMethod:newMethod |
372 "add the method given by 2nd argument under the selector given by |
441 "add the method given by 2nd argument under the selector given by |
373 1st argument to the methodDictionary. |
442 1st argument to the methodDictionary. |
374 This does NOT append a change record to the changes file and tell |
443 This does NOT append a change record to the changes file and tell |