The Trunk: EToys-eem.305.mcz

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

The Trunk: EToys-eem.305.mcz

commits-2
Eliot Miranda uploaded a new version of EToys to project The Trunk:
http://source.squeak.org/trunk/EToys-eem.305.mcz

==================== Summary ====================

Name: EToys-eem.305
Author: eem
Time: 12 July 2017, 5:17:21.792431 pm
UUID: 6180f254-4baa-41f9-a31d-adb1fa208d77
Ancestors: EToys-eem.304

Fix the ScriptCompiler's evaluate:in:to:notifying:ifFail:logged: method for non-cil contexts (e.g. the ContextVariablesInspector bottom right pane in the debugger).  The old code used aContext methodClass which would exclude the variables of a receiver whose class inherited the method, rather than implemented it directly (e.g. debug (1@2) printString and in the context inspector on the Point(Object)>>printString activation try and evaluate x@y.  Using methodClass excludes Point's inst vars.

At the same time eliminate its reliance on DoIt: and DoItIn:

=============== Diff against EToys-eem.304 ===============

Item was changed:
  ----- Method: ScriptCompiler>>evaluate:in:to:notifying:ifFail:logged: (in category 'as yet unclassified') -----
  evaluate: textOrStream in: aContext to: receiver notifying: aRequestor ifFail: failBlock logged: logFlag
  "Compiles the sourceStream into a parse tree, then generates code into a
  method. This method is then installed in the receiver's class so that it
  can be invoked. In other words, if receiver is not nil, then the text can
  refer to instance variables of that receiver (the Inspector uses this). If
  aContext is not nil, the text can refer to temporaries in that context (the
  Debugger uses this). If aRequestor is not nil, then it will receive a
+ notify:at: message before the attempt to evaluate is aborted."
- notify:at: message before the attempt to evaluate is aborted. Finally, the
- compiled method is invoked from here as DoIt or (in the case of
- evaluation in aContext) DoItIn:. The method is subsequently removed
- from the class, but this will not get done if the invocation causes an
- error which is terminated. Such garbage can be removed by executing:
- Smalltalk allBehaviorsDo: [:cl | cl removeSelector: #DoIt; removeSelector:
- #DoItIn:]."
 
+ | methodNode method value toLog itsSelectionString itsSelection |
- | class methodNode method value selector toLog itsSelectionString itsSelection |
- class := (aContext == nil ifTrue: [receiver] ifFalse: [aContext receiver]) class.
  methodNode :=  self parser new
  parse: textOrStream readStream
+ class: (self classForReceiver: receiver context: aContext)
- class: class
  noPattern: true
  context: aContext
  notifying: aRequestor
+ ifFail: [^ failBlock value]
+ for: receiver.
+ method := methodNode generate: (CompiledMethodTrailer empty sourceCode: methodNode sourceText; yourself).
- ifFail: [^ failBlock value] for: receiver.
- method := methodNode generate: (CompiledMethodTrailer empty sourceCode: (methodNode sourceText); yourself).
  self interactive ifTrue:
  [method := method copyWithTempNames: methodNode tempNames].
 
+ value := receiver
+ withArgs: (aContext ifNil: [#()] ifNotNil: [{aContext}])
+ executeMethod: method.
- selector := aContext isNil
- ifTrue: [#DoIt]
- ifFalse: [#DoItIn:].
- class addSelectorSilently: selector withMethod: method.
- value := aContext isNil
- ifTrue: [receiver DoIt]
- ifFalse: [receiver DoItIn: aContext].
- InMidstOfFileinNotification signal
- ifFalse: [class basicRemoveSelector: selector].
  logFlag ifTrue:
  [toLog := ((aRequestor respondsTo: #selection)  and:
  [(itsSelection := aRequestor selection) notNil] and:
  [(itsSelectionString := itsSelection asString) isEmptyOrNil not] )
  ifTrue:
  [itsSelectionString]
  ifFalse:
  [textOrStream readStream contents].
 
  SystemChangeNotifier uniqueInstance evaluated: toLog context: aContext].
 
+ ^value!
- ^ value!