[Pharo-project] Compiling a method taking wrong source
Hi, I have a simple snippet of code which says: *someObject class compile: aMethod classified: someCategory notifying: aRequestor.* where aRequestor is a PluggableTextMorph. Actually, when I try to compile a method with a temp var, letting the compiler notify me when a temp var is needed, I always see the final CompiledMethod with the wrong source. For example, compiling someMethod ^someTemp Is correctly updated to be someMethod | someTemp | ^someTemp But, after the compilation process, when I get the compiled method source, It just have someMethod ^someTemp Debugging, I ended up in ClassDescriptioncompile: *text* classified: category withStamp: changeStamp notifying: requestor logSource: logSource | methodAndNode | methodAndNode := self compile: text asString classified: category notifying: requestor trailer: self defaultMethodTrailer ifFail: [^nil]. logSource ifTrue: [ self logMethodSource: *text* forMethodWithNode: methodAndNode inCategory: category withStamp: changeStamp notifying: requestor. ]. self addAndClassifySelector: methodAndNode selector withMethod: methodAndNode method inProtocol: category notifying: requestor. self instanceSide noteCompilationOf: methodAndNode selector meta: self isClassSide. ^ methodAndNode selector Which is saving as the CompiledMethod source, the original text, not the one which was changed in the PluggableTextMorph and compiled in the methodAndNode object. Well, I was looking how the Browser works, and I didn't realize the difference... Can someone enlight me? Thanks, Guille
Well, replacing: self logMethodSource: *text* forMethodWithNode: methodAndNode inCategory: category withStamp: changeStamp notifying: requestor. by self logMethodSource: *methodAndNode node printString* forMethodWithNode: methodAndNode inCategory: category withStamp: changeStamp notifying: requestor. Works well :). But for sure I smell I'm doing something veeery wrong :S Has it something to do with using a mutable text instead of a string? On Sun, Jun 19, 2011 at 3:32 PM, Guillermo Polito <guillermopolito@gmail.com
wrote:
Hi, I have a simple snippet of code which says:
*someObject class compile: aMethod classified: someCategory notifying: aRequestor.*
where aRequestor is a PluggableTextMorph.
Actually, when I try to compile a method with a temp var, letting the compiler notify me when a temp var is needed, I always see the final CompiledMethod with the wrong source. For example, compiling
someMethod ^someTemp
Is correctly updated to be
someMethod | someTemp | ^someTemp
But, after the compilation process, when I get the compiled method source, It just have
someMethod ^someTemp
Debugging, I ended up in
ClassDescriptioncompile: *text* classified: category withStamp: changeStamp notifying: requestor logSource: logSource | methodAndNode | methodAndNode := self compile: text asString classified: category notifying: requestor trailer: self defaultMethodTrailer ifFail: [^nil]. logSource ifTrue: [ self logMethodSource: *text* forMethodWithNode: methodAndNode inCategory: category withStamp: changeStamp notifying: requestor. ]. self addAndClassifySelector: methodAndNode selector withMethod: methodAndNode method inProtocol: category notifying: requestor. self instanceSide noteCompilationOf: methodAndNode selector meta: self isClassSide. ^ methodAndNode selector
Which is saving as the CompiledMethod source, the original text, not the one which was changed in the PluggableTextMorph and compiled in the methodAndNode object.
Well, I was looking how the Browser works, and I didn't realize the difference... Can someone enlight me?
Thanks, Guille
This is a bug introduced by the TextEditor changes. I thought it was fixed in the latest Pharo 1.2.1? Lukas On 19 June 2011 20:37, Guillermo Polito <guillermopolito@gmail.com> wrote:
Well, replacing:
self logMethodSource: text forMethodWithNode: methodAndNode          inCategory: category withStamp: changeStamp notifying: requestor.
by
self logMethodSource: methodAndNode node printString forMethodWithNode: methodAndNode          inCategory: category withStamp: changeStamp notifying: requestor.
Works well :). But for sure I smell I'm doing something veeery wrong :S
Has it something to do with using a mutable text instead of a string?
On Sun, Jun 19, 2011 at 3:32 PM, Guillermo Polito <guillermopolito@gmail.com> wrote:
Hi, I have a simple snippet of code which says:
someObject class compile: aMethod classified: someCategory notifying: aRequestor.
where aRequestor is a PluggableTextMorph.
Actually, when I try to compile a method with a temp var, letting the compiler notify me when a temp var is needed, I always see the final CompiledMethod with the wrong source. For example, compiling
someMethod  ^someTemp
Is correctly updated to be
someMethod  | someTemp |  ^someTemp
But, after the compilation process, when I get the compiled method source, It just have
someMethod  ^someTemp
Debugging, I ended up in
ClassDescriptioncompile: text classified: category withStamp: changeStamp notifying: requestor logSource: logSource    | methodAndNode |    methodAndNode := self compile: text asString classified: category notifying: requestor                      trailer: self defaultMethodTrailer ifFail: [^nil].    logSource ifTrue: [       self logMethodSource: text forMethodWithNode: methodAndNode          inCategory: category withStamp: changeStamp notifying: requestor.    ].    self addAndClassifySelector: methodAndNode selector withMethod: methodAndNode       method inProtocol: category notifying: requestor.    self instanceSide noteCompilationOf: methodAndNode selector meta: self isClassSide.    ^ methodAndNode selector
Which is saving as the CompiledMethod source, the original text, not the one which was changed in the PluggableTextMorph and compiled in the methodAndNode object.
Well, I was looking how the Browser works, and I didn't realize the difference... Can someone enlight me?
Thanks, Guille
-- Lukas Renggli www.lukas-renggli.ch
Mmm, maybe I'm using an old image. Let me check, thanks! On Sun, Jun 19, 2011 at 4:17 PM, Lukas Renggli <renggli@gmail.com> wrote:
This is a bug introduced by the TextEditor changes. I thought it was fixed in the latest Pharo 1.2.1?
Lukas
On 19 June 2011 20:37, Guillermo Polito <guillermopolito@gmail.com> wrote:
Well, replacing:
self logMethodSource: text forMethodWithNode: methodAndNode inCategory: category withStamp: changeStamp notifying: requestor.
by
self logMethodSource: methodAndNode node printString forMethodWithNode: methodAndNode inCategory: category withStamp: changeStamp notifying: requestor.
Works well :). But for sure I smell I'm doing something veeery wrong :S
Has it something to do with using a mutable text instead of a string?
On Sun, Jun 19, 2011 at 3:32 PM, Guillermo Polito <guillermopolito@gmail.com> wrote:
Hi, I have a simple snippet of code which says:
someObject class compile: aMethod classified: someCategory notifying: aRequestor.
where aRequestor is a PluggableTextMorph.
Actually, when I try to compile a method with a temp var, letting the compiler notify me when a temp var is needed, I always see the final CompiledMethod with the wrong source. For example, compiling
someMethod ^someTemp
Is correctly updated to be
someMethod | someTemp | ^someTemp
But, after the compilation process, when I get the compiled method
source,
It just have
someMethod ^someTemp
Debugging, I ended up in
ClassDescriptioncompile: text classified: category withStamp: changeStamp notifying: requestor logSource: logSource | methodAndNode | methodAndNode := self compile: text asString classified: category notifying: requestor trailer: self defaultMethodTrailer ifFail: [^nil]. logSource ifTrue: [ self logMethodSource: text forMethodWithNode: methodAndNode inCategory: category withStamp: changeStamp notifying: requestor. ]. self addAndClassifySelector: methodAndNode selector withMethod: methodAndNode method inProtocol: category notifying: requestor. self instanceSide noteCompilationOf: methodAndNode selector meta: self isClassSide. ^ methodAndNode selector
Which is saving as the CompiledMethod source, the original text, not the one which was changed in the PluggableTextMorph and compiled in the methodAndNode object.
Well, I was looking how the Browser works, and I didn't realize the difference... Can someone enlight me?
Thanks, Guille
-- Lukas Renggli www.lukas-renggli.ch
Yeap, my fault! I was using a #12340 image while the ones in hudson are #12353 :) At least I learnt some things :P. Sorry for the spam, Guille On Sun, Jun 19, 2011 at 4:21 PM, Guillermo Polito <guillermopolito@gmail.com
wrote:
Mmm, maybe I'm using an old image. Let me check,
thanks!
On Sun, Jun 19, 2011 at 4:17 PM, Lukas Renggli <renggli@gmail.com> wrote:
This is a bug introduced by the TextEditor changes. I thought it was fixed in the latest Pharo 1.2.1?
Lukas
On 19 June 2011 20:37, Guillermo Polito <guillermopolito@gmail.com> wrote:
Well, replacing:
self logMethodSource: text forMethodWithNode: methodAndNode inCategory: category withStamp: changeStamp notifying: requestor.
by
self logMethodSource: methodAndNode node printString forMethodWithNode: methodAndNode inCategory: category withStamp: changeStamp notifying: requestor.
Works well :). But for sure I smell I'm doing something veeery wrong :S
Has it something to do with using a mutable text instead of a string?
On Sun, Jun 19, 2011 at 3:32 PM, Guillermo Polito <guillermopolito@gmail.com> wrote:
Hi, I have a simple snippet of code which says:
someObject class compile: aMethod classified: someCategory notifying: aRequestor.
where aRequestor is a PluggableTextMorph.
Actually, when I try to compile a method with a temp var, letting the compiler notify me when a temp var is needed, I always see the final CompiledMethod with the wrong source. For example, compiling
someMethod ^someTemp
Is correctly updated to be
someMethod | someTemp | ^someTemp
But, after the compilation process, when I get the compiled method
source,
It just have
someMethod ^someTemp
Debugging, I ended up in
ClassDescriptioncompile: text classified: category withStamp: changeStamp notifying: requestor logSource: logSource | methodAndNode | methodAndNode := self compile: text asString classified: category notifying: requestor trailer: self defaultMethodTrailer ifFail: [^nil]. logSource ifTrue: [ self logMethodSource: text forMethodWithNode: methodAndNode inCategory: category withStamp: changeStamp notifying: requestor. ]. self addAndClassifySelector: methodAndNode selector withMethod: methodAndNode method inProtocol: category notifying: requestor. self instanceSide noteCompilationOf: methodAndNode selector meta: self isClassSide. ^ methodAndNode selector
Which is saving as the CompiledMethod source, the original text, not the one which was changed in the PluggableTextMorph and compiled in the methodAndNode object.
Well, I was looking how the Browser works, and I didn't realize the difference... Can someone enlight me?
Thanks, Guille
-- Lukas Renggli www.lukas-renggli.ch
participants (2)
-
Guillermo Polito -
Lukas Renggli