Why does CompiledMethod>>hasLiteral: use ==

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

Why does CompiledMethod>>hasLiteral: use ==

Sean P. DeNigris
Administrator
I tried:

    aMethod hasLiteral: #DateAndTime->DateAndTime

and got false, even though an "=" literal is indeed there.

Why doesn't #hasLiteral: use #=?

Thanks.
Sean
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Why does CompiledMethod>>hasLiteral: use ==

Eliot Miranda-2


On Mon, Jul 18, 2011 at 2:40 PM, Sean P. DeNigris <[hidden email]> wrote:
I tried:

   aMethod hasLiteral: #DateAndTime->DateAndTime

and got false, even though an "=" literal is indeed there.

Why doesn't #hasLiteral: use #=?

Well, the tricky thing with literals is that 0.0 = 0 and 'one' = #one but these are all different literals.  That said, it looks like a bug to me.  It should surely be 

!CompiledMethod methodsFor: 'literals' stamp: 'eem 7/19/2011 09:19'!
hasLiteral: literal
| litClass lit |
"Answer whether the receiver references the argument, literal."
litClass := literal class.
2 to: self numLiterals - 1 do: "exclude superclass + selector/properties"
[:index |
lit := self objectAt: index.
(litClass == lit class and: [literal = lit]) ifTrue: [^true]].
^false! !
!Array methodsFor: 'private' stamp: 'eem 7/19/2011 09:20'!
hasLiteral: literal
"Answer true if literal is identical to any literal in this array, even 
if imbedded in further array structure. This method is only intended 
for private use by CompiledMethod hasLiteralSymbol:"

| litClass lit |
litClass := literal class.
1 to: self size do: 
[:index | 
(litClass == (lit := self at: index) class
and: [literal = lit]) ifTrue: [^true].
(Array == lit class
and: [lit hasLiteral: literal]) ifTrue: [^true]].
^false! !

I've run all the tests in a trunk 4.2 before and after and making the above change makes no difference.  So I think I'll go ahead and commit the change to Squeak trunk.  I'll leave the Pharo folks to apply it there-in.  Files attached.


Thanks.
Sean

--
View this message in context: http://forum.world.st/Why-does-CompiledMethod-hasLiteral-use-tp3676573p3676573.html
Sent from the Pharo Smalltalk mailing list archive at Nabble.com.




--
best,
Eliot


hasLiteral.st (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Why does CompiledMethod>>hasLiteral: use ==

Sean P. DeNigris
Administrator
Eliot Miranda-2 wrote
I've run all the tests in a trunk 4.2 before and after and making the above
change makes no difference.  So I think I'll go ahead and commit the change
to Squeak trunk.  I'll leave the Pharo folks to apply it there-in.  Files
attached.
I created Pharo issue #4538 and attached the file.

SD
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Why does CompiledMethod>>hasLiteral: use ==

Stéphane Ducasse
tx for this good reflex!

Stef

>
> Eliot Miranda-2 wrote:
>>
>> I've run all the tests in a trunk 4.2 before and after and making the
>> above
>> change makes no difference.  So I think I'll go ahead and commit the
>> change
>> to Squeak trunk.  I'll leave the Pharo folks to apply it there-in.  Files
>> attached.
>>
>
> I created Pharo issue #4538 and attached the file.
>
> SD
>
> --
> View this message in context: http://forum.world.st/Why-does-CompiledMethod-hasLiteral-use-tp3676573p3679033.html
> Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
>