Bert Freudenberg uploaded a new version of EToys to project The Trunk:
http://source.squeak.org/trunk/EToys-bf.95.mcz ==================== Summary ==================== Name: EToys-bf.95 Author: bf Time: 11 April 2013, 3:27:51.906 pm UUID: 205ad059-c5b8-4df9-b599-96a156e03a7f Ancestors: EToys-bf.94 * make project loading work * no more undeclared globals =============== Diff against EToys-bf.94 =============== Item was added: + Object subclass: #EToyExpressionTransformer2 + instanceVariableNames: 'method stack inputQueue encoder' + classVariableNames: '' + poolDictionaries: '' + category: 'Etoys-Support'! Item was added: + ----- Method: EToyExpressionTransformer2>>inputQueueEmpty (in category 'all') ----- + inputQueueEmpty + + ^ inputQueue isEmpty! Item was added: + ----- Method: EToyExpressionTransformer2>>inputQueueNext (in category 'all') ----- + inputQueueNext + "It would do the check of selector node that #inputQueuePeek does, but not necessary." + + ^ inputQueue removeFirst. + ! Item was added: + ----- Method: EToyExpressionTransformer2>>inputQueuePeek (in category 'all') ----- + inputQueuePeek + + | v | + inputQueue size > 0 ifFalse: [^ nil]. + v := inputQueue first. + (v isMemberOf: SelectorNode) ifTrue: [^ v key asSymbol]. + ^ v. + ! Item was added: + ----- Method: EToyExpressionTransformer2>>newNodeFromList:encoder: (in category 'all') ----- + newNodeFromList: aList encoder: e + + encoder := e. + inputQueue := aList asOrderedCollection. + stack := OrderedCollection new: 3. + ! Item was added: + ----- Method: EToyExpressionTransformer2>>precl (in category 'all') ----- + precl + + stack size = 0 ifTrue: [^ 0]. + stack size = 1 ifTrue: [^ self precl: stack last]. + stack last isSymbol ifTrue: [^ 0]. + ^ self precl: (stack at: stack size - 1). + ! Item was added: + ----- Method: EToyExpressionTransformer2>>precl: (in category 'all') ----- + precl: anObject + + (#(#max: #min:) includes: anObject) ifTrue: [^ 1]. + (#(#+ #-) includes: anObject) ifTrue: [^ 2]. + (#(#* #/ #// #\\) includes: anObject) ifTrue: [^ 3]. + ^ 0. + ! Item was added: + ----- Method: EToyExpressionTransformer2>>precr: (in category 'all') ----- + precr: anObject + + anObject ifNil: [^ 0]. + (#(#max: #min:) includes: anObject) ifTrue: [^ 1]. + (#(#+ #-) includes: anObject) ifTrue: [^ 2]. + (#(#* #/ #// #\\) includes: anObject) ifTrue: [^ 3]. + ^ 4. + ! Item was added: + ----- Method: EToyExpressionTransformer2>>reduceOnStack (in category 'all') ----- + reduceOnStack + + | list left sel right m | + list := stack removeLast: 3. + left := list at: 1. + sel := list at: 2. + right := list at: 3. + + m := MessageNode new + receiver: left + selector: sel + arguments: (Array with: right) + precedence: (sel precedence) + from: encoder + sourceRange: nil. + stack addLast: m. + ! Item was added: + ----- Method: EToyExpressionTransformer2>>transform (in category 'all') ----- + transform + + | leftPrec rightPrec n | + [(self inputQueueEmpty and: [stack size = 1]) not] whileTrue: [ + leftPrec := self precl. + rightPrec := self precr: (n := self inputQueuePeek). + leftPrec >= rightPrec ifTrue: [ + self reduceOnStack. + ] ifFalse: [ + self inputQueueNext. + stack addLast: n. + ]. + ]. + ^ stack last. + ! Item was removed: - ----- Method: FunctionTile>>sexpWith: (in category 'code generation') ----- - sexpWith: dictionary - | n elements sel | - sel := submorphs first operatorOrExpression. - n := SExpElement keyword: #send. - n attributeAt: #type put: ((owner isMemberOf: TilePadMorph) ifTrue: [owner type] ifFalse: ['Number']). - elements := Array with: ((SExpElement keyword: #selector) - attributeAt: #selector put: sel; yourself) - with: (argumentPad sexpWith: dictionary). - n elements: elements. - ^ n. - ! Item was added: + ----- Method: ProjectLoading class>>loadImageSegment:fromDirectory:withProjectView:numberOfFontSubstitutes:substituteFont:mgr: (in category '*etoys') ----- + loadImageSegment: morphOrList fromDirectory: aDirectoryOrNil withProjectView: existingView numberOfFontSubstitutes: numberOfFontSubstitutes substituteFont: substituteFont mgr: mgr + + | proj projectsToBeDeleted ef f | + (f := (Flaps globalFlapTabWithID: 'Navigator' translated)) ifNotNil: [f hideFlap]. + proj := morphOrList arrayOfRoots + detect: [:mm | mm isKindOf: Project] + ifNone: [^ nil]. + numberOfFontSubstitutes > 0 ifTrue: [ + proj projectParameterAt: #substitutedFont put: substituteFont]. + ef := proj projectParameterAt: #eToysFont. + (ef isNil or: [ef ~= substituteFont familySizeFace]) ifTrue: [ + proj projectParameterAt: #substitutedFont put: substituteFont. + ]. + proj projectParameters at: #MultiSymbolInWrongPlace put: false. + "Yoshiki did not put MultiSymbols into outPointers in older images!!" + morphOrList arrayOfRoots do: [:obj | + obj fixUponLoad: proj seg: morphOrList "imageSegment"]. + (proj projectParameters at: #MultiSymbolInWrongPlace) ifTrue: [ + morphOrList arrayOfRoots do: [:obj | (obj isKindOf: Set) ifTrue: [obj rehash]]]. + + proj resourceManager: mgr. + "proj versionFrom: preStream." + proj lastDirectory: aDirectoryOrNil. + proj setParent: Project current. + projectsToBeDeleted := OrderedCollection new. + existingView == #none ifFalse: [ + self makeExistingView: existingView project: proj projectsToBeDeleted: projectsToBeDeleted]. + ChangeSorter allChangeSets add: proj changeSet. + Project current projectParameters + at: #deleteWhenEnteringNewProject + ifPresent: [ :ignored | + projectsToBeDeleted add: Project current. + Project current removeParameter: #deleteWhenEnteringNewProject. + ]. + projectsToBeDeleted isEmpty ifFalse: [ + proj projectParameters + at: #projectsToBeDeleted + put: projectsToBeDeleted. + ]. + proj removeParameter: #eToysFont. + ^ proj! Item was changed: ----- Method: ProjectLoading class>>loadName:stream:fromDirectory:withProjectView:clearOriginFlag: (in category '*etoys') ----- loadName: aFileName stream: preStream fromDirectory: aDirectoryOrNil withProjectView: existingView clearOriginFlag: clearOriginFlag "Reconstitute a Morph from the selected file, presumed to be represent a Morph saved via the SmartRefStream mechanism, and open it in an appropriate Morphic world." | morphOrList archive mgr substituteFont numberOfFontSubstitutes resultArray anObject project manifests dict | (self checkStream: preStream) ifTrue: [^ self]. ProgressNotification signal: '0.2'. archive := preStream isZipArchive ifTrue:[ZipArchive new readFrom: preStream] ifFalse:[nil]. manifests := (archive membersMatching: '*manifest'). (manifests size = 1 and: [((dict := self parseManifest: manifests first contents) at: 'Project-Format' ifAbsent: []) = 'S-Expression']) ifTrue: [^ self loadSexpProjectDict: dict stream: preStream fromDirectory: aDirectoryOrNil withProjectView: existingView]. morphOrList := self morphOrList: aFileName stream: preStream fromDirectory: aDirectoryOrNil archive: archive. morphOrList ifNil: [^ self]. ProgressNotification signal: '0.4'. resultArray := self fileInName: aFileName archive: archive morphOrList: morphOrList. anObject := resultArray first. numberOfFontSubstitutes := resultArray second. substituteFont := resultArray third. mgr := resultArray fourth. preStream close. ProgressNotification signal: '0.7'. "the hard part is over" (anObject isKindOf: ImageSegment) ifTrue: [ project := self loadImageSegment: anObject fromDirectory: aDirectoryOrNil withProjectView: existingView numberOfFontSubstitutes: numberOfFontSubstitutes substituteFont: substituteFont mgr: mgr. project noteManifestDetailsIn: dict. project removeParameter: #sugarProperties. + Smalltalk at: #SugarPropertiesNotification ifPresent: [:notification | + notification signal ifNotNilDo: [:props | + project keepSugarProperties: props monitor: true]]. - SugarPropertiesNotification signal ifNotNilDo: [:props | - project keepSugarProperties: props monitor: true]. clearOriginFlag ifTrue: [project forgetExistingURL]. ProgressNotification signal: '0.8'. ^ project ].! Item was added: + ----- Method: ProjectLoading class>>makeExistingView:project:projectsToBeDeleted: (in category '*etoys') ----- + makeExistingView: existingView project: proj projectsToBeDeleted: projectsToBeDeleted + existingView ifNil: [ + Smalltalk isMorphic ifTrue: [ + proj createViewIfAppropriate. + ] ifFalse: [ + ChangeSorter allChangeSets add: proj changeSet. + ProjectView openAndEnter: proj. + "Note: in MVC we get no further than the above" + ]. + ] ifNotNil: [ + (existingView project isKindOf: DiskProxy) ifFalse: [ + existingView project changeSet name: + ChangeSet defaultName. + projectsToBeDeleted add: existingView project. + ]. + (existingView owner isSystemWindow) ifTrue: [ + existingView owner model: proj + ]. + existingView project: proj. + ]. + ! |
Free forum by Nabble | Edit this page |