VariableEnvironment

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

VariableEnvironment

Steve Alan Waring
Hi,

Its obscure but should VariableEnvironment>>includesClass: be

(super includesClass: aClass) ifFalse: [^false].
(instanceVariables includesKey: aClass name "added #name") ifTrue: [^true].
(classVariables includesKey: aClass name "added #name") ifTrue: [^true].
^((self selectorCacheFor: aClass)
detect: [:each | self includesSelector: each in: aClass]
ifNone: [nil]) notNil

Also, is there a way I can detect that a compiledMethod uses the ##()
mechanism?

Thanks,
Steve


Reply | Threaded
Open this post in threaded view
|

Re: VariableEnvironment

Chris Uppal-3
Steve Waring wrote:

> Also, is there a way I can detect that a compiledMethod uses the ##()
> mechanism?

It's only a start, but the RB parses them into instances of
StOptimizedExpression (alias RBOptimizedExpression).

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: VariableEnvironment

Blair McGlashan
In reply to this post by Steve Alan Waring
"Steve Waring" <[hidden email]> wrote in message
news:[hidden email]...
> Hi,
>
> Its obscure but should VariableEnvironment>>includesClass: be
>
> (super includesClass: aClass) ifFalse: [^false].
> (instanceVariables includesKey: aClass name "added #name") ifTrue:
[^true].
> (classVariables includesKey: aClass name "added #name") ifTrue: [^true].
> ^((self selectorCacheFor: aClass)
> detect: [:each | self includesSelector: each in: aClass]
> ifNone: [nil]) notNil

That's one for John Brant really, but judging from the rest of the class I
think you must be right.

>
> Also, is there a way I can detect that a compiledMethod uses the ##()
> mechanism?

You'll have to search the parse trees.

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Re: VariableEnvironment

John Brant
"Blair McGlashan" <[hidden email]> wrote in message
news:[hidden email]...

> "Steve Waring" <[hidden email]> wrote in message
> news:[hidden email]...
> > Hi,
> >
> > Its obscure but should VariableEnvironment>>includesClass: be
> >
> > (super includesClass: aClass) ifFalse: [^false].
> > (instanceVariables includesKey: aClass name "added #name") ifTrue:
> [^true].
> > (classVariables includesKey: aClass name "added #name") ifTrue: [^true].
> > ^((self selectorCacheFor: aClass)
> > detect: [:each | self includesSelector: each in: aClass]
> > ifNone: [nil]) notNil
>
> That's one for John Brant really, but judging from the rest of the class I
> think you must be right.

The code was running to fast, so we needed to slow it down :). Actually, I
believe that the code was originally an optimization, so we didn't need to
test the last step. I'm guessing that we changed the representation and also
sped up the last step, so that the "optimization" is no longer necessary.
You should be able to remove the two lines, since obviously the
"optimization" isn't needed, or you can change it to send the #name message.


John Brant