On Mon, Jul 18, 2011 at 2:40 PM, Sean P. DeNigris <[email protected]>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

Attachment: hasLiteral.st
Description: Binary data

Reply via email to