'From etoys2.1 of 26 July 2007 [latest update: #1596] on 7 September 2007 at 2:25:49 pm'! "Change Set: SISSFuncTiles-yo Date: 7 September 2007 Author: Yoshiki Ohshima Make FunctionTiles work with SISS file format."! !FunctionTile methodsFor: 'code generation' stamp: 'yo 9/7/2007 13:51'! 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. ! ! !ScriptEditorMorphBuilder methodsFor: 'reconstituting scripting tiles ' stamp: 'yo 9/7/2007 14:08'! functionSend: sexp with: rcvr with: realSel | p | p _ FunctionTile new. p operator: realSel pad: rcvr. ^ p. ! ! !ScriptEditorMorphBuilder methodsFor: 'reconstituting scripting tiles ' stamp: 'yo 9/7/2007 14:02'! send: sexp | rcvr type selNode realSel val p argType | rcvr _ self fromSexp: sexp elements second. type _ sexp attributeAt: #type ifAbsent: ['#Player']. selNode _ sexp elements first. realSel _ selNode attributeAt: #getter ifAbsent: []. realSel ifNotNil: [ realSel _ Utilities getterSelectorFor: realSel. (rcvr isMemberOf: PhraseTileMorph) ifFalse: [rcvr bePossessive]. ] ifNil: [ realSel _ (selNode attributeAt: #selector) asSymbol. "realSel ifNil: [self error: '']." ]. (#(getAngleTo: bounceOn: getDistanceTo: getPatchValueIn: getTurtleOf: getUphillIn: getRedComponentIn: getGreenComponentIn: getBlueComponentIn:) includes: realSel) ifTrue: [ ^ self specialKedamaSend: sexp with: rcvr with: realSel ]. (#(color:sees:) includes: realSel) ifTrue: [ ^ self specialSend: sexp with: rcvr with: realSel ]. ((ScriptingSystem tableOfNumericFunctions collect: [:e | e second]) includes: realSel) ifTrue: [ ^ self functionSend: sexp with: rcvr with: realSel ]. p _ PhraseTileMorph new setOperator: realSel type: type asSymbol rcvrType: #Player argType: #Number. p justGrabbedFromViewer: false. p submorphs first addMorph: rcvr. p submorphs first setType: (sexp elements second attributeAt: #type ifAbsent: ['Number']) asSymbol. sexp elements size = 2 ifTrue: [ (p resultType == #Number and: [p submorphs second isMemberOf: TileMorph]) ifTrue: [ p submorphs second addSuffixArrow. ]. ]. sexp elements size > 2 ifTrue: [ val _ self fromSexp: sexp elements third. argType _ (sexp elements third attributeAt: #type ifAbsent: ['Number']) asSymbol. p submorphs third setType: argType. p submorphs third addMorph: val. (argType == #Number and: [val isMemberOf: TileMorph]) ifTrue: [val addSuffixArrow. (#(#+ #- #* #/ #'//' #'\\' #max: #min: #< #'<=' #= #'~=' #> #'>=' #isDivisibleBy:) includes: realSel) ifFalse: [p submorphs second addRetractArrowAnyway]. ]. ]. ^ p. ! ! !ScriptEditorMorphBuilder methodsFor: 'reconstituting scripting tiles ' stamp: 'yo 9/7/2007 14:07'! specialSend: sexp with: rcvr with: realSel | p val | sexp elements size > 2 ifTrue: [ val _ self fromSexp: sexp elements third. ]. realSel == #color:sees: ifTrue: [ p _ PhraseTileMorph new setOperator: #+ type: #Boolean rcvrType: #Player argType: #Color. "temp dummy" p justGrabbedFromViewer: false. p submorphs first addMorph: rcvr. p submorphs second delete. p addMorph: (ColorSeerTile new showPalette: false; colorSwatchColor: (val colorSwatch color)) behind: p submorphs first. p submorphs last setType: (sexp elements fourth attributeAt: #type ifAbsent: ['Number']) asSymbol. p submorphs last addMorph: (self fromSexp: sexp elements fourth). ^ p. ]. ! !