On 25 Jul 2014, at 20:55, Marcus Denker <marcus.denker@inria.fr> wrote:


On 25 Jul 2014, at 20:49, Thierry Goubier <thierry.goubier@gmail.com> wrote:

Le 25/07/2014 20:37, kilon alios a �crit :
I don't understand how to use aClass definition from workspace nor I understand your selector message. 

(aClass compiledMethodAt: self selector) sourceCode , self would imply that i try to operate this from inside another class with self selector being the method itself at the time executed ?
No, just that you can write:

(Object compiledMethodAt: #printString) sourceCode

That's me not sanitizing my code samples (lifting it from the AltBrowser)


However because I try to parse pharo syntax to python code, the classes that I am parsing are unrelated to the parser class itself  so I don't see how self selector would be relevant here. 


I also don't understand 

    ast := RBParser parseMethod: aTarget text asString onError: [ :msg :pos | ^ self ].
    ast doSemanticAnalysisIn: self sourceClass

what is aTarget ?

Ok, as above, it should be understood as:

ast := RBParser parseMethod: (Object compiledMethodAt: #printString) onError: [ :msg :ps | ].
ast doSemanticAnalysisIn: self sourceClass.


There is  a method on CompiledMethod called #ast that called the parser + semantic analysis:

( Object compiledMethodAt: #halt ) ast

No need to know details about RBParser.

as example how to query the AST see the method #accessesSlot:

accessesSlot: aSlot
self ast nodesDo: [ :node | 
node isVariable and: [
node isInstance and: [ 
(node binding slot ==  aSlot)
ifTrue: [^true]]]]. 
^false