Decompiling method body returns as block?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Decompiling method body returns as block?

hernanmd
Hi list,
I'm using Pharo1.1rc2 #11400 and I want to extract the body part (the
String without the selector) of a CompiledMethod, but I'm getting a
BlockNode after sending #body and a MNU afterwards. This is what I do

aCompiledMethod decompileWithTemps ---> a BytecodeAgnosticMethodNode
which is displayed like:

'renderContentOn: aRenderer
        aRenderer form id: ''horizontalForm'';
                with: [aRenderer
                                fieldSet: [ ... blablabla ]]'

and is ok. Then

aCompiledMethod decompileWithTemps body ---> a BlockNode displayed as:

{[:aRenderer |
aRenderer form id: 'horizontalForm';
                with: [aRenderer
                                fieldSet: [... blablabla]]]}

I've expected the code string (sending #decompileString) without
"[:aRenderer |" part (used to work that way).
The thing is if I send #code to the BlockNode I get a
"MessageNotUnderstood: CascadeNode>>code".
I'd appreciate any hint to solve this.
Cheers,


--
Hernán Morales
Information Technology Manager,
Institute of Veterinary Genetics.
National Scientific and Technical Research Council (CONICET).
La Plata (1900), Buenos Aires, Argentina.
Telephone: +54 (0221) 421-1799.
Internal: 422
Fax: 425-7980 or 421-1799.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Decompiling method body returns as block?

Lukas Renggli
The old compiler has a strange AST representation. It represents
method bodies as blocks.

Probably the easiest is to parse the decompiled code with the
refactoring engine and extract the body there:

   (RBParser parseMethod: aCompiledMethod decompileWithTemps) body

Lukas

On 19 October 2010 22:37, Hernán Morales Durand
<[hidden email]> wrote:

> Hi list,
> I'm using Pharo1.1rc2 #11400 and I want to extract the body part (the
> String without the selector) of a CompiledMethod, but I'm getting a
> BlockNode after sending #body and a MNU afterwards. This is what I do
>
> aCompiledMethod decompileWithTemps ---> a BytecodeAgnosticMethodNode
> which is displayed like:
>
> 'renderContentOn: aRenderer
>        aRenderer form id: ''horizontalForm'';
>                with: [aRenderer
>                                fieldSet: [ ... blablabla ]]'
>
> and is ok. Then
>
> aCompiledMethod decompileWithTemps body ---> a BlockNode displayed as:
>
> {[:aRenderer |
> aRenderer form id: 'horizontalForm';
>                with: [aRenderer
>                                fieldSet: [... blablabla]]]}
>
> I've expected the code string (sending #decompileString) without
> "[:aRenderer |" part (used to work that way).
> The thing is if I send #code to the BlockNode I get a
> "MessageNotUnderstood: CascadeNode>>code".
> I'd appreciate any hint to solve this.
> Cheers,
>
>
> --
> Hernán Morales
> Information Technology Manager,
> Institute of Veterinary Genetics.
> National Scientific and Technical Research Council (CONICET).
> La Plata (1900), Buenos Aires, Argentina.
> Telephone: +54 (0221) 421-1799.
> Internal: 422
> Fax: 425-7980 or 421-1799.
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project



--
Lukas Renggli
www.lukas-renggli.ch

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Decompiling method body returns as block?

Eliot Miranda-2
In reply to this post by hernanmd
Hi Hernán,

On Tue, Oct 19, 2010 at 1:37 PM, Hernán Morales Durand <[hidden email]> wrote:
Hi list,
I'm using Pharo1.1rc2 #11400 and I want to extract the body part (the
String without the selector) of a CompiledMethod, but I'm getting a
BlockNode after sending #body and a MNU afterwards. This is what I do

aCompiledMethod decompileWithTemps ---> a BytecodeAgnosticMethodNode
which is displayed like:

'renderContentOn: aRenderer
       aRenderer form id: ''horizontalForm'';
               with: [aRenderer
                               fieldSet: [ ... blablabla ]]'

and is ok. Then

aCompiledMethod decompileWithTemps body ---> a BlockNode displayed as:

{[:aRenderer |
aRenderer form id: 'horizontalForm';
               with: [aRenderer
                               fieldSet: [... blablabla]]]}

I've expected the code string (sending #decompileString) without
"[:aRenderer |" part (used to work that way).
The thing is if I send #code to the BlockNode I get a
"MessageNotUnderstood: CascadeNode>>code".
I'd appreciate any hint to solve this.

An alternative to Lukas' suggestion would be to refactor MethodNode>>printOn: into 
    printOn: aStream
        self
            printSignatureOn: aStream;
            printBodyOn: aStream

and then use aCompiledMethod decompileWithTemps printBodyOn:

best,
Eliot

Cheers,


--
Hernán Morales
Information Technology Manager,
Institute of Veterinary Genetics.
National Scientific and Technical Research Council (CONICET).
La Plata (1900), Buenos Aires, Argentina.
Telephone: +54 (0221) 421-1799.
Internal: 422
Fax: 425-7980 or 421-1799.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Decompiling method body returns as block?

hernanmd
Wonderfull, thanks Lukas and Eliot!

2010/10/19 Eliot Miranda <[hidden email]>:

> Hi Hernán,
>
> On Tue, Oct 19, 2010 at 1:37 PM, Hernán Morales Durand
> <[hidden email]> wrote:
>>
>> Hi list,
>> I'm using Pharo1.1rc2 #11400 and I want to extract the body part (the
>> String without the selector) of a CompiledMethod, but I'm getting a
>> BlockNode after sending #body and a MNU afterwards. This is what I do
>>
>> aCompiledMethod decompileWithTemps ---> a BytecodeAgnosticMethodNode
>> which is displayed like:
>>
>> 'renderContentOn: aRenderer
>>        aRenderer form id: ''horizontalForm'';
>>                with: [aRenderer
>>                                fieldSet: [ ... blablabla ]]'
>>
>> and is ok. Then
>>
>> aCompiledMethod decompileWithTemps body ---> a BlockNode displayed as:
>>
>> {[:aRenderer |
>> aRenderer form id: 'horizontalForm';
>>                with: [aRenderer
>>                                fieldSet: [... blablabla]]]}
>>
>> I've expected the code string (sending #decompileString) without
>> "[:aRenderer |" part (used to work that way).
>> The thing is if I send #code to the BlockNode I get a
>> "MessageNotUnderstood: CascadeNode>>code".
>> I'd appreciate any hint to solve this.
>
> An alternative to Lukas' suggestion would be to refactor
> MethodNode>>printOn: into
>     printOn: aStream
>         self
>             printSignatureOn: aStream;
>             printBodyOn: aStream
> and then use aCompiledMethod decompileWithTemps printBodyOn:
> best,
> Eliot
>>
>> Cheers,
>>
>>
>> --
>> Hernán Morales
>> Information Technology Manager,
>> Institute of Veterinary Genetics.
>> National Scientific and Technical Research Council (CONICET).
>> La Plata (1900), Buenos Aires, Argentina.
>> Telephone: +54 (0221) 421-1799.
>> Internal: 422
>> Fax: 425-7980 or 421-1799.
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



--
Hernán Morales
Information Technology Manager,
Institute of Veterinary Genetics.
National Scientific and Technical Research Council (CONICET).
La Plata (1900), Buenos Aires, Argentina.
Telephone: +54 (0221) 421-1799.
Internal: 422
Fax: 425-7980 or 421-1799.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Decompiling method body returns as block?

Stéphane Ducasse
In reply to this post by Eliot Miranda-2
if you refactor the method send it to us in a bug entry :)

Stef

On Oct 20, 2010, at 5:49 AM, Hernán Morales Durand wrote:

> Wonderfull, thanks Lukas and Eliot!
>
> 2010/10/19 Eliot Miranda <[hidden email]>:
>> Hi Hernán,
>>
>> On Tue, Oct 19, 2010 at 1:37 PM, Hernán Morales Durand
>> <[hidden email]> wrote:
>>>
>>> Hi list,
>>> I'm using Pharo1.1rc2 #11400 and I want to extract the body part (the
>>> String without the selector) of a CompiledMethod, but I'm getting a
>>> BlockNode after sending #body and a MNU afterwards. This is what I do
>>>
>>> aCompiledMethod decompileWithTemps ---> a BytecodeAgnosticMethodNode
>>> which is displayed like:
>>>
>>> 'renderContentOn: aRenderer
>>>        aRenderer form id: ''horizontalForm'';
>>>                with: [aRenderer
>>>                                fieldSet: [ ... blablabla ]]'
>>>
>>> and is ok. Then
>>>
>>> aCompiledMethod decompileWithTemps body ---> a BlockNode displayed as:
>>>
>>> {[:aRenderer |
>>> aRenderer form id: 'horizontalForm';
>>>                with: [aRenderer
>>>                                fieldSet: [... blablabla]]]}
>>>
>>> I've expected the code string (sending #decompileString) without
>>> "[:aRenderer |" part (used to work that way).
>>> The thing is if I send #code to the BlockNode I get a
>>> "MessageNotUnderstood: CascadeNode>>code".
>>> I'd appreciate any hint to solve this.
>>
>> An alternative to Lukas' suggestion would be to refactor
>> MethodNode>>printOn: into
>>     printOn: aStream
>>         self
>>             printSignatureOn: aStream;
>>             printBodyOn: aStream
>> and then use aCompiledMethod decompileWithTemps printBodyOn:
>> best,
>> Eliot
>>>
>>> Cheers,
>>>
>>>
>>> --
>>> Hernán Morales
>>> Information Technology Manager,
>>> Institute of Veterinary Genetics.
>>> National Scientific and Technical Research Council (CONICET).
>>> La Plata (1900), Buenos Aires, Argentina.
>>> Telephone: +54 (0221) 421-1799.
>>> Internal: 422
>>> Fax: 425-7980 or 421-1799.
>>>
>>> _______________________________________________
>>> Pharo-project mailing list
>>> [hidden email]
>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>
>
>
> --
> Hernán Morales
> Information Technology Manager,
> Institute of Veterinary Genetics.
> National Scientific and Technical Research Council (CONICET).
> La Plata (1900), Buenos Aires, Argentina.
> Telephone: +54 (0221) 421-1799.
> Internal: 422
> Fax: 425-7980 or 421-1799.
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project