[squeak-dev] [Environments] ScriptEncoder>>associationForClass problem // globals

H. Hirzel hannes.hirzel at gmail.com
Sat Oct 14 17:13:13 UTC 2017


P.S. You can download an example home.pr project from the links given in

http://wiki.squeak.org/squeak/6531

On 10/14/17, H. Hirzel <hannes.hirzel at gmail.com> wrote:
> Hello
>
> after loading a Etoys project into a most recent trunk image
> incrementing a tile value actually generates an updated script which
> is to be compiled.
>
> Recompiling the script causes an error in
>
>         ScriptEncoder>>associationForClass
>
> 	    | assoc |
> 	    assoc := self environment associationAt: cue getClass name ifAbsent:
> [nil].
> 	    ^assoc value == cue getClass
> 		   ifTrue: [assoc]
> 		   ifFalse: [Association new value: cue getClass]
>
>
> Replacing
>
> 	    assoc := self environment associationAt: cue getClass name ifAbsent:
> [nil].
>
> with
>
> 	    assoc := self environment globals associationAt: cue getClass
> name ifAbsent: [nil].
>
>
> Made the script to work but errors later on came up at the same place
> for other reasons. In particular it was not possible to commit the
> changed 'Compiler' package to the inbox.
>
> Do you have any suggestions how to deal with this problem?
>
> Kind regards
> Hannes
>
>
> ----------------------------------------------------
> The use case in details
> ----------------------------------------------------
>
> I drop an Etoys project into a fully updated trunk image.
>
>
> If I click an arrow the following message is sent to aTileMorph
>
>            TileMorph>>arrowAction:
>
> If it is a number a new value is set, for example
>
>
>           aTileMorph literal: 9
>
>
>           TileMorph>>literal
>
> is
>
>          TileMorph>>literal: anObject
>
> 	        literal := anObject.
> 	        self updateLiteralLabel.
> 	        self acceptNewLiteral.		"Show that we are out of date,
> install is needed"
>
> #acceptNewLiteral looks for the topScript, i.e. the top morph
> containing the tiles
>
>
> then it calls
>
>          topScript installWithNewLiteral
>
>
> The topScript is a "ScriptEditor for #script1 player: Car"
>
>
>         ScriptEditorMorph>>installWithNewLiteral
>
>         	self removeSpaces.
> 	        scriptName ifNotNil:
> 		    [playerScripted ifNotNil:
>                         [playerScripted acceptScript: self topEditor
> for:  scriptName]]
>
>
> playerScripted is aPlayer (Model subclass: #Player)
>
> In
>       playerScripted acceptScript: self topEditor for:  scriptName
>
> the playerScripted gets a node (class MethodNode) from aScriptEditorMorph
>
> The node is told to #generate: the method for aCompiledMethodTrailer
> which has the data
>
>
> 'script1
> 	(self color: (Color r: 0.419 g: 0.581 b: 1) sees: (Color r: 0.936 g:
> 0.936 b: 0.936))
> 		ifFalse: [self turn: 160 + 40 random].
> 	self forward: 9.
> 	self turn: 1.
> 	self bounce: ''silence'''
>
> The node in turn asks aScriptEncoder
>
>
>        generateMethodOfClass: aCompiledMethodClass trailer: trailer
> from: methodNode
>
>
> aScriptEncoder asks
>
>        self allLiterals
>
> and within that
>
>
>         self associationForClass
>
>
>
>         ScriptEncoder>>associationForClass
> 	    | assoc |
> 	    assoc := self environment associationAt: cue getClass name ifAbsent:
> [nil].
> 	    ^assoc value == cue getClass
> 		   ifTrue: [assoc]
> 		   ifFalse: [Association new value: cue getClass]
>
>
> This is the place where the code breaks
>
>              cue getClass
>
> is
>              Player140132117123
>
>
>              self environment
>
> is
>              SmalltalkImage
>
>
> First a change from
>
>
>       	    assoc := self environment associationAt: cue getClass name
> ifAbsent: [nil].
>
> to
>
>     	    assoc := self environment globals associationAt: cue getClass
> name ifAbsent: [nil].
>
> worked after adding in addition
>
>
> I could increment and decrement values in a tile.
>
>
> However it was not possible to commit the changes to the inbox. An
> error message appeared at the same place.
>


More information about the Squeak-dev mailing list