Hi
to prepare some code for students I want to convert methods into a kind of method skeleton ie printOn: aStream "super nice comment" lk;lk; kl;;kl k;lkl;k ^ 42 into printOn: aStream "super nice comment" ^ self any idea? In the past I know that we could access the method comment but I do not find how to access the method signature (selector + variables). So I'm trying at the AST level. ((ObjSkeletonMock >> #methodToSkeletonize2) ast body: (ObjSkeletonMock >> #returnSelf) ast body). But I do not get how I can recompile this. Stef |
Hi, just after your modifications, from the compiled method try: ObjSkeletonMock compile: self ast newSource Maybe not the most elegant but it works.
Steven. Le 2017-12-03 22:31, Stephane Ducasse a écrit :
--
kloum.io
|
For example that works for me: |ast| Le 2017-12-03 23:42, Steven Costiou a écrit :
--
kloum.io
|
Thanks steven
I was finally doing | newTree | newTree := (ObjSkeletonMock >> #methodToSkeletonize2) ast body: (ObjSkeletonMock >> #returnSelf) ast body. newTree formattedCode. ObjSkeletonMock compile: newTree formattedCode classified: #foo On Sun, Dec 3, 2017 at 11:45 PM, Steven Costiou <[hidden email]> wrote: > For example that works for me: > > |ast| > ast := (MyClass >> #printOn:) ast. > ast body: (MyClass >> #returnSelf) ast body. > MyClass compile: ast newSource > > Le 2017-12-03 23:42, Steven Costiou a écrit : > > Hi, > > just after your modifications, from the compiled method try: > > ObjSkeletonMock compile: self ast newSource > > Maybe not the most elegant but it works. > > > > Steven. > > Le 2017-12-03 22:31, Stephane Ducasse a écrit : > > Hi > > to prepare some code for students I want to convert methods into a > kind of method skeleton > ie > > printOn: aStream > "super nice comment" > lk;lk; > kl;;kl > k;lkl;k > ^ 42 > > into > > printOn: aStream > "super nice comment" > ^ self > > any idea? > > In the past I know that we could access the method comment but I do > not find how to access the method signature (selector + variables). > > So I'm trying at the AST level. > > ((ObjSkeletonMock >> #methodToSkeletonize2) ast body: > (ObjSkeletonMock >> #returnSelf) ast body). > > But I do not get how I can recompile this. > > Stef > > > > -- > kloum.io > > > > -- > kloum.io |
Free forum by Nabble | Edit this page |