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

David T. Lewis lewis at mail.msen.com
Sat Oct 14 23:28:01 UTC 2017


Thanks Levente, hopefully fixed in EToys-dtl.310

Dave

On Sat, Oct 14, 2017 at 06:34:23PM -0400, David T. Lewis wrote:
> The current version of ScriptEncoder>>init:context:notifying: (tfel 8/2/2016)
> sets the environment to "class environment" but the current version in trunk
> (tfel 9/30/2016) sets it to "Smalltalk".
> 
> The change was introduced here:
> 
>    Name: EToys-tfel.266
>    Author: tfel
>    Time: 30 September 2016, 11:38:29.998245 am
>    UUID: 984ecc63-aae1-7445-b5ae-8b0f1a83be61
>    Ancestors: EToys-tfel.265
>    
>    for now, always compile scripts in the global environment.
> 
> 
> Maybe the prior version was better? Or should it have been changed from
> "class environment" to "Smalltalk environment" in order to do what was
> originally intended in EToys-tfel.266?
> 
> Dave
> 
> 
> On Sat, Oct 14, 2017 at 11:22:44PM +0200, Levente Uzonyi wrote:
> > The cause of the issue is ScriptEncoder >> #init:context:notifying: 
> > explicitly setting Smalltalk to be the environment instead of Smalltalk 
> > environment.
> > 
> > Levente
> > 
> > On Sat, 14 Oct 2017, H. Hirzel 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