How do I replace a call SmalltalkImage>>associationAt:ifAbsent:? (Environments)

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

How do I replace a call SmalltalkImage>>associationAt:ifAbsent:? (Environments)

Hannes Hirzel
Hello

How do I replace a call SmalltalkImage>>associationAt:ifAbsent:?

ScriptEncoder>>associationForClass
        | assoc |
        assoc := self environment associationAt: cue getClass name ifAbsent: [nil].
        ^assoc value == cue getClass
                ifTrue: [assoc]
                ifFalse: [Association new value: cue getClass]



SmalltalkImage>>associationAt: key ifAbsent: aBlock
        "Obsoleted."

        self deprecated: 'Use Smalltalk globals'.
        ^globals associationAt: key ifAbsent: aBlock


A direct replacement does not work.


Kind regards

Hannes

Reply | Threaded
Open this post in threaded view
|

Re: How do I replace a call SmalltalkImage>>associationAt:ifAbsent:? (Environments)

Hannes Hirzel
Note: ScriptEncoder belongs to Etoys

EncoderForV3PlusClosures subclass: #ScriptEncoder
        instanceVariableNames: 'referenceObject'
        classVariableNames: ''
        poolDictionaries: ''
        category: 'Etoys-Squeakland-System-Compiler'

Maybe the fix has to be done earlier in the method #allLiterals

    #allLiterals
calls
    #associationForClass


allLiterals
        addedSelectorAndMethodClassLiterals ifFalse:
                [addedSelectorAndMethodClassLiterals := true.
                "Put the optimized selectors in literals so as to browse senders more easily"
                optimizedSelectors := optimizedSelectors reject: [:e| literalStream
originalContents hasLiteral: e].
                optimizedSelectors isEmpty ifFalse: [
                        "Use one entry per literal if enough room, else make anArray"
                        literalStream position + optimizedSelectors size + 2 >= self maxNumLiterals
                                ifTrue: [self litIndex: optimizedSelectors asArray]
                                ifFalse: [optimizedSelectors do: [:e | self litIndex: e]]].
                "Add a slot for selector or MethodProperties"
                self litIndex: nil.
                self litIndex: self associationForClass].
        ^literalStream contents


On 10/9/17, H. Hirzel <[hidden email]> wrote:

> Hello
>
> How do I replace a call SmalltalkImage>>associationAt:ifAbsent:?
>
> ScriptEncoder>>associationForClass
> | assoc |
> assoc := self environment associationAt: cue getClass name ifAbsent:
> [nil].
> ^assoc value == cue getClass
> ifTrue: [assoc]
> ifFalse: [Association new value: cue getClass]
>
>
>
> SmalltalkImage>>associationAt: key ifAbsent: aBlock
> "Obsoleted."
>
> self deprecated: 'Use Smalltalk globals'.
> ^globals associationAt: key ifAbsent: aBlock
>
>
> A direct replacement does not work.
>
>
> Kind regards
>
> Hannes
>

Reply | Threaded
Open this post in threaded view
|

Re: How do I replace a call SmalltalkImage>>associationAt:ifAbsent:? (Environments)

Levente Uzonyi
In reply to this post by Hannes Hirzel
On Mon, 9 Oct 2017, H. Hirzel wrote:

> Hello
>
> How do I replace a call SmalltalkImage>>associationAt:ifAbsent:?

What image do you use? The receiver of #associationAt:ifAbsent: must not
be a SmalltalkImage but an Environment.

Levente

>
> ScriptEncoder>>associationForClass
> | assoc |
> assoc := self environment associationAt: cue getClass name ifAbsent: [nil].
> ^assoc value == cue getClass
> ifTrue: [assoc]
> ifFalse: [Association new value: cue getClass]
>
>
>
> SmalltalkImage>>associationAt: key ifAbsent: aBlock
> "Obsoleted."
>
> self deprecated: 'Use Smalltalk globals'.
> ^globals associationAt: key ifAbsent: aBlock
>
>
> A direct replacement does not work.
>
>
> Kind regards
>
> Hannes

Reply | Threaded
Open this post in threaded view
|

Re: How do I replace a call SmalltalkImage>>associationAt:ifAbsent:? (Environments)

Hannes Hirzel
Squeak 6.0a trunk image.
With fix EToys-hjh.308.mcz loaded (please commit it to trunk)

The I dropped an Etoys example pr project file from
    http://squeakland.org/tutorials/demos/
onto the desktop.

Unfortunately I do not recall the details which action caused the
walkback window with the

      SmalltalkImage>>associationAt:ifAbsent:

problem to appear.

I'll report later if it occurs again.

--Hannes

On 10/9/17, Levente Uzonyi <[hidden email]> wrote:

> On Mon, 9 Oct 2017, H. Hirzel wrote:
>
>> Hello
>>
>> How do I replace a call SmalltalkImage>>associationAt:ifAbsent:?
>
> What image do you use? The receiver of #associationAt:ifAbsent: must not
> be a SmalltalkImage but an Environment.
>
> Levente
>
>>
>> ScriptEncoder>>associationForClass
>> | assoc |
>> assoc := self environment associationAt: cue getClass name ifAbsent:
>> [nil].
>> ^assoc value == cue getClass
>> ifTrue: [assoc]
>> ifFalse: [Association new value: cue getClass]
>>
>>
>>
>> SmalltalkImage>>associationAt: key ifAbsent: aBlock
>> "Obsoleted."
>>
>> self deprecated: 'Use Smalltalk globals'.
>> ^globals associationAt: key ifAbsent: aBlock
>>
>>
>> A direct replacement does not work.
>>
>>
>> Kind regards
>>
>> Hannes
>
>

Reply | Threaded
Open this post in threaded view
|

Re: How do I replace a call SmalltalkImage>>associationAt:ifAbsent:? (Environments)

Hannes Hirzel
Found the use case.

Steps to reproduce it in your Squeak 6.0a trunk image:

a) In a regular MorphicProject choose 'show shared flaps' (right-click
world menu in my setup)
b) from the 'widgets' flap bring out a paint tool
c) draw a sketch / select 'keep'
d) bring up the halos of the sketch
e) choose the blue 'viewer' icon
f) drag out the 'sketch turn by 5' tile from the tiles of the sketch

you get the error message

SmalltalkImage>>#associationAt:ifAbsent: has been deprecated. Use
Smalltalk globals



On 10/9/17, H. Hirzel <[hidden email]> wrote:

> Squeak 6.0a trunk image.
> With fix EToys-hjh.308.mcz loaded (please commit it to trunk)
>
> The I dropped an Etoys example pr project file from
>     http://squeakland.org/tutorials/demos/
> onto the desktop.
>
> Unfortunately I do not recall the details which action caused the
> walkback window with the
>
>       SmalltalkImage>>associationAt:ifAbsent:
>
> problem to appear.
>
> I'll report later if it occurs again.
>
> --Hannes
>
> On 10/9/17, Levente Uzonyi <[hidden email]> wrote:
>> On Mon, 9 Oct 2017, H. Hirzel wrote:
>>
>>> Hello
>>>
>>> How do I replace a call SmalltalkImage>>associationAt:ifAbsent:?
>>
>> What image do you use? The receiver of #associationAt:ifAbsent: must not
>> be a SmalltalkImage but an Environment.
>>
>> Levente
>>
>>>
>>> ScriptEncoder>>associationForClass
>>> | assoc |
>>> assoc := self environment associationAt: cue getClass name ifAbsent:
>>> [nil].
>>> ^assoc value == cue getClass
>>> ifTrue: [assoc]
>>> ifFalse: [Association new value: cue getClass]
>>>
>>>
>>>
>>> SmalltalkImage>>associationAt: key ifAbsent: aBlock
>>> "Obsoleted."
>>>
>>> self deprecated: 'Use Smalltalk globals'.
>>> ^globals associationAt: key ifAbsent: aBlock
>>>
>>>
>>> A direct replacement does not work.
>>>
>>>
>>> Kind regards
>>>
>>> Hannes
>>
>>
>



Squeak6.0a_error_after_dragging_out_a_tile_Screenshot_2017-10-09.png (197K) Download Attachment