aClass compile: (aClass sourceCodeAt: aMethod) string,' "** this is a comment**"'
Cheers, Bob
On 4/29/13 4:03 PM, Dvir Faivel wrote:
T hanks Bob! the example helped a lot.
Tim, i want to change the behavior of some methods (at runtime, based on the user's decision). for example, if a method of class A contains the comment: "hello, this is a comment" than if B inherits from A, this method wouldn't be inherited (an attempt to call this method from an object of type B would cause an exception to be thrown). the reason i'm using a comment is that it doesn't affect the code.
is there a simple way to add a code to a method? for example, to add "this is a comment" to the end of the code?
On Mon, Apr 29, 2013 at 2:46 AM, tim Rowledge <tim@rowledge.org mailto:tim@rowledge.org> wrote:
On 28-04-2013, at 1:55 PM, Dvir Faivel <sdvirf@t2.technion.ac.il <mailto:sdvirf@t2.technion.ac.il>> wrote: > hi there, > i have a question about squeak object model. > > how can i check whether a method contains a certain piece of code? You'll get better advice if you expand upon what you want & why; what is the real problem you are trying to solve here? If, for example you're simply wanting to programatically find all senders of a particular message then the code is already there - take a look at SystemNavigation>allCallsOn:fromBehaviors:sorted: to see how to scan all the methods implemented by a list of behaviours (ie classes or metaclasses) for sends of a particular message, including ones that are special cases. If you already know which class and method you want to look at then examine Behavior>whichSelectorsReferTo:specialByte:thorough: to see how the system does it. Or are you wanting to look for particular fragments of code with some sort of text based pattern matching? Or...? tim -- tim Rowledge; tim@rowledge.org <mailto:tim@rowledge.org>; http://www.rowledge.org/tim ASCII to ASCII, DOS to DOS. ************************************************************************************ This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses. ************************************************************************************