Nicolas Cellier uploaded a new version of EToys to project The Trunk:
http://source.squeak.org/trunk/EToys-nice.438.mcz ==================== Summary ==================== Name: EToys-nice.438 Author: nice Time: 7 April 2021, 8:40:21.068323 pm UUID: d28ff6d4-e638-483f-b11b-7c3a9f5c7283 Ancestors: EToys-mt.437 Nuke usage of #parserClass: because redundant with definition of ScriptCompiler class>>parserClass. Fix evaluate:in:to:notifying:ifFail:logged: (self parser) already answers an instance, (self parser new) fails. Simplify: ScriptCompiler new parserClass new -> ScriptCompiler newParser =============== Diff against EToys-mt.437 =============== Item was removed: - ----- Method: ScriptCompiler>>compile:in:notifying:ifFail: (in category 'as yet unclassified') ----- - compile: textOrStream in: aClass notifying: aRequestor ifFail: failBlock - - self parserClass: ScriptParser. - ^ super compile: textOrStream in: aClass notifying: aRequestor ifFail: failBlock! Item was changed: ----- Method: ScriptCompiler>>compile:in:notifying:ifFail:for: (in category 'as yet unclassified') ----- compile: textOrStream in: aClass notifying: aRequestor ifFail: failBlock for: anInstance "Answer a MethodNode for the argument, textOrStream. If the MethodNode can not be created, notify the argument, aRequestor; if aRequestor is nil, evaluate failBlock instead. The MethodNode is the root of a parse tree. It can be told to generate a CompiledMethod to be installed in the method dictionary of the argument, aClass." - self parserClass: ScriptParser. ^ self parser parse: textOrStream readStream class: aClass noPattern: false context: nil notifying: aRequestor ifFail: [^ failBlock value] for: anInstance. ! 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." | methodNode method value toLog itsSelectionString itsSelection | + methodNode := self parser - methodNode := self parser new parse: textOrStream readStream class: (self classForReceiver: receiver context: aContext) noPattern: true context: aContext notifying: aRequestor 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. 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! Item was changed: ----- Method: TileMorph>>parseNodeWith: (in category '*Etoys-Squeakland-code generation') ----- parseNodeWith: encoder | op playerBearingCode | playerBearingCode := self playerBearingCode. "Must determine whom is scripted for what follows to work; if it's ever nil, we've got trouble" type = #expression ifTrue: + [^ (ScriptCompiler newParser parse: 'xxx ', operatorOrExpression class: UndefinedObject) block statements first]. - [^ (ScriptCompiler new parserClass new parse: 'xxx ', operatorOrExpression class: UndefinedObject) block statements first]. type = #literal ifTrue: [^ encoder encodeLiteral: literal]. type == #objRef ifTrue: [^playerBearingCode == actualObject ifTrue: ["If the object is the method's own 'self' then we MUST, rather than just MAY, put out 'self' rather than the referencer call, though the latter will temporarily work if only one instance of the uniclass exists." ^ encoder encodeVariable: 'self'] ifFalse: [(actualObject isPlayerLike and: [actualObject isSequentialStub]) ifTrue: [ ^ actualObject parseNodeWith: encoder. ] ifFalse: [ ^ encoder encodePlayer: actualObject]]]. type = #operator ifTrue: [op := ((UpdatingOperators includesKey: operatorOrExpression) and: [self precedingTileType = #slotRef]) ifTrue: [UpdatingOperators at: operatorOrExpression] ifFalse: [operatorOrExpression]. ^op isEmpty ifTrue: [self halt.] ifFalse: [^ encoder encodeSelector: (EqualityOperators at: op ifAbsent: [op])]]. ! |
Free forum by Nabble | Edit this page |