Importer-Exporter.js 118 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516
  1. (function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Importer-Exporter');
  3. smalltalk.addClass('AbstractExporter', smalltalk.Object, [], 'Importer-Exporter');
  4. smalltalk.AbstractExporter.comment="I am an abstract exporter for Amber source code.";
  5. smalltalk.addMethod(
  6. smalltalk.method({
  7. selector: "chunkEscape:",
  8. category: 'convenience',
  9. fn: function (aString){
  10. var self=this;
  11. return smalltalk.withContext(function($ctx1) {
  12. var $1;
  13. $1=_st(_st(aString)._replace_with_("!","!!"))._trimBoth();
  14. return $1;
  15. }, function($ctx1) {$ctx1.fill(self,"chunkEscape:",{aString:aString},smalltalk.AbstractExporter)})},
  16. args: ["aString"],
  17. source: "chunkEscape: aString\x0a\x09\x22Replace all occurrences of ! with !! and trim at both ends.\x22\x0a\x0a\x09^(aString replace: '!' with: '!!') trimBoth",
  18. messageSends: ["trimBoth", "replace:with:"],
  19. referencedClasses: []
  20. }),
  21. smalltalk.AbstractExporter);
  22. smalltalk.addMethod(
  23. smalltalk.method({
  24. selector: "classNameFor:",
  25. category: 'convenience',
  26. fn: function (aClass){
  27. var self=this;
  28. return smalltalk.withContext(function($ctx1) {
  29. var $2,$3,$1;
  30. $2=_st(aClass)._isMetaclass();
  31. if(smalltalk.assert($2)){
  32. $1=_st(_st(_st(aClass)._instanceClass())._name()).__comma(" class");
  33. } else {
  34. $3=_st(aClass)._isNil();
  35. if(smalltalk.assert($3)){
  36. $1="nil";
  37. } else {
  38. $1=_st(aClass)._name();
  39. };
  40. };
  41. return $1;
  42. }, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},smalltalk.AbstractExporter)})},
  43. args: ["aClass"],
  44. source: "classNameFor: aClass\x0a\x09^aClass isMetaclass\x0a\x09\x09ifTrue: [ aClass instanceClass name, ' class' ]\x0a\x09\x09ifFalse: [\x0a\x09\x09\x09aClass isNil\x0a\x09\x09\x09\x09ifTrue: [ 'nil' ]\x0a\x09\x09\x09\x09ifFalse: [ aClass name ] ]",
  45. messageSends: ["ifTrue:ifFalse:", ",", "name", "instanceClass", "isNil", "isMetaclass"],
  46. referencedClasses: []
  47. }),
  48. smalltalk.AbstractExporter);
  49. smalltalk.addMethod(
  50. smalltalk.method({
  51. selector: "recipe",
  52. category: 'fileOut',
  53. fn: function (){
  54. var self=this;
  55. return smalltalk.withContext(function($ctx1) {
  56. self._subclassResponsibility();
  57. return self}, function($ctx1) {$ctx1.fill(self,"recipe",{},smalltalk.AbstractExporter)})},
  58. args: [],
  59. source: "recipe\x0a\x09\x22Recipe to export a given package.\x22\x0a\x0a\x09self subclassResponsibility",
  60. messageSends: ["subclassResponsibility"],
  61. referencedClasses: []
  62. }),
  63. smalltalk.AbstractExporter);
  64. smalltalk.AbstractExporter.klass.iVarNames = ['default'];
  65. smalltalk.addMethod(
  66. smalltalk.method({
  67. selector: "default",
  68. category: 'instance creation',
  69. fn: function (){
  70. var self=this;
  71. return smalltalk.withContext(function($ctx1) {
  72. var $2,$1;
  73. $2=self["@default"];
  74. if(($receiver = $2) == nil || $receiver == undefined){
  75. self["@default"]=self._new();
  76. $1=self["@default"];
  77. } else {
  78. $1=$2;
  79. };
  80. return $1;
  81. }, function($ctx1) {$ctx1.fill(self,"default",{},smalltalk.AbstractExporter.klass)})},
  82. args: [],
  83. source: "default\x0a\x09^ default ifNil: [ default := self new ]",
  84. messageSends: ["ifNil:", "new"],
  85. referencedClasses: []
  86. }),
  87. smalltalk.AbstractExporter.klass);
  88. smalltalk.addClass('ChunkExporter', smalltalk.AbstractExporter, [], 'Importer-Exporter');
  89. smalltalk.ChunkExporter.comment="I am an exporter dedicated to outputting Amber source code in the classic Smalltalk chunk format.\x0a\x0aI do not output any compiled code.";
  90. smalltalk.addMethod(
  91. smalltalk.method({
  92. selector: "exportCategoryEpilogueOf:on:",
  93. category: 'exporting-output',
  94. fn: function (category,aStream){
  95. var self=this;
  96. return smalltalk.withContext(function($ctx1) {
  97. var $1,$2;
  98. $1=aStream;
  99. _st($1)._nextPutAll_(" !");
  100. _st($1)._lf();
  101. $2=_st($1)._lf();
  102. return self}, function($ctx1) {$ctx1.fill(self,"exportCategoryEpilogueOf:on:",{category:category,aStream:aStream},smalltalk.ChunkExporter)})},
  103. args: ["category", "aStream"],
  104. source: "exportCategoryEpilogueOf: category on: aStream\x0a\x09aStream nextPutAll: ' !'; lf; lf",
  105. messageSends: ["nextPutAll:", "lf"],
  106. referencedClasses: []
  107. }),
  108. smalltalk.ChunkExporter);
  109. smalltalk.addMethod(
  110. smalltalk.method({
  111. selector: "exportCategoryPrologueOf:on:",
  112. category: 'exporting-output',
  113. fn: function (category,aStream){
  114. var self=this;
  115. return smalltalk.withContext(function($ctx1) {
  116. var $1,$2;
  117. $1=aStream;
  118. _st($1)._nextPutAll_("!".__comma(self._classNameFor_(_st(category)._theClass())));
  119. $2=_st($1)._nextPutAll_(_st(" methodsFor: '".__comma(_st(category)._name())).__comma("'!"));
  120. return self}, function($ctx1) {$ctx1.fill(self,"exportCategoryPrologueOf:on:",{category:category,aStream:aStream},smalltalk.ChunkExporter)})},
  121. args: ["category", "aStream"],
  122. source: "exportCategoryPrologueOf: category on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: '!', (self classNameFor: category theClass);\x0a\x09\x09nextPutAll: ' methodsFor: ''', category name, '''!'",
  123. messageSends: ["nextPutAll:", ",", "classNameFor:", "theClass", "name"],
  124. referencedClasses: []
  125. }),
  126. smalltalk.ChunkExporter);
  127. smalltalk.addMethod(
  128. smalltalk.method({
  129. selector: "exportDefinitionOf:on:",
  130. category: 'exporting-output',
  131. fn: function (aClass,aStream){
  132. var self=this;
  133. return smalltalk.withContext(function($ctx1) {
  134. var $1,$2,$3,$4,$5,$6,$7;
  135. $1=aStream;
  136. _st($1)._nextPutAll_(self._classNameFor_(_st(aClass)._superclass()));
  137. _st($1)._nextPutAll_(" subclass: #".__comma(self._classNameFor_(aClass)));
  138. _st($1)._lf();
  139. _st($1)._tab();
  140. $2=_st($1)._nextPutAll_("instanceVariableNames: '");
  141. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  142. return smalltalk.withContext(function($ctx2) {
  143. return _st(aStream)._nextPutAll_(each);
  144. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  145. return smalltalk.withContext(function($ctx2) {
  146. return _st(aStream)._nextPutAll_(" ");
  147. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  148. $3=aStream;
  149. _st($3)._nextPutAll_("'");
  150. _st($3)._lf();
  151. _st($3)._tab();
  152. _st($3)._nextPutAll_(_st("package: '".__comma(_st(aClass)._category())).__comma("'!"));
  153. $4=_st($3)._lf();
  154. $5=_st(_st(aClass)._comment())._notEmpty();
  155. if(smalltalk.assert($5)){
  156. $6=aStream;
  157. _st($6)._nextPutAll_(_st("!".__comma(self._classNameFor_(aClass))).__comma(" commentStamp!"));
  158. _st($6)._lf();
  159. _st($6)._nextPutAll_(_st(self._chunkEscape_(_st(aClass)._comment())).__comma("!"));
  160. $7=_st($6)._lf();
  161. $7;
  162. };
  163. _st(aStream)._lf();
  164. return self}, function($ctx1) {$ctx1.fill(self,"exportDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
  165. args: ["aClass", "aStream"],
  166. source: "exportDefinitionOf: aClass on: aStream\x0a\x09\x22Chunk format.\x22\x0a\x0a\x09aStream\x0a\x09\x09nextPutAll: (self classNameFor: aClass superclass);\x0a\x09\x09nextPutAll: ' subclass: #', (self classNameFor: aClass); lf;\x0a\x09\x09tab; nextPutAll: 'instanceVariableNames: '''.\x0a\x09aClass instanceVariableNames\x0a\x09\x09do: [:each | aStream nextPutAll: each]\x0a\x09\x09separatedBy: [aStream nextPutAll: ' '].\x0a\x09aStream\x0a\x09\x09nextPutAll: ''''; lf;\x0a\x09\x09tab; nextPutAll: 'package: ''', aClass category, '''!'; lf.\x0a\x09aClass comment notEmpty ifTrue: [\x0a\x09\x09aStream\x0a\x09\x09nextPutAll: '!', (self classNameFor: aClass), ' commentStamp!';lf;\x0a\x09\x09nextPutAll: (self chunkEscape: aClass comment), '!';lf].\x0a\x09aStream lf",
  167. messageSends: ["nextPutAll:", "classNameFor:", "superclass", ",", "lf", "tab", "do:separatedBy:", "instanceVariableNames", "category", "ifTrue:", "chunkEscape:", "comment", "notEmpty"],
  168. referencedClasses: []
  169. }),
  170. smalltalk.ChunkExporter);
  171. smalltalk.addMethod(
  172. smalltalk.method({
  173. selector: "exportMetaDefinitionOf:on:",
  174. category: 'exporting-output',
  175. fn: function (aClass,aStream){
  176. var self=this;
  177. return smalltalk.withContext(function($ctx1) {
  178. var $1,$2,$3,$4,$5;
  179. $1=_st(_st(_st(aClass)._class())._instanceVariableNames())._isEmpty();
  180. if(! smalltalk.assert($1)){
  181. $2=aStream;
  182. _st($2)._nextPutAll_(self._classNameFor_(_st(aClass)._class()));
  183. $3=_st($2)._nextPutAll_(" instanceVariableNames: '");
  184. $3;
  185. _st(_st(_st(aClass)._class())._instanceVariableNames())._do_separatedBy_((function(each){
  186. return smalltalk.withContext(function($ctx2) {
  187. return _st(aStream)._nextPutAll_(each);
  188. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  189. return smalltalk.withContext(function($ctx2) {
  190. return _st(aStream)._nextPutAll_(" ");
  191. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  192. $4=aStream;
  193. _st($4)._nextPutAll_("'!");
  194. _st($4)._lf();
  195. $5=_st($4)._lf();
  196. $5;
  197. };
  198. return self}, function($ctx1) {$ctx1.fill(self,"exportMetaDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
  199. args: ["aClass", "aStream"],
  200. source: "exportMetaDefinitionOf: aClass on: aStream\x0a\x0a\x09aClass class instanceVariableNames isEmpty ifFalse: [\x0a\x09\x09aStream\x0a\x09\x09\x09nextPutAll: (self classNameFor: aClass class);\x0a\x09\x09\x09nextPutAll: ' instanceVariableNames: '''.\x0a\x09\x09aClass class instanceVariableNames\x0a\x09\x09\x09do: [:each | aStream nextPutAll: each]\x0a\x09\x09\x09separatedBy: [aStream nextPutAll: ' '].\x0a\x09\x09aStream\x0a\x09\x09\x09nextPutAll: '''!'; lf; lf]",
  201. messageSends: ["ifFalse:", "nextPutAll:", "classNameFor:", "class", "do:separatedBy:", "instanceVariableNames", "lf", "isEmpty"],
  202. referencedClasses: []
  203. }),
  204. smalltalk.ChunkExporter);
  205. smalltalk.addMethod(
  206. smalltalk.method({
  207. selector: "exportMethod:on:",
  208. category: 'exporting-output',
  209. fn: function (aMethod,aStream){
  210. var self=this;
  211. return smalltalk.withContext(function($ctx1) {
  212. var $1,$2;
  213. $1=aStream;
  214. _st($1)._lf();
  215. _st($1)._lf();
  216. _st($1)._nextPutAll_(self._chunkEscape_(_st(aMethod)._source()));
  217. _st($1)._lf();
  218. $2=_st($1)._nextPutAll_("!");
  219. return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:on:",{aMethod:aMethod,aStream:aStream},smalltalk.ChunkExporter)})},
  220. args: ["aMethod", "aStream"],
  221. source: "exportMethod: aMethod on: aStream\x0a\x09aStream\x0a\x09\x09lf; lf; nextPutAll: (self chunkEscape: aMethod source); lf;\x0a\x09\x09nextPutAll: '!'",
  222. messageSends: ["lf", "nextPutAll:", "chunkEscape:", "source"],
  223. referencedClasses: []
  224. }),
  225. smalltalk.ChunkExporter);
  226. smalltalk.addMethod(
  227. smalltalk.method({
  228. selector: "exportPackageDefinitionOf:on:",
  229. category: 'exporting-output',
  230. fn: function (package_,aStream){
  231. var self=this;
  232. return smalltalk.withContext(function($ctx1) {
  233. var $1,$2;
  234. $1=aStream;
  235. _st($1)._nextPutAll_(_st("Smalltalk current createPackage: '".__comma(_st(package_)._name())).__comma("'!"));
  236. $2=_st($1)._lf();
  237. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageDefinitionOf:on:",{package_:package_,aStream:aStream},smalltalk.ChunkExporter)})},
  238. args: ["package", "aStream"],
  239. source: "exportPackageDefinitionOf: package on: aStream\x0a\x09\x22Chunk format.\x22\x0a\x0a\x09aStream\x0a\x09\x09nextPutAll: 'Smalltalk current createPackage: ''', package name, '''!';\x0a\x09\x09lf",
  240. messageSends: ["nextPutAll:", ",", "name", "lf"],
  241. referencedClasses: []
  242. }),
  243. smalltalk.ChunkExporter);
  244. smalltalk.addMethod(
  245. smalltalk.method({
  246. selector: "extensionCategoriesOfPackage:",
  247. category: 'exporting-accessing',
  248. fn: function (package_){
  249. var self=this;
  250. var name,map,result;
  251. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  252. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  253. function $MethodCategory(){return smalltalk.MethodCategory||(typeof MethodCategory=="undefined"?nil:MethodCategory)}
  254. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  255. function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
  256. return smalltalk.withContext(function($ctx1) {
  257. var $1,$2;
  258. name=_st(package_)._name();
  259. result=_st($OrderedCollection())._new();
  260. _st(_st($Package())._sortedClasses_(_st(_st($Smalltalk())._current())._classes()))._do_((function(each){
  261. return smalltalk.withContext(function($ctx2) {
  262. return _st([each,_st(each)._class()])._do_((function(aClass){
  263. return smalltalk.withContext(function($ctx3) {
  264. map=_st($Dictionary())._new();
  265. map;
  266. _st(aClass)._protocolsDo_((function(category,methods){
  267. return smalltalk.withContext(function($ctx4) {
  268. $1=_st(category)._match_("^\x5c*".__comma(name));
  269. if(smalltalk.assert($1)){
  270. return _st(map)._at_put_(category,methods);
  271. };
  272. }, function($ctx4) {$ctx4.fillBlock({category:category,methods:methods},$ctx3)})}));
  273. return _st(result)._addAll_(_st(_st(_st(map)._keys())._sorted_((function(a,b){
  274. return smalltalk.withContext(function($ctx4) {
  275. return _st(a).__lt_eq(b);
  276. }, function($ctx4) {$ctx4.fillBlock({a:a,b:b},$ctx3)})})))._collect_((function(category){
  277. return smalltalk.withContext(function($ctx4) {
  278. return _st($MethodCategory())._name_theClass_methods_(category,aClass,_st(map)._at_(category));
  279. }, function($ctx4) {$ctx4.fillBlock({category:category},$ctx3)})})));
  280. }, function($ctx3) {$ctx3.fillBlock({aClass:aClass},$ctx2)})}));
  281. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  282. $2=result;
  283. return $2;
  284. }, function($ctx1) {$ctx1.fill(self,"extensionCategoriesOfPackage:",{package_:package_,name:name,map:map,result:result},smalltalk.ChunkExporter)})},
  285. args: ["package"],
  286. source: "extensionCategoriesOfPackage: package\x0a\x09\x22Issue #143: sort protocol alphabetically\x22\x0a\x0a\x09| name map result |\x0a\x09name := package name.\x0a\x09result := OrderedCollection new.\x0a\x09(Package sortedClasses: Smalltalk current classes) do: [:each |\x0a\x09\x09{each. each class} do: [:aClass |\x0a\x09\x09\x09map := Dictionary new.\x0a\x09\x09\x09aClass protocolsDo: [:category :methods |\x0a\x09\x09\x09\x09(category match: '^\x5c*', name) ifTrue: [ map at: category put: methods ]].\x0a\x09\x09\x09result addAll: ((map keys sorted: [:a :b | a <= b ]) collect: [:category |\x0a\x09\x09\x09\x09MethodCategory name: category theClass: aClass methods: (map at: category)]) ]].\x0a\x09^result",
  287. messageSends: ["name", "new", "do:", "protocolsDo:", "ifTrue:", "at:put:", "match:", ",", "addAll:", "collect:", "name:theClass:methods:", "at:", "sorted:", "<=", "keys", "class", "sortedClasses:", "classes", "current"],
  288. referencedClasses: ["OrderedCollection", "Dictionary", "MethodCategory", "Smalltalk", "Package"]
  289. }),
  290. smalltalk.ChunkExporter);
  291. smalltalk.addMethod(
  292. smalltalk.method({
  293. selector: "methodsOfCategory:",
  294. category: 'exporting-accessing',
  295. fn: function (category){
  296. var self=this;
  297. return smalltalk.withContext(function($ctx1) {
  298. var $1;
  299. $1=_st(_st(category)._methods())._sorted_((function(a,b){
  300. return smalltalk.withContext(function($ctx2) {
  301. return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  302. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})}));
  303. return $1;
  304. }, function($ctx1) {$ctx1.fill(self,"methodsOfCategory:",{category:category},smalltalk.ChunkExporter)})},
  305. args: ["category"],
  306. source: "methodsOfCategory: category\x0a\x09\x22Issue #143: sort methods alphabetically\x22\x0a\x0a\x09^(category methods) sorted: [:a :b | a selector <= b selector]",
  307. messageSends: ["sorted:", "<=", "selector", "methods"],
  308. referencedClasses: []
  309. }),
  310. smalltalk.ChunkExporter);
  311. smalltalk.addMethod(
  312. smalltalk.method({
  313. selector: "ownCategoriesOfClass:",
  314. category: 'exporting-accessing',
  315. fn: function (aClass){
  316. var self=this;
  317. var map;
  318. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  319. function $MethodCategory(){return smalltalk.MethodCategory||(typeof MethodCategory=="undefined"?nil:MethodCategory)}
  320. return smalltalk.withContext(function($ctx1) {
  321. var $1,$2;
  322. map=_st($Dictionary())._new();
  323. _st(aClass)._protocolsDo_((function(category,methods){
  324. return smalltalk.withContext(function($ctx2) {
  325. $1=_st(category)._match_("^\x5c*");
  326. if(! smalltalk.assert($1)){
  327. return _st(map)._at_put_(category,methods);
  328. };
  329. }, function($ctx2) {$ctx2.fillBlock({category:category,methods:methods},$ctx1)})}));
  330. $2=_st(_st(_st(map)._keys())._sorted_((function(a,b){
  331. return smalltalk.withContext(function($ctx2) {
  332. return _st(a).__lt_eq(b);
  333. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})})))._collect_((function(category){
  334. return smalltalk.withContext(function($ctx2) {
  335. return _st($MethodCategory())._name_theClass_methods_(category,aClass,_st(map)._at_(category));
  336. }, function($ctx2) {$ctx2.fillBlock({category:category},$ctx1)})}));
  337. return $2;
  338. }, function($ctx1) {$ctx1.fill(self,"ownCategoriesOfClass:",{aClass:aClass,map:map},smalltalk.ChunkExporter)})},
  339. args: ["aClass"],
  340. source: "ownCategoriesOfClass: aClass\x0a\x09\x22Issue #143: sort protocol alphabetically\x22\x0a\x0a\x09| map |\x0a\x09map := Dictionary new.\x0a\x09aClass protocolsDo: [:category :methods |\x0a\x09\x09(category match: '^\x5c*') ifFalse: [ map at: category put: methods ]].\x0a\x09^(map keys sorted: [:a :b | a <= b ]) collect: [:category |\x0a\x09\x09MethodCategory name: category theClass: aClass methods: (map at: category) ]",
  341. messageSends: ["new", "protocolsDo:", "ifFalse:", "at:put:", "match:", "collect:", "name:theClass:methods:", "at:", "sorted:", "<=", "keys"],
  342. referencedClasses: ["Dictionary", "MethodCategory"]
  343. }),
  344. smalltalk.ChunkExporter);
  345. smalltalk.addMethod(
  346. smalltalk.method({
  347. selector: "ownCategoriesOfMetaClass:",
  348. category: 'exporting-accessing',
  349. fn: function (aClass){
  350. var self=this;
  351. return smalltalk.withContext(function($ctx1) {
  352. var $1;
  353. $1=self._ownCategoriesOfClass_(_st(aClass)._class());
  354. return $1;
  355. }, function($ctx1) {$ctx1.fill(self,"ownCategoriesOfMetaClass:",{aClass:aClass},smalltalk.ChunkExporter)})},
  356. args: ["aClass"],
  357. source: "ownCategoriesOfMetaClass: aClass\x0a\x09\x22Issue #143: sort protocol alphabetically\x22\x0a\x0a\x09^self ownCategoriesOfClass: aClass class",
  358. messageSends: ["ownCategoriesOfClass:", "class"],
  359. referencedClasses: []
  360. }),
  361. smalltalk.ChunkExporter);
  362. smalltalk.addMethod(
  363. smalltalk.method({
  364. selector: "recipe",
  365. category: 'fileOut',
  366. fn: function (){
  367. var self=this;
  368. var exportCategoryRecipe;
  369. function $PluggableExporter(){return smalltalk.PluggableExporter||(typeof PluggableExporter=="undefined"?nil:PluggableExporter)}
  370. return smalltalk.withContext(function($ctx1) {
  371. var $1;
  372. exportCategoryRecipe=[self.__minus_gt("exportCategoryPrologueOf:on:"),[self.__minus_gt("methodsOfCategory:"),self.__minus_gt("exportMethod:on:")],self.__minus_gt("exportCategoryEpilogueOf:on:")];
  373. $1=[self.__minus_gt("exportPackageDefinitionOf:on:"),[_st($PluggableExporter()).__minus_gt("ownClassesOfPackage:"),self.__minus_gt("exportDefinitionOf:on:"),_st([self.__minus_gt("ownCategoriesOfClass:")]).__comma(exportCategoryRecipe),self.__minus_gt("exportMetaDefinitionOf:on:"),_st([self.__minus_gt("ownCategoriesOfMetaClass:")]).__comma(exportCategoryRecipe)],_st([self.__minus_gt("extensionCategoriesOfPackage:")]).__comma(exportCategoryRecipe)];
  374. return $1;
  375. }, function($ctx1) {$ctx1.fill(self,"recipe",{exportCategoryRecipe:exportCategoryRecipe},smalltalk.ChunkExporter)})},
  376. args: [],
  377. source: "recipe\x0a\x09\x22Export a given package.\x22\x0a\x0a\x09| exportCategoryRecipe |\x0a\x09exportCategoryRecipe := {\x0a\x09\x09self -> #exportCategoryPrologueOf:on:.\x0a\x09\x09{\x0a\x09\x09\x09self -> #methodsOfCategory:.\x0a\x09\x09\x09self -> #exportMethod:on: }.\x0a\x09\x09self -> #exportCategoryEpilogueOf:on: }.\x0a\x0a\x09^{\x0a\x09\x09self -> #exportPackageDefinitionOf:on:.\x0a\x09\x09{\x0a\x09\x09\x09PluggableExporter -> #ownClassesOfPackage:.\x0a\x09\x09\x09self -> #exportDefinitionOf:on:.\x0a\x09\x09\x09{ self -> #ownCategoriesOfClass: }, exportCategoryRecipe.\x0a\x09\x09\x09self -> #exportMetaDefinitionOf:on:.\x0a\x09\x09\x09{ self -> #ownCategoriesOfMetaClass: }, exportCategoryRecipe }.\x0a\x09\x09{ self -> #extensionCategoriesOfPackage: }, exportCategoryRecipe\x0a\x09}",
  378. messageSends: ["->", ","],
  379. referencedClasses: ["PluggableExporter"]
  380. }),
  381. smalltalk.ChunkExporter);
  382. smalltalk.addMethod(
  383. smalltalk.method({
  384. selector: "chunkEscape:",
  385. category: 'private',
  386. fn: function (aString){
  387. var self=this;
  388. return smalltalk.withContext(function($ctx1) {
  389. var $1;
  390. $1=_st(_st(aString)._replace_with_("!","!!"))._trimBoth();
  391. return $1;
  392. }, function($ctx1) {$ctx1.fill(self,"chunkEscape:",{aString:aString},smalltalk.ChunkExporter.klass)})},
  393. args: ["aString"],
  394. source: "chunkEscape: aString\x0a\x09\x22Replace all occurrences of ! with !! and trim at both ends.\x22\x0a\x0a\x09^(aString replace: '!' with: '!!') trimBoth",
  395. messageSends: ["trimBoth", "replace:with:"],
  396. referencedClasses: []
  397. }),
  398. smalltalk.ChunkExporter.klass);
  399. smalltalk.addMethod(
  400. smalltalk.method({
  401. selector: "classNameFor:",
  402. category: 'private',
  403. fn: function (aClass){
  404. var self=this;
  405. return smalltalk.withContext(function($ctx1) {
  406. var $2,$3,$1;
  407. $2=_st(aClass)._isMetaclass();
  408. if(smalltalk.assert($2)){
  409. $1=_st(_st(_st(aClass)._instanceClass())._name()).__comma(" class");
  410. } else {
  411. $3=_st(aClass)._isNil();
  412. if(smalltalk.assert($3)){
  413. $1="nil";
  414. } else {
  415. $1=_st(aClass)._name();
  416. };
  417. };
  418. return $1;
  419. }, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},smalltalk.ChunkExporter.klass)})},
  420. args: ["aClass"],
  421. source: "classNameFor: aClass\x0a\x09^aClass isMetaclass\x0a\x09\x09ifTrue: [aClass instanceClass name, ' class']\x0a\x09\x09ifFalse: [\x0a\x09\x09aClass isNil\x0a\x09\x09\x09ifTrue: ['nil']\x0a\x09\x09\x09ifFalse: [aClass name]]",
  422. messageSends: ["ifTrue:ifFalse:", ",", "name", "instanceClass", "isNil", "isMetaclass"],
  423. referencedClasses: []
  424. }),
  425. smalltalk.ChunkExporter.klass);
  426. smalltalk.addMethod(
  427. smalltalk.method({
  428. selector: "exportCategoryEpilogueOf:on:",
  429. category: 'exporting-output',
  430. fn: function (category,aStream){
  431. var self=this;
  432. return smalltalk.withContext(function($ctx1) {
  433. var $1,$2;
  434. $1=aStream;
  435. _st($1)._nextPutAll_(" !");
  436. _st($1)._lf();
  437. $2=_st($1)._lf();
  438. return self}, function($ctx1) {$ctx1.fill(self,"exportCategoryEpilogueOf:on:",{category:category,aStream:aStream},smalltalk.ChunkExporter.klass)})},
  439. args: ["category", "aStream"],
  440. source: "exportCategoryEpilogueOf: category on: aStream\x0a\x09aStream nextPutAll: ' !'; lf; lf",
  441. messageSends: ["nextPutAll:", "lf"],
  442. referencedClasses: []
  443. }),
  444. smalltalk.ChunkExporter.klass);
  445. smalltalk.addMethod(
  446. smalltalk.method({
  447. selector: "exportCategoryPrologueOf:on:",
  448. category: 'exporting-output',
  449. fn: function (category,aStream){
  450. var self=this;
  451. return smalltalk.withContext(function($ctx1) {
  452. var $1,$2;
  453. $1=aStream;
  454. _st($1)._nextPutAll_("!".__comma(self._classNameFor_(_st(category)._theClass())));
  455. $2=_st($1)._nextPutAll_(_st(" methodsFor: '".__comma(_st(category)._name())).__comma("'!"));
  456. return self}, function($ctx1) {$ctx1.fill(self,"exportCategoryPrologueOf:on:",{category:category,aStream:aStream},smalltalk.ChunkExporter.klass)})},
  457. args: ["category", "aStream"],
  458. source: "exportCategoryPrologueOf: category on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: '!', (self classNameFor: category theClass);\x0a\x09\x09nextPutAll: ' methodsFor: ''', category name, '''!'",
  459. messageSends: ["nextPutAll:", ",", "classNameFor:", "theClass", "name"],
  460. referencedClasses: []
  461. }),
  462. smalltalk.ChunkExporter.klass);
  463. smalltalk.addMethod(
  464. smalltalk.method({
  465. selector: "exportDefinitionOf:on:",
  466. category: 'exporting-output',
  467. fn: function (aClass,aStream){
  468. var self=this;
  469. return smalltalk.withContext(function($ctx1) {
  470. var $1,$2,$3,$4,$5,$6,$7;
  471. $1=aStream;
  472. _st($1)._nextPutAll_(self._classNameFor_(_st(aClass)._superclass()));
  473. _st($1)._nextPutAll_(" subclass: #".__comma(self._classNameFor_(aClass)));
  474. _st($1)._lf();
  475. _st($1)._tab();
  476. $2=_st($1)._nextPutAll_("instanceVariableNames: '");
  477. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  478. return smalltalk.withContext(function($ctx2) {
  479. return _st(aStream)._nextPutAll_(each);
  480. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  481. return smalltalk.withContext(function($ctx2) {
  482. return _st(aStream)._nextPutAll_(" ");
  483. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  484. $3=aStream;
  485. _st($3)._nextPutAll_("'");
  486. _st($3)._lf();
  487. _st($3)._tab();
  488. _st($3)._nextPutAll_(_st("package: '".__comma(_st(aClass)._category())).__comma("'!"));
  489. $4=_st($3)._lf();
  490. $5=_st(_st(aClass)._comment())._notEmpty();
  491. if(smalltalk.assert($5)){
  492. $6=aStream;
  493. _st($6)._nextPutAll_(_st("!".__comma(self._classNameFor_(aClass))).__comma(" commentStamp!"));
  494. _st($6)._lf();
  495. _st($6)._nextPutAll_(_st(self._chunkEscape_(_st(aClass)._comment())).__comma("!"));
  496. $7=_st($6)._lf();
  497. $7;
  498. };
  499. _st(aStream)._lf();
  500. return self}, function($ctx1) {$ctx1.fill(self,"exportDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.ChunkExporter.klass)})},
  501. args: ["aClass", "aStream"],
  502. source: "exportDefinitionOf: aClass on: aStream\x0a\x09\x22Chunk format.\x22\x0a\x0a\x09aStream\x0a\x09\x09nextPutAll: (self classNameFor: aClass superclass);\x0a\x09\x09nextPutAll: ' subclass: #', (self classNameFor: aClass); lf;\x0a\x09\x09tab; nextPutAll: 'instanceVariableNames: '''.\x0a\x09aClass instanceVariableNames\x0a\x09\x09do: [:each | aStream nextPutAll: each]\x0a\x09\x09separatedBy: [aStream nextPutAll: ' '].\x0a\x09aStream\x0a\x09\x09nextPutAll: ''''; lf;\x0a\x09\x09tab; nextPutAll: 'package: ''', aClass category, '''!'; lf.\x0a\x09aClass comment notEmpty ifTrue: [\x0a\x09\x09aStream\x0a\x09\x09nextPutAll: '!', (self classNameFor: aClass), ' commentStamp!';lf;\x0a\x09\x09nextPutAll: (self chunkEscape: aClass comment), '!';lf].\x0a\x09aStream lf",
  503. messageSends: ["nextPutAll:", "classNameFor:", "superclass", ",", "lf", "tab", "do:separatedBy:", "instanceVariableNames", "category", "ifTrue:", "chunkEscape:", "comment", "notEmpty"],
  504. referencedClasses: []
  505. }),
  506. smalltalk.ChunkExporter.klass);
  507. smalltalk.addMethod(
  508. smalltalk.method({
  509. selector: "exportMetaDefinitionOf:on:",
  510. category: 'exporting-output',
  511. fn: function (aClass,aStream){
  512. var self=this;
  513. return smalltalk.withContext(function($ctx1) {
  514. var $1,$2,$3,$4,$5;
  515. $1=_st(_st(_st(aClass)._class())._instanceVariableNames())._isEmpty();
  516. if(! smalltalk.assert($1)){
  517. $2=aStream;
  518. _st($2)._nextPutAll_(self._classNameFor_(_st(aClass)._class()));
  519. $3=_st($2)._nextPutAll_(" instanceVariableNames: '");
  520. $3;
  521. _st(_st(_st(aClass)._class())._instanceVariableNames())._do_separatedBy_((function(each){
  522. return smalltalk.withContext(function($ctx2) {
  523. return _st(aStream)._nextPutAll_(each);
  524. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  525. return smalltalk.withContext(function($ctx2) {
  526. return _st(aStream)._nextPutAll_(" ");
  527. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  528. $4=aStream;
  529. _st($4)._nextPutAll_("'!");
  530. _st($4)._lf();
  531. $5=_st($4)._lf();
  532. $5;
  533. };
  534. return self}, function($ctx1) {$ctx1.fill(self,"exportMetaDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.ChunkExporter.klass)})},
  535. args: ["aClass", "aStream"],
  536. source: "exportMetaDefinitionOf: aClass on: aStream\x0a\x0a\x09aClass class instanceVariableNames isEmpty ifFalse: [\x0a\x09\x09aStream\x0a\x09\x09\x09nextPutAll: (self classNameFor: aClass class);\x0a\x09\x09\x09nextPutAll: ' instanceVariableNames: '''.\x0a\x09\x09aClass class instanceVariableNames\x0a\x09\x09\x09do: [:each | aStream nextPutAll: each]\x0a\x09\x09\x09separatedBy: [aStream nextPutAll: ' '].\x0a\x09\x09aStream\x0a\x09\x09\x09nextPutAll: '''!'; lf; lf]",
  537. messageSends: ["ifFalse:", "nextPutAll:", "classNameFor:", "class", "do:separatedBy:", "instanceVariableNames", "lf", "isEmpty"],
  538. referencedClasses: []
  539. }),
  540. smalltalk.ChunkExporter.klass);
  541. smalltalk.addMethod(
  542. smalltalk.method({
  543. selector: "exportMethod:on:",
  544. category: 'exporting-output',
  545. fn: function (aMethod,aStream){
  546. var self=this;
  547. return smalltalk.withContext(function($ctx1) {
  548. var $1,$2;
  549. $1=aStream;
  550. _st($1)._lf();
  551. _st($1)._lf();
  552. _st($1)._nextPutAll_(self._chunkEscape_(_st(aMethod)._source()));
  553. _st($1)._lf();
  554. $2=_st($1)._nextPutAll_("!");
  555. return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:on:",{aMethod:aMethod,aStream:aStream},smalltalk.ChunkExporter.klass)})},
  556. args: ["aMethod", "aStream"],
  557. source: "exportMethod: aMethod on: aStream\x0a\x09aStream\x0a\x09\x09lf; lf; nextPutAll: (self chunkEscape: aMethod source); lf;\x0a\x09\x09nextPutAll: '!'",
  558. messageSends: ["lf", "nextPutAll:", "chunkEscape:", "source"],
  559. referencedClasses: []
  560. }),
  561. smalltalk.ChunkExporter.klass);
  562. smalltalk.addMethod(
  563. smalltalk.method({
  564. selector: "exportPackageDefinitionOf:on:",
  565. category: 'exporting-output',
  566. fn: function (package_,aStream){
  567. var self=this;
  568. return smalltalk.withContext(function($ctx1) {
  569. var $1,$2;
  570. $1=aStream;
  571. _st($1)._nextPutAll_(_st("Smalltalk current createPackage: '".__comma(_st(package_)._name())).__comma("'!"));
  572. $2=_st($1)._lf();
  573. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageDefinitionOf:on:",{package_:package_,aStream:aStream},smalltalk.ChunkExporter.klass)})},
  574. args: ["package", "aStream"],
  575. source: "exportPackageDefinitionOf: package on: aStream\x0a\x09\x22Chunk format.\x22\x0a\x0a\x09aStream\x0a\x09\x09nextPutAll: 'Smalltalk current createPackage: ''', package name, '''!';\x0a\x09\x09lf",
  576. messageSends: ["nextPutAll:", ",", "name", "lf"],
  577. referencedClasses: []
  578. }),
  579. smalltalk.ChunkExporter.klass);
  580. smalltalk.addMethod(
  581. smalltalk.method({
  582. selector: "extensionCategoriesOfPackage:",
  583. category: 'exporting-accessing',
  584. fn: function (package_){
  585. var self=this;
  586. var name,map,result;
  587. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  588. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  589. function $MethodCategory(){return smalltalk.MethodCategory||(typeof MethodCategory=="undefined"?nil:MethodCategory)}
  590. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  591. function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
  592. return smalltalk.withContext(function($ctx1) {
  593. var $1,$2;
  594. name=_st(package_)._name();
  595. result=_st($OrderedCollection())._new();
  596. _st(_st($Package())._sortedClasses_(_st(_st($Smalltalk())._current())._classes()))._do_((function(each){
  597. return smalltalk.withContext(function($ctx2) {
  598. return _st([each,_st(each)._class()])._do_((function(aClass){
  599. return smalltalk.withContext(function($ctx3) {
  600. map=_st($Dictionary())._new();
  601. map;
  602. _st(aClass)._protocolsDo_((function(category,methods){
  603. return smalltalk.withContext(function($ctx4) {
  604. $1=_st(category)._match_("^\x5c*".__comma(name));
  605. if(smalltalk.assert($1)){
  606. return _st(map)._at_put_(category,methods);
  607. };
  608. }, function($ctx4) {$ctx4.fillBlock({category:category,methods:methods},$ctx3)})}));
  609. return _st(result)._addAll_(_st(_st(_st(map)._keys())._sorted_((function(a,b){
  610. return smalltalk.withContext(function($ctx4) {
  611. return _st(a).__lt_eq(b);
  612. }, function($ctx4) {$ctx4.fillBlock({a:a,b:b},$ctx3)})})))._collect_((function(category){
  613. return smalltalk.withContext(function($ctx4) {
  614. return _st($MethodCategory())._name_theClass_methods_(category,aClass,_st(map)._at_(category));
  615. }, function($ctx4) {$ctx4.fillBlock({category:category},$ctx3)})})));
  616. }, function($ctx3) {$ctx3.fillBlock({aClass:aClass},$ctx2)})}));
  617. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  618. $2=result;
  619. return $2;
  620. }, function($ctx1) {$ctx1.fill(self,"extensionCategoriesOfPackage:",{package_:package_,name:name,map:map,result:result},smalltalk.ChunkExporter.klass)})},
  621. args: ["package"],
  622. source: "extensionCategoriesOfPackage: package\x0a\x09\x22Issue #143: sort protocol alphabetically\x22\x0a\x0a\x09| name map result |\x0a\x09name := package name.\x0a\x09result := OrderedCollection new.\x0a\x09(Package sortedClasses: Smalltalk current classes) do: [:each |\x0a\x09\x09{each. each class} do: [:aClass |\x0a\x09\x09\x09map := Dictionary new.\x0a\x09\x09\x09aClass protocolsDo: [:category :methods |\x0a\x09\x09\x09\x09(category match: '^\x5c*', name) ifTrue: [ map at: category put: methods ]].\x0a\x09\x09\x09result addAll: ((map keys sorted: [:a :b | a <= b ]) collect: [:category |\x0a\x09\x09\x09\x09MethodCategory name: category theClass: aClass methods: (map at: category)]) ]].\x0a\x09^result",
  623. messageSends: ["name", "new", "do:", "protocolsDo:", "ifTrue:", "at:put:", "match:", ",", "addAll:", "collect:", "name:theClass:methods:", "at:", "sorted:", "<=", "keys", "class", "sortedClasses:", "classes", "current"],
  624. referencedClasses: ["OrderedCollection", "Dictionary", "MethodCategory", "Smalltalk", "Package"]
  625. }),
  626. smalltalk.ChunkExporter.klass);
  627. smalltalk.addMethod(
  628. smalltalk.method({
  629. selector: "methodsOfCategory:",
  630. category: 'exporting-accessing',
  631. fn: function (category){
  632. var self=this;
  633. return smalltalk.withContext(function($ctx1) {
  634. var $1;
  635. $1=_st(_st(category)._methods())._sorted_((function(a,b){
  636. return smalltalk.withContext(function($ctx2) {
  637. return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  638. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})}));
  639. return $1;
  640. }, function($ctx1) {$ctx1.fill(self,"methodsOfCategory:",{category:category},smalltalk.ChunkExporter.klass)})},
  641. args: ["category"],
  642. source: "methodsOfCategory: category\x0a\x09\x22Issue #143: sort methods alphabetically\x22\x0a\x0a\x09^(category methods) sorted: [:a :b | a selector <= b selector]",
  643. messageSends: ["sorted:", "<=", "selector", "methods"],
  644. referencedClasses: []
  645. }),
  646. smalltalk.ChunkExporter.klass);
  647. smalltalk.addMethod(
  648. smalltalk.method({
  649. selector: "ownCategoriesOfClass:",
  650. category: 'exporting-accessing',
  651. fn: function (aClass){
  652. var self=this;
  653. var map;
  654. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  655. function $MethodCategory(){return smalltalk.MethodCategory||(typeof MethodCategory=="undefined"?nil:MethodCategory)}
  656. return smalltalk.withContext(function($ctx1) {
  657. var $1,$2;
  658. map=_st($Dictionary())._new();
  659. _st(aClass)._protocolsDo_((function(category,methods){
  660. return smalltalk.withContext(function($ctx2) {
  661. $1=_st(category)._match_("^\x5c*");
  662. if(! smalltalk.assert($1)){
  663. return _st(map)._at_put_(category,methods);
  664. };
  665. }, function($ctx2) {$ctx2.fillBlock({category:category,methods:methods},$ctx1)})}));
  666. $2=_st(_st(_st(map)._keys())._sorted_((function(a,b){
  667. return smalltalk.withContext(function($ctx2) {
  668. return _st(a).__lt_eq(b);
  669. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})})))._collect_((function(category){
  670. return smalltalk.withContext(function($ctx2) {
  671. return _st($MethodCategory())._name_theClass_methods_(category,aClass,_st(map)._at_(category));
  672. }, function($ctx2) {$ctx2.fillBlock({category:category},$ctx1)})}));
  673. return $2;
  674. }, function($ctx1) {$ctx1.fill(self,"ownCategoriesOfClass:",{aClass:aClass,map:map},smalltalk.ChunkExporter.klass)})},
  675. args: ["aClass"],
  676. source: "ownCategoriesOfClass: aClass\x0a\x09\x22Issue #143: sort protocol alphabetically\x22\x0a\x0a\x09| map |\x0a\x09map := Dictionary new.\x0a\x09aClass protocolsDo: [:category :methods |\x0a\x09\x09(category match: '^\x5c*') ifFalse: [ map at: category put: methods ]].\x0a\x09^(map keys sorted: [:a :b | a <= b ]) collect: [:category |\x0a\x09\x09MethodCategory name: category theClass: aClass methods: (map at: category) ]",
  677. messageSends: ["new", "protocolsDo:", "ifFalse:", "at:put:", "match:", "collect:", "name:theClass:methods:", "at:", "sorted:", "<=", "keys"],
  678. referencedClasses: ["Dictionary", "MethodCategory"]
  679. }),
  680. smalltalk.ChunkExporter.klass);
  681. smalltalk.addMethod(
  682. smalltalk.method({
  683. selector: "ownCategoriesOfMetaClass:",
  684. category: 'exporting-accessing',
  685. fn: function (aClass){
  686. var self=this;
  687. return smalltalk.withContext(function($ctx1) {
  688. var $1;
  689. $1=self._ownCategoriesOfClass_(_st(aClass)._class());
  690. return $1;
  691. }, function($ctx1) {$ctx1.fill(self,"ownCategoriesOfMetaClass:",{aClass:aClass},smalltalk.ChunkExporter.klass)})},
  692. args: ["aClass"],
  693. source: "ownCategoriesOfMetaClass: aClass\x0a\x09\x22Issue #143: sort protocol alphabetically\x22\x0a\x0a\x09^self ownCategoriesOfClass: aClass class",
  694. messageSends: ["ownCategoriesOfClass:", "class"],
  695. referencedClasses: []
  696. }),
  697. smalltalk.ChunkExporter.klass);
  698. smalltalk.addMethod(
  699. smalltalk.method({
  700. selector: "recipe",
  701. category: 'fileOut',
  702. fn: function (){
  703. var self=this;
  704. var exportCategoryRecipe;
  705. function $PluggableExporter(){return smalltalk.PluggableExporter||(typeof PluggableExporter=="undefined"?nil:PluggableExporter)}
  706. return smalltalk.withContext(function($ctx1) {
  707. var $1;
  708. exportCategoryRecipe=[self.__minus_gt("exportCategoryPrologueOf:on:"),[self.__minus_gt("methodsOfCategory:"),self.__minus_gt("exportMethod:on:")],self.__minus_gt("exportCategoryEpilogueOf:on:")];
  709. $1=[self.__minus_gt("exportPackageDefinitionOf:on:"),[_st($PluggableExporter()).__minus_gt("ownClassesOfPackage:"),self.__minus_gt("exportDefinitionOf:on:"),_st([self.__minus_gt("ownCategoriesOfClass:")]).__comma(exportCategoryRecipe),self.__minus_gt("exportMetaDefinitionOf:on:"),_st([self.__minus_gt("ownCategoriesOfMetaClass:")]).__comma(exportCategoryRecipe)],_st([self.__minus_gt("extensionCategoriesOfPackage:")]).__comma(exportCategoryRecipe)];
  710. return $1;
  711. }, function($ctx1) {$ctx1.fill(self,"recipe",{exportCategoryRecipe:exportCategoryRecipe},smalltalk.ChunkExporter.klass)})},
  712. args: [],
  713. source: "recipe\x0a\x09\x22Export a given package.\x22\x0a\x0a\x09| exportCategoryRecipe |\x0a\x09exportCategoryRecipe := {\x0a\x09\x09self -> #exportCategoryPrologueOf:on:.\x0a\x09\x09{\x0a\x09\x09\x09self -> #methodsOfCategory:.\x0a\x09\x09\x09self -> #exportMethod:on: }.\x0a\x09\x09self -> #exportCategoryEpilogueOf:on: }.\x0a\x0a\x09^{\x0a\x09\x09self -> #exportPackageDefinitionOf:on:.\x0a\x09\x09{\x0a\x09\x09\x09PluggableExporter -> #ownClassesOfPackage:.\x0a\x09\x09\x09self -> #exportDefinitionOf:on:.\x0a\x09\x09\x09{ self -> #ownCategoriesOfClass: }, exportCategoryRecipe.\x0a\x09\x09\x09self -> #exportMetaDefinitionOf:on:.\x0a\x09\x09\x09{ self -> #ownCategoriesOfMetaClass: }, exportCategoryRecipe }.\x0a\x09\x09{ self -> #extensionCategoriesOfPackage: }, exportCategoryRecipe\x0a\x09}",
  714. messageSends: ["->", ","],
  715. referencedClasses: ["PluggableExporter"]
  716. }),
  717. smalltalk.ChunkExporter.klass);
  718. smalltalk.addClass('Exporter', smalltalk.AbstractExporter, [], 'Importer-Exporter');
  719. smalltalk.Exporter.comment="I am responsible for outputting Amber code into a JavaScript string.\x0a\x0aThe generated output is enough to reconstruct the exported data, including Smalltalk source code and other metadata.\x0a\x0a## Use case\x0a\x0aI am typically used to save code outside of the Amber runtime (committing to disk, etc.).\x0a\x0a## API\x0a\x0aUse `#exportAll`, `#exportClass:` or `#exportPackage:` methods.";
  720. smalltalk.addMethod(
  721. smalltalk.method({
  722. selector: "classNameFor:",
  723. category: 'as yet unclassified',
  724. fn: function (aClass){
  725. var self=this;
  726. return smalltalk.withContext(function($ctx1) {
  727. var $2,$3,$1;
  728. $2=_st(aClass)._isMetaclass();
  729. if(smalltalk.assert($2)){
  730. $1=_st(_st(_st(aClass)._instanceClass())._name()).__comma(".klass");
  731. } else {
  732. $3=_st(aClass)._isNil();
  733. if(smalltalk.assert($3)){
  734. $1="nil";
  735. } else {
  736. $1=_st(aClass)._name();
  737. };
  738. };
  739. return $1;
  740. }, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},smalltalk.Exporter)})},
  741. args: ["aClass"],
  742. source: "classNameFor: aClass\x0a\x09^aClass isMetaclass\x0a\x09\x09ifTrue: [ aClass instanceClass name, '.klass' ]\x0a\x09\x09ifFalse: [\x0a\x09\x09\x09aClass isNil\x0a\x09\x09\x09\x09ifTrue: [ 'nil' ]\x0a\x09\x09\x09\x09ifFalse: [ aClass name ] ]",
  743. messageSends: ["ifTrue:ifFalse:", ",", "name", "instanceClass", "isNil", "isMetaclass"],
  744. referencedClasses: []
  745. }),
  746. smalltalk.Exporter);
  747. smalltalk.addMethod(
  748. smalltalk.method({
  749. selector: "exportDefinitionOf:on:",
  750. category: 'exporting-output',
  751. fn: function (aClass,aStream){
  752. var self=this;
  753. return smalltalk.withContext(function($ctx1) {
  754. var $1,$2,$3,$4,$5,$6,$7;
  755. $1=aStream;
  756. _st($1)._lf();
  757. _st($1)._nextPutAll_("smalltalk.addClass(");
  758. _st($1)._nextPutAll_(_st("'".__comma(self._classNameFor_(aClass))).__comma("', "));
  759. _st($1)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aClass)._superclass())));
  760. $2=_st($1)._nextPutAll_(", [");
  761. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  762. return smalltalk.withContext(function($ctx2) {
  763. return _st(aStream)._nextPutAll_(_st("'".__comma(each)).__comma("'"));
  764. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  765. return smalltalk.withContext(function($ctx2) {
  766. return _st(aStream)._nextPutAll_(", ");
  767. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  768. $3=aStream;
  769. _st($3)._nextPutAll_("], '");
  770. _st($3)._nextPutAll_(_st(_st(aClass)._category()).__comma("'"));
  771. $4=_st($3)._nextPutAll_(");");
  772. $5=_st(_st(aClass)._comment())._notEmpty();
  773. if(smalltalk.assert($5)){
  774. $6=aStream;
  775. _st($6)._lf();
  776. _st($6)._nextPutAll_("smalltalk.");
  777. _st($6)._nextPutAll_(self._classNameFor_(aClass));
  778. _st($6)._nextPutAll_(".comment=");
  779. _st($6)._nextPutAll_(_st(_st(aClass)._comment())._asJavascript());
  780. $7=_st($6)._nextPutAll_(";");
  781. $7;
  782. };
  783. _st(aStream)._lf();
  784. return self}, function($ctx1) {$ctx1.fill(self,"exportDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.Exporter)})},
  785. args: ["aClass", "aStream"],
  786. source: "exportDefinitionOf: aClass on: aStream\x0a\x09aStream\x0a\x09\x09lf;\x0a\x09\x09nextPutAll: 'smalltalk.addClass(';\x0a\x09\x09nextPutAll: '''', (self classNameFor: aClass), ''', ';\x0a\x09\x09nextPutAll: 'smalltalk.', (self classNameFor: aClass superclass);\x0a\x09\x09nextPutAll: ', ['.\x0a\x09aClass instanceVariableNames\x0a\x09\x09do: [:each | aStream nextPutAll: '''', each, '''']\x0a\x09\x09separatedBy: [aStream nextPutAll: ', '].\x0a\x09aStream\x0a\x09\x09nextPutAll: '], ''';\x0a\x09\x09nextPutAll: aClass category, '''';\x0a\x09\x09nextPutAll: ');'.\x0a\x09aClass comment notEmpty ifTrue: [\x0a\x09\x09aStream\x0a\x09\x09\x09lf;\x0a\x09\x09nextPutAll: 'smalltalk.';\x0a\x09\x09nextPutAll: (self classNameFor: aClass);\x0a\x09\x09nextPutAll: '.comment=';\x0a\x09\x09nextPutAll: aClass comment asJavascript;\x0a\x09\x09nextPutAll: ';'].\x0a\x09aStream lf",
  787. messageSends: ["lf", "nextPutAll:", ",", "classNameFor:", "superclass", "do:separatedBy:", "instanceVariableNames", "category", "ifTrue:", "asJavascript", "comment", "notEmpty"],
  788. referencedClasses: []
  789. }),
  790. smalltalk.Exporter);
  791. smalltalk.addMethod(
  792. smalltalk.method({
  793. selector: "exportMetaDefinitionOf:on:",
  794. category: 'exporting-output',
  795. fn: function (aClass,aStream){
  796. var self=this;
  797. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  798. return smalltalk.withContext(function($ctx1) {
  799. var $1,$2,$3;
  800. _st(aStream)._lf();
  801. $1=_st(_st(_st(aClass)._class())._instanceVariableNames())._isEmpty();
  802. if(! smalltalk.assert($1)){
  803. $2=aStream;
  804. _st($2)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aClass)._class())));
  805. $3=_st($2)._nextPutAll_(".iVarNames = [");
  806. $3;
  807. _st(_st(_st(aClass)._class())._instanceVariableNames())._do_separatedBy_((function(each){
  808. return smalltalk.withContext(function($ctx2) {
  809. return _st(aStream)._nextPutAll_(_st("'".__comma(each)).__comma("'"));
  810. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  811. return smalltalk.withContext(function($ctx2) {
  812. return _st(aStream)._nextPutAll_(",");
  813. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  814. _st(aStream)._nextPutAll_("];".__comma(_st($String())._lf()));
  815. };
  816. return self}, function($ctx1) {$ctx1.fill(self,"exportMetaDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.Exporter)})},
  817. args: ["aClass", "aStream"],
  818. source: "exportMetaDefinitionOf: aClass on: aStream\x0a\x09aStream lf.\x0a\x09aClass class instanceVariableNames isEmpty ifFalse: [\x0a\x09\x09aStream\x0a\x09\x09nextPutAll: 'smalltalk.', (self classNameFor: aClass class);\x0a\x09\x09nextPutAll: '.iVarNames = ['.\x0a\x09\x09aClass class instanceVariableNames\x0a\x09\x09do: [:each | aStream nextPutAll: '''', each, '''']\x0a\x09\x09separatedBy: [aStream nextPutAll: ','].\x0a\x09\x09aStream nextPutAll: '];', String lf]",
  819. messageSends: ["lf", "ifFalse:", "nextPutAll:", ",", "classNameFor:", "class", "do:separatedBy:", "instanceVariableNames", "isEmpty"],
  820. referencedClasses: ["String"]
  821. }),
  822. smalltalk.Exporter);
  823. smalltalk.addMethod(
  824. smalltalk.method({
  825. selector: "exportMethod:on:",
  826. category: 'exporting-output',
  827. fn: function (aMethod,aStream){
  828. var self=this;
  829. return smalltalk.withContext(function($ctx1) {
  830. var $1,$2,$3,$4;
  831. $1=aStream;
  832. _st($1)._nextPutAll_("smalltalk.addMethod(");
  833. _st($1)._lf();
  834. _st($1)._nextPutAll_("smalltalk.method({");
  835. _st($1)._lf();
  836. _st($1)._nextPutAll_(_st("selector: ".__comma(_st(_st(aMethod)._selector())._asJavascript())).__comma(","));
  837. _st($1)._lf();
  838. _st($1)._nextPutAll_(_st("category: '".__comma(_st(aMethod)._category())).__comma("',"));
  839. _st($1)._lf();
  840. _st($1)._nextPutAll_(_st("fn: ".__comma(_st(_st(aMethod)._fn())._compiledSource())).__comma(","));
  841. _st($1)._lf();
  842. _st($1)._nextPutAll_(_st("args: ".__comma(_st(_st(aMethod)._arguments())._asJavascript())).__comma(","));
  843. _st($1)._lf();
  844. _st($1)._nextPutAll_(_st("source: ".__comma(_st(_st(aMethod)._source())._asJavascript())).__comma(","));
  845. _st($1)._lf();
  846. _st($1)._nextPutAll_(_st("messageSends: ".__comma(_st(_st(aMethod)._messageSends())._asJavascript())).__comma(","));
  847. _st($1)._lf();
  848. $2=_st($1)._nextPutAll_("referencedClasses: ".__comma(_st(_st(aMethod)._referencedClasses())._asJavascript()));
  849. $3=aStream;
  850. _st($3)._lf();
  851. _st($3)._nextPutAll_("}),");
  852. _st($3)._lf();
  853. _st($3)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aMethod)._methodClass())));
  854. _st($3)._nextPutAll_(");");
  855. _st($3)._lf();
  856. $4=_st($3)._lf();
  857. return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:on:",{aMethod:aMethod,aStream:aStream},smalltalk.Exporter)})},
  858. args: ["aMethod", "aStream"],
  859. source: "exportMethod: aMethod on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: 'smalltalk.addMethod(';lf;\x0a\x09\x09\x22nextPutAll: aMethod selector asSelector asJavascript, ',';lf;\x22\x0a\x09\x09nextPutAll: 'smalltalk.method({';lf;\x0a\x09\x09nextPutAll: 'selector: ', aMethod selector asJavascript, ',';lf;\x0a\x09\x09nextPutAll: 'category: ''', aMethod category, ''',';lf;\x0a\x09\x09nextPutAll: 'fn: ', aMethod fn compiledSource, ',';lf;\x0a\x09\x09nextPutAll: 'args: ', aMethod arguments asJavascript, ','; lf;\x0a\x09\x09nextPutAll: 'source: ', aMethod source asJavascript, ',';lf;\x0a\x09\x09nextPutAll: 'messageSends: ', aMethod messageSends asJavascript, ',';lf;\x0a\x09\x09nextPutAll: 'referencedClasses: ', aMethod referencedClasses asJavascript.\x0a\x09aStream\x0a\x09\x09lf;\x0a\x09\x09nextPutAll: '}),';lf;\x0a\x09\x09nextPutAll: 'smalltalk.', (self classNameFor: aMethod methodClass);\x0a\x09\x09nextPutAll: ');';lf;lf",
  860. messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "selector", "category", "compiledSource", "fn", "arguments", "source", "messageSends", "referencedClasses", "classNameFor:", "methodClass"],
  861. referencedClasses: []
  862. }),
  863. smalltalk.Exporter);
  864. smalltalk.addMethod(
  865. smalltalk.method({
  866. selector: "exportPackageDefinitionOf:on:",
  867. category: 'exporting-output',
  868. fn: function (package_,aStream){
  869. var self=this;
  870. return smalltalk.withContext(function($ctx1) {
  871. var $1,$2;
  872. $1=aStream;
  873. _st($1)._nextPutAll_("smalltalk.addPackage(");
  874. _st($1)._nextPutAll_(_st("'".__comma(_st(package_)._name())).__comma("');"));
  875. $2=_st($1)._lf();
  876. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageDefinitionOf:on:",{package_:package_,aStream:aStream},smalltalk.Exporter)})},
  877. args: ["package", "aStream"],
  878. source: "exportPackageDefinitionOf: package on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: 'smalltalk.addPackage(';\x0a\x09\x09nextPutAll: '''', package name, ''');';\x0a\x09\x09lf",
  879. messageSends: ["nextPutAll:", ",", "name", "lf"],
  880. referencedClasses: []
  881. }),
  882. smalltalk.Exporter);
  883. smalltalk.addMethod(
  884. smalltalk.method({
  885. selector: "exportPackageEpilogueOf:on:",
  886. category: 'exporting-output',
  887. fn: function (aPackage,aStream){
  888. var self=this;
  889. return smalltalk.withContext(function($ctx1) {
  890. var $1,$2;
  891. $1=aStream;
  892. _st($1)._nextPutAll_("})(global_smalltalk,global_nil,global__st);");
  893. $2=_st($1)._lf();
  894. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageEpilogueOf:on:",{aPackage:aPackage,aStream:aStream},smalltalk.Exporter)})},
  895. args: ["aPackage", "aStream"],
  896. source: "exportPackageEpilogueOf: aPackage on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: '})(global_smalltalk,global_nil,global__st);';\x0a\x09\x09lf",
  897. messageSends: ["nextPutAll:", "lf"],
  898. referencedClasses: []
  899. }),
  900. smalltalk.Exporter);
  901. smalltalk.addMethod(
  902. smalltalk.method({
  903. selector: "exportPackagePrologueOf:on:",
  904. category: 'exporting-output',
  905. fn: function (aPackage,aStream){
  906. var self=this;
  907. return smalltalk.withContext(function($ctx1) {
  908. var $1,$2;
  909. $1=aStream;
  910. _st($1)._nextPutAll_("(function(smalltalk,nil,_st){");
  911. $2=_st($1)._lf();
  912. return self}, function($ctx1) {$ctx1.fill(self,"exportPackagePrologueOf:on:",{aPackage:aPackage,aStream:aStream},smalltalk.Exporter)})},
  913. args: ["aPackage", "aStream"],
  914. source: "exportPackagePrologueOf: aPackage on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: '(function(smalltalk,nil,_st){';\x0a\x09\x09lf",
  915. messageSends: ["nextPutAll:", "lf"],
  916. referencedClasses: []
  917. }),
  918. smalltalk.Exporter);
  919. smalltalk.addMethod(
  920. smalltalk.method({
  921. selector: "extensionMethodsOfPackage:",
  922. category: 'exporting-accessing',
  923. fn: function (package_){
  924. var self=this;
  925. var name,result;
  926. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  927. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  928. function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
  929. return smalltalk.withContext(function($ctx1) {
  930. var $1;
  931. name=_st(package_)._name();
  932. result=_st($OrderedCollection())._new();
  933. _st(_st($Package())._sortedClasses_(_st(_st($Smalltalk())._current())._classes()))._do_((function(each){
  934. return smalltalk.withContext(function($ctx2) {
  935. return _st([each,_st(each)._class()])._do_((function(aClass){
  936. return smalltalk.withContext(function($ctx3) {
  937. return _st(result)._addAll_(_st(_st(_st(_st(aClass)._methodDictionary())._values())._sorted_((function(a,b){
  938. return smalltalk.withContext(function($ctx4) {
  939. return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  940. }, function($ctx4) {$ctx4.fillBlock({a:a,b:b},$ctx3)})})))._select_((function(method){
  941. return smalltalk.withContext(function($ctx4) {
  942. return _st(_st(method)._category())._match_("^\x5c*".__comma(name));
  943. }, function($ctx4) {$ctx4.fillBlock({method:method},$ctx3)})})));
  944. }, function($ctx3) {$ctx3.fillBlock({aClass:aClass},$ctx2)})}));
  945. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  946. $1=result;
  947. return $1;
  948. }, function($ctx1) {$ctx1.fill(self,"extensionMethodsOfPackage:",{package_:package_,name:name,result:result},smalltalk.Exporter)})},
  949. args: ["package"],
  950. source: "extensionMethodsOfPackage: package\x0a\x09\x22Issue #143: sort classes and methods alphabetically\x22\x0a\x0a\x09| name result |\x0a\x09name := package name.\x0a\x09result := OrderedCollection new.\x0a\x09(Package sortedClasses: Smalltalk current classes) do: [:each |\x0a\x09\x09{each. each class} do: [:aClass |\x0a\x09\x09\x09result addAll: (((aClass methodDictionary values)\x0a\x09\x09\x09\x09sorted: [:a :b | a selector <= b selector])\x0a\x09\x09\x09\x09select: [:method | method category match: '^\x5c*', name]) ]].\x0a\x09^result",
  951. messageSends: ["name", "new", "do:", "addAll:", "select:", "match:", ",", "category", "sorted:", "<=", "selector", "values", "methodDictionary", "class", "sortedClasses:", "classes", "current"],
  952. referencedClasses: ["OrderedCollection", "Smalltalk", "Package"]
  953. }),
  954. smalltalk.Exporter);
  955. smalltalk.addMethod(
  956. smalltalk.method({
  957. selector: "ownMethodsOfClass:",
  958. category: 'exporting-accessing',
  959. fn: function (aClass){
  960. var self=this;
  961. return smalltalk.withContext(function($ctx1) {
  962. var $1;
  963. $1=_st(_st(_st(_st(aClass)._methodDictionary())._values())._sorted_((function(a,b){
  964. return smalltalk.withContext(function($ctx2) {
  965. return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  966. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})})))._reject_((function(each){
  967. return smalltalk.withContext(function($ctx2) {
  968. return _st(_st(each)._category())._match_("^\x5c*");
  969. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  970. return $1;
  971. }, function($ctx1) {$ctx1.fill(self,"ownMethodsOfClass:",{aClass:aClass},smalltalk.Exporter)})},
  972. args: ["aClass"],
  973. source: "ownMethodsOfClass: aClass\x0a\x09\x22Issue #143: sort methods alphabetically\x22\x0a\x0a\x09^((aClass methodDictionary values) sorted: [:a :b | a selector <= b selector])\x0a\x09\x09reject: [:each | (each category match: '^\x5c*')]",
  974. messageSends: ["reject:", "match:", "category", "sorted:", "<=", "selector", "values", "methodDictionary"],
  975. referencedClasses: []
  976. }),
  977. smalltalk.Exporter);
  978. smalltalk.addMethod(
  979. smalltalk.method({
  980. selector: "ownMethodsOfMetaClass:",
  981. category: 'exporting-accessing',
  982. fn: function (aClass){
  983. var self=this;
  984. return smalltalk.withContext(function($ctx1) {
  985. var $1;
  986. $1=self._ownMethodsOfClass_(_st(aClass)._class());
  987. return $1;
  988. }, function($ctx1) {$ctx1.fill(self,"ownMethodsOfMetaClass:",{aClass:aClass},smalltalk.Exporter)})},
  989. args: ["aClass"],
  990. source: "ownMethodsOfMetaClass: aClass\x0a\x09\x22Issue #143: sort methods alphabetically\x22\x0a\x0a\x09^self ownMethodsOfClass: aClass class",
  991. messageSends: ["ownMethodsOfClass:", "class"],
  992. referencedClasses: []
  993. }),
  994. smalltalk.Exporter);
  995. smalltalk.addMethod(
  996. smalltalk.method({
  997. selector: "recipe",
  998. category: 'fileOut',
  999. fn: function (){
  1000. var self=this;
  1001. function $PluggableExporter(){return smalltalk.PluggableExporter||(typeof PluggableExporter=="undefined"?nil:PluggableExporter)}
  1002. return smalltalk.withContext(function($ctx1) {
  1003. var $1;
  1004. $1=[self.__minus_gt("exportPackagePrologueOf:on:"),self.__minus_gt("exportPackageDefinitionOf:on:"),[_st($PluggableExporter()).__minus_gt("ownClassesOfPackage:"),self.__minus_gt("exportDefinitionOf:on:"),[self.__minus_gt("ownMethodsOfClass:"),self.__minus_gt("exportMethod:on:")],self.__minus_gt("exportMetaDefinitionOf:on:"),[self.__minus_gt("ownMethodsOfMetaClass:"),self.__minus_gt("exportMethod:on:")]],[self.__minus_gt("extensionMethodsOfPackage:"),self.__minus_gt("exportMethod:on:")],self.__minus_gt("exportPackageEpilogueOf:on:")];
  1005. return $1;
  1006. }, function($ctx1) {$ctx1.fill(self,"recipe",{},smalltalk.Exporter)})},
  1007. args: [],
  1008. source: "recipe\x0a\x09\x22Export a given package.\x22\x0a\x0a\x09^{\x0a\x09\x09self -> #exportPackagePrologueOf:on:.\x0a\x09\x09self -> #exportPackageDefinitionOf:on:.\x0a\x09\x09{\x0a\x09\x09\x09PluggableExporter -> #ownClassesOfPackage:.\x0a\x09\x09\x09self -> #exportDefinitionOf:on:.\x0a\x09\x09\x09{\x0a\x09\x09\x09\x09self -> #ownMethodsOfClass:.\x0a\x09\x09\x09\x09self -> #exportMethod:on: }.\x0a\x09\x09\x09self -> #exportMetaDefinitionOf:on:.\x0a\x09\x09\x09{\x0a\x09\x09\x09\x09self -> #ownMethodsOfMetaClass:.\x0a\x09\x09\x09\x09self -> #exportMethod:on: } }.\x0a\x09\x09{\x0a\x09\x09\x09self -> #extensionMethodsOfPackage:.\x0a\x09\x09\x09self -> #exportMethod:on: }.\x0a\x09\x09self -> #exportPackageEpilogueOf:on:\x0a\x09}",
  1009. messageSends: ["->"],
  1010. referencedClasses: ["PluggableExporter"]
  1011. }),
  1012. smalltalk.Exporter);
  1013. smalltalk.addMethod(
  1014. smalltalk.method({
  1015. selector: "classNameFor:",
  1016. category: 'private',
  1017. fn: function (aClass){
  1018. var self=this;
  1019. return smalltalk.withContext(function($ctx1) {
  1020. var $2,$3,$1;
  1021. $2=_st(aClass)._isMetaclass();
  1022. if(smalltalk.assert($2)){
  1023. $1=_st(_st(_st(aClass)._instanceClass())._name()).__comma(".klass");
  1024. } else {
  1025. $3=_st(aClass)._isNil();
  1026. if(smalltalk.assert($3)){
  1027. $1="nil";
  1028. } else {
  1029. $1=_st(aClass)._name();
  1030. };
  1031. };
  1032. return $1;
  1033. }, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},smalltalk.Exporter.klass)})},
  1034. args: ["aClass"],
  1035. source: "classNameFor: aClass\x0a\x09^aClass isMetaclass\x0a\x09\x09ifTrue: [aClass instanceClass name, '.klass']\x0a\x09\x09ifFalse: [\x0a\x09\x09aClass isNil\x0a\x09\x09\x09ifTrue: ['nil']\x0a\x09\x09\x09ifFalse: [aClass name]]",
  1036. messageSends: ["ifTrue:ifFalse:", ",", "name", "instanceClass", "isNil", "isMetaclass"],
  1037. referencedClasses: []
  1038. }),
  1039. smalltalk.Exporter.klass);
  1040. smalltalk.addMethod(
  1041. smalltalk.method({
  1042. selector: "exportDefinitionOf:on:",
  1043. category: 'exporting-output',
  1044. fn: function (aClass,aStream){
  1045. var self=this;
  1046. return smalltalk.withContext(function($ctx1) {
  1047. var $1,$2,$3,$4,$5,$6,$7;
  1048. $1=aStream;
  1049. _st($1)._lf();
  1050. _st($1)._nextPutAll_("smalltalk.addClass(");
  1051. _st($1)._nextPutAll_(_st("'".__comma(self._classNameFor_(aClass))).__comma("', "));
  1052. _st($1)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aClass)._superclass())));
  1053. $2=_st($1)._nextPutAll_(", [");
  1054. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  1055. return smalltalk.withContext(function($ctx2) {
  1056. return _st(aStream)._nextPutAll_(_st("'".__comma(each)).__comma("'"));
  1057. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  1058. return smalltalk.withContext(function($ctx2) {
  1059. return _st(aStream)._nextPutAll_(", ");
  1060. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1061. $3=aStream;
  1062. _st($3)._nextPutAll_("], '");
  1063. _st($3)._nextPutAll_(_st(_st(aClass)._category()).__comma("'"));
  1064. $4=_st($3)._nextPutAll_(");");
  1065. $5=_st(_st(aClass)._comment())._notEmpty();
  1066. if(smalltalk.assert($5)){
  1067. $6=aStream;
  1068. _st($6)._lf();
  1069. _st($6)._nextPutAll_("smalltalk.");
  1070. _st($6)._nextPutAll_(self._classNameFor_(aClass));
  1071. _st($6)._nextPutAll_(".comment=");
  1072. _st($6)._nextPutAll_(_st(_st(aClass)._comment())._asJavascript());
  1073. $7=_st($6)._nextPutAll_(";");
  1074. $7;
  1075. };
  1076. _st(aStream)._lf();
  1077. return self}, function($ctx1) {$ctx1.fill(self,"exportDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.Exporter.klass)})},
  1078. args: ["aClass", "aStream"],
  1079. source: "exportDefinitionOf: aClass on: aStream\x0a\x09aStream\x0a\x09\x09lf;\x0a\x09\x09nextPutAll: 'smalltalk.addClass(';\x0a\x09\x09nextPutAll: '''', (self classNameFor: aClass), ''', ';\x0a\x09\x09nextPutAll: 'smalltalk.', (self classNameFor: aClass superclass);\x0a\x09\x09nextPutAll: ', ['.\x0a\x09aClass instanceVariableNames\x0a\x09\x09do: [:each | aStream nextPutAll: '''', each, '''']\x0a\x09\x09separatedBy: [aStream nextPutAll: ', '].\x0a\x09aStream\x0a\x09\x09nextPutAll: '], ''';\x0a\x09\x09nextPutAll: aClass category, '''';\x0a\x09\x09nextPutAll: ');'.\x0a\x09aClass comment notEmpty ifTrue: [\x0a\x09\x09aStream\x0a\x09\x09\x09lf;\x0a\x09\x09nextPutAll: 'smalltalk.';\x0a\x09\x09nextPutAll: (self classNameFor: aClass);\x0a\x09\x09nextPutAll: '.comment=';\x0a\x09\x09nextPutAll: aClass comment asJavascript;\x0a\x09\x09nextPutAll: ';'].\x0a\x09aStream lf",
  1080. messageSends: ["lf", "nextPutAll:", ",", "classNameFor:", "superclass", "do:separatedBy:", "instanceVariableNames", "category", "ifTrue:", "asJavascript", "comment", "notEmpty"],
  1081. referencedClasses: []
  1082. }),
  1083. smalltalk.Exporter.klass);
  1084. smalltalk.addMethod(
  1085. smalltalk.method({
  1086. selector: "exportMetaDefinitionOf:on:",
  1087. category: 'exporting-output',
  1088. fn: function (aClass,aStream){
  1089. var self=this;
  1090. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  1091. return smalltalk.withContext(function($ctx1) {
  1092. var $1,$2,$3;
  1093. _st(aStream)._lf();
  1094. $1=_st(_st(_st(aClass)._class())._instanceVariableNames())._isEmpty();
  1095. if(! smalltalk.assert($1)){
  1096. $2=aStream;
  1097. _st($2)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aClass)._class())));
  1098. $3=_st($2)._nextPutAll_(".iVarNames = [");
  1099. $3;
  1100. _st(_st(_st(aClass)._class())._instanceVariableNames())._do_separatedBy_((function(each){
  1101. return smalltalk.withContext(function($ctx2) {
  1102. return _st(aStream)._nextPutAll_(_st("'".__comma(each)).__comma("'"));
  1103. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  1104. return smalltalk.withContext(function($ctx2) {
  1105. return _st(aStream)._nextPutAll_(",");
  1106. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1107. _st(aStream)._nextPutAll_("];".__comma(_st($String())._lf()));
  1108. };
  1109. return self}, function($ctx1) {$ctx1.fill(self,"exportMetaDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.Exporter.klass)})},
  1110. args: ["aClass", "aStream"],
  1111. source: "exportMetaDefinitionOf: aClass on: aStream\x0a\x09aStream lf.\x0a\x09aClass class instanceVariableNames isEmpty ifFalse: [\x0a\x09\x09aStream\x0a\x09\x09nextPutAll: 'smalltalk.', (self classNameFor: aClass class);\x0a\x09\x09nextPutAll: '.iVarNames = ['.\x0a\x09\x09aClass class instanceVariableNames\x0a\x09\x09do: [:each | aStream nextPutAll: '''', each, '''']\x0a\x09\x09separatedBy: [aStream nextPutAll: ','].\x0a\x09\x09aStream nextPutAll: '];', String lf]",
  1112. messageSends: ["lf", "ifFalse:", "nextPutAll:", ",", "classNameFor:", "class", "do:separatedBy:", "instanceVariableNames", "isEmpty"],
  1113. referencedClasses: ["String"]
  1114. }),
  1115. smalltalk.Exporter.klass);
  1116. smalltalk.addMethod(
  1117. smalltalk.method({
  1118. selector: "exportMethod:on:",
  1119. category: 'exporting-output',
  1120. fn: function (aMethod,aStream){
  1121. var self=this;
  1122. return smalltalk.withContext(function($ctx1) {
  1123. var $1,$2,$3,$4;
  1124. $1=aStream;
  1125. _st($1)._nextPutAll_("smalltalk.addMethod(");
  1126. _st($1)._lf();
  1127. _st($1)._nextPutAll_("smalltalk.method({");
  1128. _st($1)._lf();
  1129. _st($1)._nextPutAll_(_st("selector: ".__comma(_st(_st(aMethod)._selector())._asJavascript())).__comma(","));
  1130. _st($1)._lf();
  1131. _st($1)._nextPutAll_(_st("category: '".__comma(_st(aMethod)._category())).__comma("',"));
  1132. _st($1)._lf();
  1133. _st($1)._nextPutAll_(_st("fn: ".__comma(_st(_st(aMethod)._fn())._compiledSource())).__comma(","));
  1134. _st($1)._lf();
  1135. _st($1)._nextPutAll_(_st("args: ".__comma(_st(_st(aMethod)._arguments())._asJavascript())).__comma(","));
  1136. _st($1)._lf();
  1137. _st($1)._nextPutAll_(_st("source: ".__comma(_st(_st(aMethod)._source())._asJavascript())).__comma(","));
  1138. _st($1)._lf();
  1139. _st($1)._nextPutAll_(_st("messageSends: ".__comma(_st(_st(aMethod)._messageSends())._asJavascript())).__comma(","));
  1140. _st($1)._lf();
  1141. $2=_st($1)._nextPutAll_("referencedClasses: ".__comma(_st(_st(aMethod)._referencedClasses())._asJavascript()));
  1142. $3=aStream;
  1143. _st($3)._lf();
  1144. _st($3)._nextPutAll_("}),");
  1145. _st($3)._lf();
  1146. _st($3)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aMethod)._methodClass())));
  1147. _st($3)._nextPutAll_(");");
  1148. _st($3)._lf();
  1149. $4=_st($3)._lf();
  1150. return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:on:",{aMethod:aMethod,aStream:aStream},smalltalk.Exporter.klass)})},
  1151. args: ["aMethod", "aStream"],
  1152. source: "exportMethod: aMethod on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: 'smalltalk.addMethod(';lf;\x0a\x09\x09\x22nextPutAll: aMethod selector asSelector asJavascript, ',';lf;\x22\x0a\x09\x09nextPutAll: 'smalltalk.method({';lf;\x0a\x09\x09nextPutAll: 'selector: ', aMethod selector asJavascript, ',';lf;\x0a\x09\x09nextPutAll: 'category: ''', aMethod category, ''',';lf;\x0a\x09\x09nextPutAll: 'fn: ', aMethod fn compiledSource, ',';lf;\x0a\x09\x09nextPutAll: 'args: ', aMethod arguments asJavascript, ','; lf;\x0a\x09\x09nextPutAll: 'source: ', aMethod source asJavascript, ',';lf;\x0a\x09\x09nextPutAll: 'messageSends: ', aMethod messageSends asJavascript, ',';lf;\x0a\x09\x09nextPutAll: 'referencedClasses: ', aMethod referencedClasses asJavascript.\x0a\x09aStream\x0a\x09\x09lf;\x0a\x09\x09nextPutAll: '}),';lf;\x0a\x09\x09nextPutAll: 'smalltalk.', (self classNameFor: aMethod methodClass);\x0a\x09\x09nextPutAll: ');';lf;lf",
  1153. messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "selector", "category", "compiledSource", "fn", "arguments", "source", "messageSends", "referencedClasses", "classNameFor:", "methodClass"],
  1154. referencedClasses: []
  1155. }),
  1156. smalltalk.Exporter.klass);
  1157. smalltalk.addMethod(
  1158. smalltalk.method({
  1159. selector: "exportPackageDefinitionOf:on:",
  1160. category: 'exporting-output',
  1161. fn: function (package_,aStream){
  1162. var self=this;
  1163. return smalltalk.withContext(function($ctx1) {
  1164. var $1,$2;
  1165. $1=aStream;
  1166. _st($1)._nextPutAll_("smalltalk.addPackage(");
  1167. _st($1)._nextPutAll_(_st("'".__comma(_st(package_)._name())).__comma("');"));
  1168. $2=_st($1)._lf();
  1169. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageDefinitionOf:on:",{package_:package_,aStream:aStream},smalltalk.Exporter.klass)})},
  1170. args: ["package", "aStream"],
  1171. source: "exportPackageDefinitionOf: package on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: 'smalltalk.addPackage(';\x0a\x09\x09nextPutAll: '''', package name, ''');';\x0a\x09\x09lf",
  1172. messageSends: ["nextPutAll:", ",", "name", "lf"],
  1173. referencedClasses: []
  1174. }),
  1175. smalltalk.Exporter.klass);
  1176. smalltalk.addMethod(
  1177. smalltalk.method({
  1178. selector: "exportPackageEpilogueOf:on:",
  1179. category: 'exporting-output',
  1180. fn: function (aPackage,aStream){
  1181. var self=this;
  1182. return smalltalk.withContext(function($ctx1) {
  1183. var $1,$2;
  1184. $1=aStream;
  1185. _st($1)._nextPutAll_("})(global_smalltalk,global_nil,global__st);");
  1186. $2=_st($1)._lf();
  1187. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageEpilogueOf:on:",{aPackage:aPackage,aStream:aStream},smalltalk.Exporter.klass)})},
  1188. args: ["aPackage", "aStream"],
  1189. source: "exportPackageEpilogueOf: aPackage on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: '})(global_smalltalk,global_nil,global__st);';\x0a\x09\x09lf",
  1190. messageSends: ["nextPutAll:", "lf"],
  1191. referencedClasses: []
  1192. }),
  1193. smalltalk.Exporter.klass);
  1194. smalltalk.addMethod(
  1195. smalltalk.method({
  1196. selector: "exportPackagePrologueOf:on:",
  1197. category: 'exporting-output',
  1198. fn: function (aPackage,aStream){
  1199. var self=this;
  1200. return smalltalk.withContext(function($ctx1) {
  1201. var $1,$2;
  1202. $1=aStream;
  1203. _st($1)._nextPutAll_("(function(smalltalk,nil,_st){");
  1204. $2=_st($1)._lf();
  1205. return self}, function($ctx1) {$ctx1.fill(self,"exportPackagePrologueOf:on:",{aPackage:aPackage,aStream:aStream},smalltalk.Exporter.klass)})},
  1206. args: ["aPackage", "aStream"],
  1207. source: "exportPackagePrologueOf: aPackage on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: '(function(smalltalk,nil,_st){';\x0a\x09\x09lf",
  1208. messageSends: ["nextPutAll:", "lf"],
  1209. referencedClasses: []
  1210. }),
  1211. smalltalk.Exporter.klass);
  1212. smalltalk.addMethod(
  1213. smalltalk.method({
  1214. selector: "extensionMethodsOfPackage:",
  1215. category: 'exporting-accessing',
  1216. fn: function (package_){
  1217. var self=this;
  1218. var name,result;
  1219. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  1220. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1221. function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
  1222. return smalltalk.withContext(function($ctx1) {
  1223. var $1;
  1224. name=_st(package_)._name();
  1225. result=_st($OrderedCollection())._new();
  1226. _st(_st($Package())._sortedClasses_(_st(_st($Smalltalk())._current())._classes()))._do_((function(each){
  1227. return smalltalk.withContext(function($ctx2) {
  1228. return _st([each,_st(each)._class()])._do_((function(aClass){
  1229. return smalltalk.withContext(function($ctx3) {
  1230. return _st(result)._addAll_(_st(_st(_st(_st(aClass)._methodDictionary())._values())._sorted_((function(a,b){
  1231. return smalltalk.withContext(function($ctx4) {
  1232. return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  1233. }, function($ctx4) {$ctx4.fillBlock({a:a,b:b},$ctx3)})})))._select_((function(method){
  1234. return smalltalk.withContext(function($ctx4) {
  1235. return _st(_st(method)._category())._match_("^\x5c*".__comma(name));
  1236. }, function($ctx4) {$ctx4.fillBlock({method:method},$ctx3)})})));
  1237. }, function($ctx3) {$ctx3.fillBlock({aClass:aClass},$ctx2)})}));
  1238. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  1239. $1=result;
  1240. return $1;
  1241. }, function($ctx1) {$ctx1.fill(self,"extensionMethodsOfPackage:",{package_:package_,name:name,result:result},smalltalk.Exporter.klass)})},
  1242. args: ["package"],
  1243. source: "extensionMethodsOfPackage: package\x0a\x09\x22Issue #143: sort classes and methods alphabetically\x22\x0a\x0a\x09| name result |\x0a\x09name := package name.\x0a\x09result := OrderedCollection new.\x0a\x09(Package sortedClasses: Smalltalk current classes) do: [:each |\x0a\x09\x09{each. each class} do: [:aClass |\x0a\x09\x09\x09result addAll: (((aClass methodDictionary values)\x0a\x09\x09\x09\x09sorted: [:a :b | a selector <= b selector])\x0a\x09\x09\x09\x09select: [:method | method category match: '^\x5c*', name]) ]].\x0a\x09^result",
  1244. messageSends: ["name", "new", "do:", "addAll:", "select:", "match:", ",", "category", "sorted:", "<=", "selector", "values", "methodDictionary", "class", "sortedClasses:", "classes", "current"],
  1245. referencedClasses: ["OrderedCollection", "Smalltalk", "Package"]
  1246. }),
  1247. smalltalk.Exporter.klass);
  1248. smalltalk.addMethod(
  1249. smalltalk.method({
  1250. selector: "ownMethodsOfClass:",
  1251. category: 'exporting-accessing',
  1252. fn: function (aClass){
  1253. var self=this;
  1254. return smalltalk.withContext(function($ctx1) {
  1255. var $1;
  1256. $1=_st(_st(_st(_st(aClass)._methodDictionary())._values())._sorted_((function(a,b){
  1257. return smalltalk.withContext(function($ctx2) {
  1258. return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  1259. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})})))._reject_((function(each){
  1260. return smalltalk.withContext(function($ctx2) {
  1261. return _st(_st(each)._category())._match_("^\x5c*");
  1262. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  1263. return $1;
  1264. }, function($ctx1) {$ctx1.fill(self,"ownMethodsOfClass:",{aClass:aClass},smalltalk.Exporter.klass)})},
  1265. args: ["aClass"],
  1266. source: "ownMethodsOfClass: aClass\x0a\x09\x22Issue #143: sort methods alphabetically\x22\x0a\x0a\x09^((aClass methodDictionary values) sorted: [:a :b | a selector <= b selector])\x0a\x09\x09reject: [:each | (each category match: '^\x5c*')]",
  1267. messageSends: ["reject:", "match:", "category", "sorted:", "<=", "selector", "values", "methodDictionary"],
  1268. referencedClasses: []
  1269. }),
  1270. smalltalk.Exporter.klass);
  1271. smalltalk.addMethod(
  1272. smalltalk.method({
  1273. selector: "ownMethodsOfMetaClass:",
  1274. category: 'exporting-accessing',
  1275. fn: function (aClass){
  1276. var self=this;
  1277. return smalltalk.withContext(function($ctx1) {
  1278. var $1;
  1279. $1=self._ownMethodsOfClass_(_st(aClass)._class());
  1280. return $1;
  1281. }, function($ctx1) {$ctx1.fill(self,"ownMethodsOfMetaClass:",{aClass:aClass},smalltalk.Exporter.klass)})},
  1282. args: ["aClass"],
  1283. source: "ownMethodsOfMetaClass: aClass\x0a\x09\x22Issue #143: sort methods alphabetically\x22\x0a\x0a\x09^self ownMethodsOfClass: aClass class",
  1284. messageSends: ["ownMethodsOfClass:", "class"],
  1285. referencedClasses: []
  1286. }),
  1287. smalltalk.Exporter.klass);
  1288. smalltalk.addMethod(
  1289. smalltalk.method({
  1290. selector: "recipe",
  1291. category: 'fileOut',
  1292. fn: function (){
  1293. var self=this;
  1294. function $PluggableExporter(){return smalltalk.PluggableExporter||(typeof PluggableExporter=="undefined"?nil:PluggableExporter)}
  1295. return smalltalk.withContext(function($ctx1) {
  1296. var $1;
  1297. $1=[self.__minus_gt("exportPackagePrologueOf:on:"),self.__minus_gt("exportPackageDefinitionOf:on:"),[_st($PluggableExporter()).__minus_gt("ownClassesOfPackage:"),self.__minus_gt("exportDefinitionOf:on:"),[self.__minus_gt("ownMethodsOfClass:"),self.__minus_gt("exportMethod:on:")],self.__minus_gt("exportMetaDefinitionOf:on:"),[self.__minus_gt("ownMethodsOfMetaClass:"),self.__minus_gt("exportMethod:on:")]],[self.__minus_gt("extensionMethodsOfPackage:"),self.__minus_gt("exportMethod:on:")],self.__minus_gt("exportPackageEpilogueOf:on:")];
  1298. return $1;
  1299. }, function($ctx1) {$ctx1.fill(self,"recipe",{},smalltalk.Exporter.klass)})},
  1300. args: [],
  1301. source: "recipe\x0a\x09\x22Export a given package.\x22\x0a\x0a\x09^{\x0a\x09\x09self -> #exportPackagePrologueOf:on:.\x0a\x09\x09self -> #exportPackageDefinitionOf:on:.\x0a\x09\x09{\x0a\x09\x09\x09PluggableExporter -> #ownClassesOfPackage:.\x0a\x09\x09\x09self -> #exportDefinitionOf:on:.\x0a\x09\x09\x09{\x0a\x09\x09\x09\x09self -> #ownMethodsOfClass:.\x0a\x09\x09\x09\x09self -> #exportMethod:on: }.\x0a\x09\x09\x09self -> #exportMetaDefinitionOf:on:.\x0a\x09\x09\x09{\x0a\x09\x09\x09\x09self -> #ownMethodsOfMetaClass:.\x0a\x09\x09\x09\x09self -> #exportMethod:on: } }.\x0a\x09\x09{\x0a\x09\x09\x09self -> #extensionMethodsOfPackage:.\x0a\x09\x09\x09self -> #exportMethod:on: }.\x0a\x09\x09self -> #exportPackageEpilogueOf:on:\x0a\x09}",
  1302. messageSends: ["->"],
  1303. referencedClasses: ["PluggableExporter"]
  1304. }),
  1305. smalltalk.Exporter.klass);
  1306. smalltalk.addClass('StrippedExporter', smalltalk.Exporter, [], 'Importer-Exporter');
  1307. smalltalk.StrippedExporter.comment="I export Amber code into a JavaScript string, but without any optional associated data like the Amber source code.";
  1308. smalltalk.addMethod(
  1309. smalltalk.method({
  1310. selector: "exportDefinitionOf:on:",
  1311. category: 'exporting-output',
  1312. fn: function (aClass,aStream){
  1313. var self=this;
  1314. return smalltalk.withContext(function($ctx1) {
  1315. var $1,$2,$3,$4;
  1316. $1=aStream;
  1317. _st($1)._lf();
  1318. _st($1)._nextPutAll_("smalltalk.addClass(");
  1319. _st($1)._nextPutAll_(_st("'".__comma(self._classNameFor_(aClass))).__comma("', "));
  1320. _st($1)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aClass)._superclass())));
  1321. $2=_st($1)._nextPutAll_(", [");
  1322. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  1323. return smalltalk.withContext(function($ctx2) {
  1324. return _st(aStream)._nextPutAll_(_st("'".__comma(each)).__comma("'"));
  1325. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  1326. return smalltalk.withContext(function($ctx2) {
  1327. return _st(aStream)._nextPutAll_(", ");
  1328. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1329. $3=aStream;
  1330. _st($3)._nextPutAll_("], '");
  1331. _st($3)._nextPutAll_(_st(_st(aClass)._category()).__comma("'"));
  1332. $4=_st($3)._nextPutAll_(");");
  1333. _st(aStream)._lf();
  1334. return self}, function($ctx1) {$ctx1.fill(self,"exportDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.StrippedExporter)})},
  1335. args: ["aClass", "aStream"],
  1336. source: "exportDefinitionOf: aClass on: aStream\x0a\x09aStream\x0a\x09\x09lf;\x0a\x09\x09nextPutAll: 'smalltalk.addClass(';\x0a\x09\x09nextPutAll: '''', (self classNameFor: aClass), ''', ';\x0a\x09\x09nextPutAll: 'smalltalk.', (self classNameFor: aClass superclass);\x0a\x09\x09nextPutAll: ', ['.\x0a\x09aClass instanceVariableNames\x0a\x09\x09do: [:each | aStream nextPutAll: '''', each, '''']\x0a\x09\x09separatedBy: [aStream nextPutAll: ', '].\x0a\x09aStream\x0a\x09\x09nextPutAll: '], ''';\x0a\x09\x09nextPutAll: aClass category, '''';\x0a\x09\x09nextPutAll: ');'.\x0a\x09aStream lf",
  1337. messageSends: ["lf", "nextPutAll:", ",", "classNameFor:", "superclass", "do:separatedBy:", "instanceVariableNames", "category"],
  1338. referencedClasses: []
  1339. }),
  1340. smalltalk.StrippedExporter);
  1341. smalltalk.addMethod(
  1342. smalltalk.method({
  1343. selector: "exportMethod:on:",
  1344. category: 'exporting-output',
  1345. fn: function (aMethod,aStream){
  1346. var self=this;
  1347. return smalltalk.withContext(function($ctx1) {
  1348. var $1,$2;
  1349. $1=aStream;
  1350. _st($1)._nextPutAll_("smalltalk.addMethod(");
  1351. _st($1)._lf();
  1352. _st($1)._nextPutAll_("smalltalk.method({");
  1353. _st($1)._lf();
  1354. _st($1)._nextPutAll_(_st("selector: ".__comma(_st(_st(aMethod)._selector())._asJavascript())).__comma(","));
  1355. _st($1)._lf();
  1356. _st($1)._nextPutAll_(_st("fn: ".__comma(_st(_st(aMethod)._fn())._compiledSource())).__comma(","));
  1357. _st($1)._lf();
  1358. _st($1)._nextPutAll_("messageSends: ".__comma(_st(_st(aMethod)._messageSends())._asJavascript()));
  1359. _st($1)._nextPutAll_("}),");
  1360. _st($1)._lf();
  1361. _st($1)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aMethod)._methodClass())));
  1362. _st($1)._nextPutAll_(");");
  1363. _st($1)._lf();
  1364. $2=_st($1)._lf();
  1365. return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:on:",{aMethod:aMethod,aStream:aStream},smalltalk.StrippedExporter)})},
  1366. args: ["aMethod", "aStream"],
  1367. source: "exportMethod: aMethod on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: 'smalltalk.addMethod(';lf;\x0a\x09\x09\x22nextPutAll: aMethod selector asSelector asJavascript, ',';lf;\x22\x0a\x09\x09nextPutAll: 'smalltalk.method({';lf;\x0a\x09\x09nextPutAll: 'selector: ', aMethod selector asJavascript, ',';lf;\x0a\x09\x09nextPutAll: 'fn: ', aMethod fn compiledSource, ',';lf;\x0a\x09\x09nextPutAll: 'messageSends: ', aMethod messageSends asJavascript;\x0a\x09\x09nextPutAll: '}),';lf;\x0a\x09\x09nextPutAll: 'smalltalk.', (self classNameFor: aMethod methodClass);\x0a\x09\x09nextPutAll: ');';lf;lf",
  1368. messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "selector", "compiledSource", "fn", "messageSends", "classNameFor:", "methodClass"],
  1369. referencedClasses: []
  1370. }),
  1371. smalltalk.StrippedExporter);
  1372. smalltalk.addMethod(
  1373. smalltalk.method({
  1374. selector: "exportDefinitionOf:on:",
  1375. category: 'exporting-output',
  1376. fn: function (aClass,aStream){
  1377. var self=this;
  1378. return smalltalk.withContext(function($ctx1) {
  1379. var $1,$2,$3,$4;
  1380. $1=aStream;
  1381. _st($1)._lf();
  1382. _st($1)._nextPutAll_("smalltalk.addClass(");
  1383. _st($1)._nextPutAll_(_st("'".__comma(self._classNameFor_(aClass))).__comma("', "));
  1384. _st($1)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aClass)._superclass())));
  1385. $2=_st($1)._nextPutAll_(", [");
  1386. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  1387. return smalltalk.withContext(function($ctx2) {
  1388. return _st(aStream)._nextPutAll_(_st("'".__comma(each)).__comma("'"));
  1389. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  1390. return smalltalk.withContext(function($ctx2) {
  1391. return _st(aStream)._nextPutAll_(", ");
  1392. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1393. $3=aStream;
  1394. _st($3)._nextPutAll_("], '");
  1395. _st($3)._nextPutAll_(_st(_st(aClass)._category()).__comma("'"));
  1396. $4=_st($3)._nextPutAll_(");");
  1397. _st(aStream)._lf();
  1398. return self}, function($ctx1) {$ctx1.fill(self,"exportDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.StrippedExporter.klass)})},
  1399. args: ["aClass", "aStream"],
  1400. source: "exportDefinitionOf: aClass on: aStream\x0a\x09aStream\x0a\x09\x09lf;\x0a\x09\x09nextPutAll: 'smalltalk.addClass(';\x0a\x09\x09nextPutAll: '''', (self classNameFor: aClass), ''', ';\x0a\x09\x09nextPutAll: 'smalltalk.', (self classNameFor: aClass superclass);\x0a\x09\x09nextPutAll: ', ['.\x0a\x09aClass instanceVariableNames\x0a\x09\x09do: [:each | aStream nextPutAll: '''', each, '''']\x0a\x09\x09separatedBy: [aStream nextPutAll: ', '].\x0a\x09aStream\x0a\x09\x09nextPutAll: '], ''';\x0a\x09\x09nextPutAll: aClass category, '''';\x0a\x09\x09nextPutAll: ');'.\x0a\x09aStream lf",
  1401. messageSends: ["lf", "nextPutAll:", ",", "classNameFor:", "superclass", "do:separatedBy:", "instanceVariableNames", "category"],
  1402. referencedClasses: []
  1403. }),
  1404. smalltalk.StrippedExporter.klass);
  1405. smalltalk.addMethod(
  1406. smalltalk.method({
  1407. selector: "exportMethod:on:",
  1408. category: 'exporting-output',
  1409. fn: function (aMethod,aStream){
  1410. var self=this;
  1411. return smalltalk.withContext(function($ctx1) {
  1412. var $1,$2;
  1413. $1=aStream;
  1414. _st($1)._nextPutAll_("smalltalk.addMethod(");
  1415. _st($1)._lf();
  1416. _st($1)._nextPutAll_("smalltalk.method({");
  1417. _st($1)._lf();
  1418. _st($1)._nextPutAll_(_st("selector: ".__comma(_st(_st(aMethod)._selector())._asJavascript())).__comma(","));
  1419. _st($1)._lf();
  1420. _st($1)._nextPutAll_(_st("fn: ".__comma(_st(_st(aMethod)._fn())._compiledSource())).__comma(","));
  1421. _st($1)._lf();
  1422. _st($1)._nextPutAll_("messageSends: ".__comma(_st(_st(aMethod)._messageSends())._asJavascript()));
  1423. _st($1)._nextPutAll_("}),");
  1424. _st($1)._lf();
  1425. _st($1)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aMethod)._methodClass())));
  1426. _st($1)._nextPutAll_(");");
  1427. _st($1)._lf();
  1428. $2=_st($1)._lf();
  1429. return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:on:",{aMethod:aMethod,aStream:aStream},smalltalk.StrippedExporter.klass)})},
  1430. args: ["aMethod", "aStream"],
  1431. source: "exportMethod: aMethod on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: 'smalltalk.addMethod(';lf;\x0a\x09\x09\x22nextPutAll: aMethod selector asSelector asJavascript, ',';lf;\x22\x0a\x09\x09nextPutAll: 'smalltalk.method({';lf;\x0a\x09\x09nextPutAll: 'selector: ', aMethod selector asJavascript, ',';lf;\x0a\x09\x09nextPutAll: 'fn: ', aMethod fn compiledSource, ',';lf;\x0a\x09\x09nextPutAll: 'messageSends: ', aMethod messageSends asJavascript;\x0a\x09\x09nextPutAll: '}),';lf;\x0a\x09\x09nextPutAll: 'smalltalk.', (self classNameFor: aMethod methodClass);\x0a\x09\x09nextPutAll: ');';lf;lf",
  1432. messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "selector", "compiledSource", "fn", "messageSends", "classNameFor:", "methodClass"],
  1433. referencedClasses: []
  1434. }),
  1435. smalltalk.StrippedExporter.klass);
  1436. smalltalk.addClass('ChunkParser', smalltalk.Object, ['stream'], 'Importer-Exporter');
  1437. smalltalk.ChunkParser.comment="I am responsible for parsing aStream contents in the chunk format.\x0a\x0a## API\x0a\x0a ChunkParser new\x0a stream: aStream;\x0a nextChunk";
  1438. smalltalk.addMethod(
  1439. smalltalk.method({
  1440. selector: "nextChunk",
  1441. category: 'reading',
  1442. fn: function (){
  1443. var self=this;
  1444. var char,result,chunk;
  1445. return smalltalk.withContext(function($ctx1) {
  1446. var $1,$2,$3;
  1447. var $early={};
  1448. try {
  1449. result=""._writeStream();
  1450. _st((function(){
  1451. return smalltalk.withContext(function($ctx2) {
  1452. char=_st(self["@stream"])._next();
  1453. char;
  1454. return _st(char)._notNil();
  1455. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileTrue_((function(){
  1456. return smalltalk.withContext(function($ctx2) {
  1457. $1=_st(char).__eq("!");
  1458. if(smalltalk.assert($1)){
  1459. $2=_st(_st(self["@stream"])._peek()).__eq("!");
  1460. if(smalltalk.assert($2)){
  1461. _st(self["@stream"])._next();
  1462. } else {
  1463. $3=_st(_st(result)._contents())._trimBoth();
  1464. throw $early=[$3];
  1465. };
  1466. };
  1467. return _st(result)._nextPut_(char);
  1468. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1469. return nil;
  1470. }
  1471. catch(e) {if(e===$early)return e[0]; throw e}
  1472. }, function($ctx1) {$ctx1.fill(self,"nextChunk",{char:char,result:result,chunk:chunk},smalltalk.ChunkParser)})},
  1473. args: [],
  1474. source: "nextChunk\x0a\x09\x22The chunk format (Smalltalk Interchange Format or Fileout format)\x0a\x09is a trivial format but can be a bit tricky to understand:\x0a\x09\x09- Uses the exclamation mark as delimiter of chunks.\x0a\x09\x09- Inside a chunk a normal exclamation mark must be doubled.\x0a\x09\x09- A non empty chunk must be a valid Smalltalk expression.\x0a\x09\x09- A chunk on top level with a preceding empty chunk is an instruction chunk:\x0a\x09\x09\x09- The object created by the expression then takes over reading chunks.\x0a\x0a\x09This metod returns next chunk as a String (trimmed), empty String (all whitespace) or nil.\x22\x0a\x0a\x09| char result chunk |\x0a\x09result := '' writeStream.\x0a\x09\x09[char := stream next.\x0a\x09\x09char notNil] whileTrue: [\x0a\x09\x09\x09\x09char = '!' ifTrue: [\x0a\x09\x09\x09\x09\x09\x09stream peek = '!'\x0a\x09\x09\x09\x09\x09\x09\x09\x09ifTrue: [stream next \x22skipping the escape double\x22]\x0a\x09\x09\x09\x09\x09\x09\x09\x09ifFalse: [^result contents trimBoth \x22chunk end marker found\x22]].\x0a\x09\x09\x09\x09result nextPut: char].\x0a\x09^nil \x22a chunk needs to end with !\x22",
  1475. messageSends: ["writeStream", "whileTrue:", "ifTrue:", "ifTrue:ifFalse:", "next", "trimBoth", "contents", "=", "peek", "nextPut:", "notNil"],
  1476. referencedClasses: []
  1477. }),
  1478. smalltalk.ChunkParser);
  1479. smalltalk.addMethod(
  1480. smalltalk.method({
  1481. selector: "stream:",
  1482. category: 'accessing',
  1483. fn: function (aStream){
  1484. var self=this;
  1485. return smalltalk.withContext(function($ctx1) {
  1486. self["@stream"]=aStream;
  1487. return self}, function($ctx1) {$ctx1.fill(self,"stream:",{aStream:aStream},smalltalk.ChunkParser)})},
  1488. args: ["aStream"],
  1489. source: "stream: aStream\x0a\x09stream := aStream",
  1490. messageSends: [],
  1491. referencedClasses: []
  1492. }),
  1493. smalltalk.ChunkParser);
  1494. smalltalk.addMethod(
  1495. smalltalk.method({
  1496. selector: "on:",
  1497. category: 'not yet classified',
  1498. fn: function (aStream){
  1499. var self=this;
  1500. return smalltalk.withContext(function($ctx1) {
  1501. var $1;
  1502. $1=_st(self._new())._stream_(aStream);
  1503. return $1;
  1504. }, function($ctx1) {$ctx1.fill(self,"on:",{aStream:aStream},smalltalk.ChunkParser.klass)})},
  1505. args: ["aStream"],
  1506. source: "on: aStream\x0a\x09^self new stream: aStream",
  1507. messageSends: ["stream:", "new"],
  1508. referencedClasses: []
  1509. }),
  1510. smalltalk.ChunkParser.klass);
  1511. smalltalk.addClass('Importer', smalltalk.Object, [], 'Importer-Exporter');
  1512. smalltalk.Importer.comment="I can import Amber code from a string in the chunk format.\x0a\x0a## API\x0a\x0a Importer new import: aString";
  1513. smalltalk.addMethod(
  1514. smalltalk.method({
  1515. selector: "import:",
  1516. category: 'fileIn',
  1517. fn: function (aStream){
  1518. var self=this;
  1519. var chunk,result,parser,lastEmpty;
  1520. function $ChunkParser(){return smalltalk.ChunkParser||(typeof ChunkParser=="undefined"?nil:ChunkParser)}
  1521. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  1522. return smalltalk.withContext(function($ctx1) {
  1523. var $1,$2;
  1524. parser=_st($ChunkParser())._on_(aStream);
  1525. lastEmpty=false;
  1526. _st((function(){
  1527. return smalltalk.withContext(function($ctx2) {
  1528. chunk=_st(parser)._nextChunk();
  1529. chunk;
  1530. return _st(chunk)._isNil();
  1531. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
  1532. return smalltalk.withContext(function($ctx2) {
  1533. $1=_st(chunk)._isEmpty();
  1534. if(smalltalk.assert($1)){
  1535. lastEmpty=true;
  1536. return lastEmpty;
  1537. } else {
  1538. result=_st(_st($Compiler())._new())._evaluateExpression_(chunk);
  1539. result;
  1540. $2=lastEmpty;
  1541. if(smalltalk.assert($2)){
  1542. lastEmpty=false;
  1543. lastEmpty;
  1544. return _st(result)._scanFrom_(parser);
  1545. };
  1546. };
  1547. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1548. return self}, function($ctx1) {$ctx1.fill(self,"import:",{aStream:aStream,chunk:chunk,result:result,parser:parser,lastEmpty:lastEmpty},smalltalk.Importer)})},
  1549. args: ["aStream"],
  1550. source: "import: aStream\x0a\x09| chunk result parser lastEmpty |\x0a\x09parser := ChunkParser on: aStream.\x0a\x09lastEmpty := false.\x0a\x09[chunk := parser nextChunk.\x0a\x09chunk isNil] whileFalse: [\x0a\x09\x09chunk isEmpty\x0a\x09\x09\x09ifTrue: [lastEmpty := true]\x0a\x09\x09\x09ifFalse: [\x0a\x09\x09\x09\x09result := Compiler new evaluateExpression: chunk.\x0a\x09\x09\x09\x09lastEmpty\x0a\x09\x09\x09\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09lastEmpty := false.\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09result scanFrom: parser]]]",
  1551. messageSends: ["on:", "whileFalse:", "ifTrue:ifFalse:", "evaluateExpression:", "new", "ifTrue:", "scanFrom:", "isEmpty", "nextChunk", "isNil"],
  1552. referencedClasses: ["ChunkParser", "Compiler"]
  1553. }),
  1554. smalltalk.Importer);
  1555. smalltalk.addClass('MethodCategory', smalltalk.Object, ['methods', 'name', 'theClass'], 'Importer-Exporter');
  1556. smalltalk.MethodCategory.comment="I am an abstraction for a method category in a class / metaclass.\x0a\x0aI know of my class, name and methods.\x0aI am used when exporting a package.";
  1557. smalltalk.addMethod(
  1558. smalltalk.method({
  1559. selector: "methods",
  1560. category: 'accessing',
  1561. fn: function (){
  1562. var self=this;
  1563. return smalltalk.withContext(function($ctx1) {
  1564. var $1;
  1565. $1=self["@methods"];
  1566. return $1;
  1567. }, function($ctx1) {$ctx1.fill(self,"methods",{},smalltalk.MethodCategory)})},
  1568. args: [],
  1569. source: "methods\x0a\x09^methods",
  1570. messageSends: [],
  1571. referencedClasses: []
  1572. }),
  1573. smalltalk.MethodCategory);
  1574. smalltalk.addMethod(
  1575. smalltalk.method({
  1576. selector: "methods:",
  1577. category: 'accessing',
  1578. fn: function (anArray){
  1579. var self=this;
  1580. return smalltalk.withContext(function($ctx1) {
  1581. self["@methods"]=anArray;
  1582. return self}, function($ctx1) {$ctx1.fill(self,"methods:",{anArray:anArray},smalltalk.MethodCategory)})},
  1583. args: ["anArray"],
  1584. source: "methods: anArray\x0a\x09methods := anArray",
  1585. messageSends: [],
  1586. referencedClasses: []
  1587. }),
  1588. smalltalk.MethodCategory);
  1589. smalltalk.addMethod(
  1590. smalltalk.method({
  1591. selector: "name",
  1592. category: 'accessing',
  1593. fn: function (){
  1594. var self=this;
  1595. return smalltalk.withContext(function($ctx1) {
  1596. var $1;
  1597. $1=self["@name"];
  1598. return $1;
  1599. }, function($ctx1) {$ctx1.fill(self,"name",{},smalltalk.MethodCategory)})},
  1600. args: [],
  1601. source: "name\x0a\x09^name",
  1602. messageSends: [],
  1603. referencedClasses: []
  1604. }),
  1605. smalltalk.MethodCategory);
  1606. smalltalk.addMethod(
  1607. smalltalk.method({
  1608. selector: "name:",
  1609. category: 'accessing',
  1610. fn: function (aString){
  1611. var self=this;
  1612. return smalltalk.withContext(function($ctx1) {
  1613. self["@name"]=aString;
  1614. return self}, function($ctx1) {$ctx1.fill(self,"name:",{aString:aString},smalltalk.MethodCategory)})},
  1615. args: ["aString"],
  1616. source: "name: aString\x0a\x09name := aString",
  1617. messageSends: [],
  1618. referencedClasses: []
  1619. }),
  1620. smalltalk.MethodCategory);
  1621. smalltalk.addMethod(
  1622. smalltalk.method({
  1623. selector: "theClass",
  1624. category: 'accessing',
  1625. fn: function (){
  1626. var self=this;
  1627. return smalltalk.withContext(function($ctx1) {
  1628. var $1;
  1629. $1=self["@theClass"];
  1630. return $1;
  1631. }, function($ctx1) {$ctx1.fill(self,"theClass",{},smalltalk.MethodCategory)})},
  1632. args: [],
  1633. source: "theClass\x0a\x09^theClass",
  1634. messageSends: [],
  1635. referencedClasses: []
  1636. }),
  1637. smalltalk.MethodCategory);
  1638. smalltalk.addMethod(
  1639. smalltalk.method({
  1640. selector: "theClass:",
  1641. category: 'accessing',
  1642. fn: function (aClass){
  1643. var self=this;
  1644. return smalltalk.withContext(function($ctx1) {
  1645. self["@theClass"]=aClass;
  1646. return self}, function($ctx1) {$ctx1.fill(self,"theClass:",{aClass:aClass},smalltalk.MethodCategory)})},
  1647. args: ["aClass"],
  1648. source: "theClass: aClass\x0a\x09theClass := aClass",
  1649. messageSends: [],
  1650. referencedClasses: []
  1651. }),
  1652. smalltalk.MethodCategory);
  1653. smalltalk.addMethod(
  1654. smalltalk.method({
  1655. selector: "name:theClass:methods:",
  1656. category: 'not yet classified',
  1657. fn: function (aString,aClass,anArray){
  1658. var self=this;
  1659. return smalltalk.withContext(function($ctx1) {
  1660. var $2,$3,$1;
  1661. $2=self._new();
  1662. _st($2)._name_(aString);
  1663. _st($2)._theClass_(aClass);
  1664. _st($2)._methods_(anArray);
  1665. $3=_st($2)._yourself();
  1666. $1=$3;
  1667. return $1;
  1668. }, function($ctx1) {$ctx1.fill(self,"name:theClass:methods:",{aString:aString,aClass:aClass,anArray:anArray},smalltalk.MethodCategory.klass)})},
  1669. args: ["aString", "aClass", "anArray"],
  1670. source: "name: aString theClass: aClass methods: anArray\x0a\x09^self new\x0a\x09\x09name: aString;\x0a\x09\x09theClass: aClass;\x0a\x09\x09methods: anArray;\x0a\x09\x09yourself",
  1671. messageSends: ["name:", "new", "theClass:", "methods:", "yourself"],
  1672. referencedClasses: []
  1673. }),
  1674. smalltalk.MethodCategory.klass);
  1675. smalltalk.addClass('PackageHandler', smalltalk.InterfacingObject, [], 'Importer-Exporter');
  1676. smalltalk.PackageHandler.comment="I am responsible for handling package loading and committing.\x0a\x0aI should not be used directly. Instead, use the corresponding `Package` methods.";
  1677. smalltalk.addMethod(
  1678. smalltalk.method({
  1679. selector: "ajaxPutAt:data:",
  1680. category: 'private',
  1681. fn: function (aURL,aString){
  1682. var self=this;
  1683. return smalltalk.withContext(function($ctx1) {
  1684. self._ajax_(smalltalk.HashedCollection._from_(["url".__minus_gt(aURL),"type".__minus_gt("PUT"),"data".__minus_gt(aString),"contentType".__minus_gt("text/plain;charset=UTF-8"),"error".__minus_gt((function(xhr){
  1685. return smalltalk.withContext(function($ctx2) {
  1686. return self._error_(_st(_st(_st("Commiting ".__comma(aURL)).__comma(" failed with reason: \x22")).__comma(_st(xhr)._responseText())).__comma("\x22"));
  1687. }, function($ctx2) {$ctx2.fillBlock({xhr:xhr},$ctx1)})}))]));
  1688. return self}, function($ctx1) {$ctx1.fill(self,"ajaxPutAt:data:",{aURL:aURL,aString:aString},smalltalk.PackageHandler)})},
  1689. args: ["aURL", "aString"],
  1690. source: "ajaxPutAt: aURL data: aString\x0a\x09self\x0a\x09\x09ajax: #{\x0a\x09\x09\x09'url' -> aURL.\x0a\x09\x09\x09'type' -> 'PUT'.\x0a\x09\x09\x09'data' -> aString.\x0a\x09\x09\x09'contentType' -> 'text/plain;charset=UTF-8'.\x0a\x09\x09\x09'error' -> [ :xhr | self error: 'Commiting ' , aURL , ' failed with reason: \x22' , (xhr responseText) , '\x22'] }",
  1691. messageSends: ["ajax:", "->", "error:", ",", "responseText"],
  1692. referencedClasses: []
  1693. }),
  1694. smalltalk.PackageHandler);
  1695. smalltalk.addMethod(
  1696. smalltalk.method({
  1697. selector: "commit:",
  1698. category: 'committing',
  1699. fn: function (aPackage){
  1700. var self=this;
  1701. function $PluggableExporter(){return smalltalk.PluggableExporter||(typeof PluggableExporter=="undefined"?nil:PluggableExporter)}
  1702. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  1703. return smalltalk.withContext(function($ctx1) {
  1704. _st(self._commitChannels())._do_displayingProgress_((function(commitStrategyFactory){
  1705. var fileContents,commitStrategy;
  1706. return smalltalk.withContext(function($ctx2) {
  1707. commitStrategy=_st(commitStrategyFactory)._value_(aPackage);
  1708. commitStrategy;
  1709. fileContents=_st($String())._streamContents_((function(stream){
  1710. return smalltalk.withContext(function($ctx3) {
  1711. return _st(_st($PluggableExporter())._newUsing_(_st(commitStrategy)._key()))._exportPackage_on_(aPackage,stream);
  1712. }, function($ctx3) {$ctx3.fillBlock({stream:stream},$ctx2)})}));
  1713. fileContents;
  1714. return self._ajaxPutAt_data_(_st(commitStrategy)._value(),fileContents);
  1715. }, function($ctx2) {$ctx2.fillBlock({commitStrategyFactory:commitStrategyFactory,fileContents:fileContents,commitStrategy:commitStrategy},$ctx1)})}),"Committing package ".__comma(_st(aPackage)._name()));
  1716. return self}, function($ctx1) {$ctx1.fill(self,"commit:",{aPackage:aPackage},smalltalk.PackageHandler)})},
  1717. args: ["aPackage"],
  1718. source: "commit: aPackage\x0a\x09self commitChannels\x0a\x09\x09do: [ :commitStrategyFactory || fileContents commitStrategy |\x0a\x09\x09\x09commitStrategy := commitStrategyFactory value: aPackage.\x0a\x09\x09\x09fileContents := String streamContents: [ :stream |\x0a\x09\x09\x09\x09(PluggableExporter newUsing: commitStrategy key) exportPackage: aPackage on: stream ].\x0a\x09\x09\x09self ajaxPutAt: commitStrategy value data: fileContents ]\x0a\x09\x09displayingProgress: 'Committing package ', aPackage name",
  1719. messageSends: ["do:displayingProgress:", "value:", "streamContents:", "exportPackage:on:", "newUsing:", "key", "ajaxPutAt:data:", "value", ",", "name", "commitChannels"],
  1720. referencedClasses: ["PluggableExporter", "String"]
  1721. }),
  1722. smalltalk.PackageHandler);
  1723. smalltalk.addMethod(
  1724. smalltalk.method({
  1725. selector: "commitChannels",
  1726. category: 'committing',
  1727. fn: function (){
  1728. var self=this;
  1729. return smalltalk.withContext(function($ctx1) {
  1730. self._subclassResponsibility();
  1731. return self}, function($ctx1) {$ctx1.fill(self,"commitChannels",{},smalltalk.PackageHandler)})},
  1732. args: [],
  1733. source: "commitChannels\x0a\x09self subclassResponsibility",
  1734. messageSends: ["subclassResponsibility"],
  1735. referencedClasses: []
  1736. }),
  1737. smalltalk.PackageHandler);
  1738. smalltalk.PackageHandler.klass.iVarNames = ['registry'];
  1739. smalltalk.addMethod(
  1740. smalltalk.method({
  1741. selector: "classRegisteredFor:",
  1742. category: 'accessing',
  1743. fn: function (aString){
  1744. var self=this;
  1745. return smalltalk.withContext(function($ctx1) {
  1746. var $1;
  1747. $1=_st(self["@registry"])._at_(aString);
  1748. return $1;
  1749. }, function($ctx1) {$ctx1.fill(self,"classRegisteredFor:",{aString:aString},smalltalk.PackageHandler.klass)})},
  1750. args: ["aString"],
  1751. source: "classRegisteredFor: aString\x0a\x09^registry at: aString",
  1752. messageSends: ["at:"],
  1753. referencedClasses: []
  1754. }),
  1755. smalltalk.PackageHandler.klass);
  1756. smalltalk.addMethod(
  1757. smalltalk.method({
  1758. selector: "for:",
  1759. category: 'accessing',
  1760. fn: function (aString){
  1761. var self=this;
  1762. return smalltalk.withContext(function($ctx1) {
  1763. var $1;
  1764. $1=_st(self._classRegisteredFor_(aString))._new();
  1765. return $1;
  1766. }, function($ctx1) {$ctx1.fill(self,"for:",{aString:aString},smalltalk.PackageHandler.klass)})},
  1767. args: ["aString"],
  1768. source: "for: aString\x0a\x09^(self classRegisteredFor: aString) new",
  1769. messageSends: ["new", "classRegisteredFor:"],
  1770. referencedClasses: []
  1771. }),
  1772. smalltalk.PackageHandler.klass);
  1773. smalltalk.addMethod(
  1774. smalltalk.method({
  1775. selector: "initialize",
  1776. category: 'initialization',
  1777. fn: function (){
  1778. var self=this;
  1779. return smalltalk.withContext(function($ctx1) {
  1780. smalltalk.PackageHandler.klass.superclass.fn.prototype._initialize.apply(_st(self), []);
  1781. self["@registry"]=smalltalk.HashedCollection._from_([]);
  1782. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.PackageHandler.klass)})},
  1783. args: [],
  1784. source: "initialize\x0a\x09super initialize.\x0a\x09registry := #{}",
  1785. messageSends: ["initialize"],
  1786. referencedClasses: []
  1787. }),
  1788. smalltalk.PackageHandler.klass);
  1789. smalltalk.addMethod(
  1790. smalltalk.method({
  1791. selector: "register:for:",
  1792. category: 'registry',
  1793. fn: function (aClass,aString){
  1794. var self=this;
  1795. return smalltalk.withContext(function($ctx1) {
  1796. _st(self["@registry"])._at_put_(aString,aClass);
  1797. return self}, function($ctx1) {$ctx1.fill(self,"register:for:",{aClass:aClass,aString:aString},smalltalk.PackageHandler.klass)})},
  1798. args: ["aClass", "aString"],
  1799. source: "register: aClass for: aString\x0a\x09registry at: aString put: aClass",
  1800. messageSends: ["at:put:"],
  1801. referencedClasses: []
  1802. }),
  1803. smalltalk.PackageHandler.klass);
  1804. smalltalk.addMethod(
  1805. smalltalk.method({
  1806. selector: "registerFor:",
  1807. category: 'registry',
  1808. fn: function (aString){
  1809. var self=this;
  1810. function $PackageHandler(){return smalltalk.PackageHandler||(typeof PackageHandler=="undefined"?nil:PackageHandler)}
  1811. return smalltalk.withContext(function($ctx1) {
  1812. _st($PackageHandler())._register_for_(self,aString);
  1813. return self}, function($ctx1) {$ctx1.fill(self,"registerFor:",{aString:aString},smalltalk.PackageHandler.klass)})},
  1814. args: ["aString"],
  1815. source: "registerFor: aString\x0a\x09PackageHandler register: self for: aString",
  1816. messageSends: ["register:for:"],
  1817. referencedClasses: ["PackageHandler"]
  1818. }),
  1819. smalltalk.PackageHandler.klass);
  1820. smalltalk.addClass('LegacyPackageHandler', smalltalk.PackageHandler, [], 'Importer-Exporter');
  1821. smalltalk.LegacyPackageHandler.comment="I am responsible for handling package loading and committing.\x0d\x0a\x0d\x0aI should not be used directly. Instead, use the corresponding `Package` methods.";
  1822. smalltalk.addMethod(
  1823. smalltalk.method({
  1824. selector: "commitChannels",
  1825. category: 'committing',
  1826. fn: function (){
  1827. var self=this;
  1828. function $Exporter(){return smalltalk.Exporter||(typeof Exporter=="undefined"?nil:Exporter)}
  1829. function $StrippedExporter(){return smalltalk.StrippedExporter||(typeof StrippedExporter=="undefined"?nil:StrippedExporter)}
  1830. function $ChunkExporter(){return smalltalk.ChunkExporter||(typeof ChunkExporter=="undefined"?nil:ChunkExporter)}
  1831. return smalltalk.withContext(function($ctx1) {
  1832. var $1;
  1833. $1=[(function(pkg){
  1834. return smalltalk.withContext(function($ctx2) {
  1835. return _st(_st(_st($Exporter())._default())._recipe()).__minus_gt(_st(_st(_st(_st(pkg)._commitPathJs()).__comma("/")).__comma(_st(pkg)._name())).__comma(".js"));
  1836. }, function($ctx2) {$ctx2.fillBlock({pkg:pkg},$ctx1)})}),(function(pkg){
  1837. return smalltalk.withContext(function($ctx2) {
  1838. return _st(_st(_st($StrippedExporter())._default())._recipe()).__minus_gt(_st(_st(_st(_st(pkg)._commitPathJs()).__comma("/")).__comma(_st(pkg)._name())).__comma(".deploy.js"));
  1839. }, function($ctx2) {$ctx2.fillBlock({pkg:pkg},$ctx1)})}),(function(pkg){
  1840. return smalltalk.withContext(function($ctx2) {
  1841. return _st(_st(_st($ChunkExporter())._default())._recipe()).__minus_gt(_st(_st(_st(_st(pkg)._commitPathSt()).__comma("/")).__comma(_st(pkg)._name())).__comma(".st"));
  1842. }, function($ctx2) {$ctx2.fillBlock({pkg:pkg},$ctx1)})})];
  1843. return $1;
  1844. }, function($ctx1) {$ctx1.fill(self,"commitChannels",{},smalltalk.LegacyPackageHandler)})},
  1845. args: [],
  1846. source: "commitChannels\x0a\x09^{ \x0a\x09\x09[ :pkg | Exporter default recipe -> (pkg commitPathJs, '/', pkg name, '.js') ].\x0a\x09\x09[ :pkg | StrippedExporter default recipe -> (pkg commitPathJs, '/', pkg name, '.deploy.js') ].\x0a\x09\x09[ :pkg | ChunkExporter default recipe -> (pkg commitPathSt, '/', pkg name, '.st') ]\x0a\x09}",
  1847. messageSends: ["->", ",", "name", "commitPathJs", "recipe", "default", "commitPathSt"],
  1848. referencedClasses: ["Exporter", "StrippedExporter", "ChunkExporter"]
  1849. }),
  1850. smalltalk.LegacyPackageHandler);
  1851. smalltalk.addMethod(
  1852. smalltalk.method({
  1853. selector: "commitPathJsFor:",
  1854. category: 'committing',
  1855. fn: function (aPackage){
  1856. var self=this;
  1857. return smalltalk.withContext(function($ctx1) {
  1858. var $1;
  1859. $1=_st(self._class())._defaultCommitPathJs();
  1860. return $1;
  1861. }, function($ctx1) {$ctx1.fill(self,"commitPathJsFor:",{aPackage:aPackage},smalltalk.LegacyPackageHandler)})},
  1862. args: ["aPackage"],
  1863. source: "commitPathJsFor: aPackage\x0a\x09^self class defaultCommitPathJs",
  1864. messageSends: ["defaultCommitPathJs", "class"],
  1865. referencedClasses: []
  1866. }),
  1867. smalltalk.LegacyPackageHandler);
  1868. smalltalk.addMethod(
  1869. smalltalk.method({
  1870. selector: "commitPathStFor:",
  1871. category: 'committing',
  1872. fn: function (aPackage){
  1873. var self=this;
  1874. return smalltalk.withContext(function($ctx1) {
  1875. var $1;
  1876. $1=_st(self._class())._defaultCommitPathSt();
  1877. return $1;
  1878. }, function($ctx1) {$ctx1.fill(self,"commitPathStFor:",{aPackage:aPackage},smalltalk.LegacyPackageHandler)})},
  1879. args: ["aPackage"],
  1880. source: "commitPathStFor: aPackage\x0a\x09^self class defaultCommitPathSt",
  1881. messageSends: ["defaultCommitPathSt", "class"],
  1882. referencedClasses: []
  1883. }),
  1884. smalltalk.LegacyPackageHandler);
  1885. smalltalk.addMethod(
  1886. smalltalk.method({
  1887. selector: "loadPackage:prefix:",
  1888. category: 'loading',
  1889. fn: function (packageName,aString){
  1890. var self=this;
  1891. var url;
  1892. return smalltalk.withContext(function($ctx1) {
  1893. var $1;
  1894. url=_st(_st(_st("/".__comma(aString)).__comma("/js/")).__comma(packageName)).__comma(".js");
  1895. self._ajax_(smalltalk.HashedCollection._from_(["url".__minus_gt(url),"type".__minus_gt("GET"),"dataType".__minus_gt("script"),"complete".__minus_gt((function(jqXHR,textStatus){
  1896. return smalltalk.withContext(function($ctx2) {
  1897. $1=_st(_st(jqXHR)._readyState()).__eq((4));
  1898. if(smalltalk.assert($1)){
  1899. return self._setupPackageNamed_prefix_(packageName,aString);
  1900. };
  1901. }, function($ctx2) {$ctx2.fillBlock({jqXHR:jqXHR,textStatus:textStatus},$ctx1)})})),"error".__minus_gt((function(){
  1902. return smalltalk.withContext(function($ctx2) {
  1903. return self._alert_("Could not load package at: ".__comma(url));
  1904. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))]));
  1905. return self}, function($ctx1) {$ctx1.fill(self,"loadPackage:prefix:",{packageName:packageName,aString:aString,url:url},smalltalk.LegacyPackageHandler)})},
  1906. args: ["packageName", "aString"],
  1907. source: "loadPackage: packageName prefix: aString\x0a\x09| url |\x0a\x09url := '/', aString, '/js/', packageName, '.js'.\x0a\x09self\x0a\x09\x09ajax: #{\x0a\x09\x09\x09'url' -> url.\x0a\x09\x09\x09'type' -> 'GET'.\x0a\x09\x09\x09'dataType' -> 'script'.\x0a\x09\x09\x09'complete' -> [ :jqXHR :textStatus |\x0a\x09\x09\x09\x09jqXHR readyState = 4\x0a\x09\x09\x09\x09\x09ifTrue: [ self setupPackageNamed: packageName prefix: aString ] ].\x0a\x09\x09\x09'error' -> [ self alert: 'Could not load package at: ', url ]\x0a\x09\x09}",
  1908. messageSends: [",", "ajax:", "->", "ifTrue:", "setupPackageNamed:prefix:", "=", "readyState", "alert:"],
  1909. referencedClasses: []
  1910. }),
  1911. smalltalk.LegacyPackageHandler);
  1912. smalltalk.addMethod(
  1913. smalltalk.method({
  1914. selector: "loadPackages:prefix:",
  1915. category: 'loading',
  1916. fn: function (aCollection,aString){
  1917. var self=this;
  1918. return smalltalk.withContext(function($ctx1) {
  1919. _st(aCollection)._do_((function(each){
  1920. return smalltalk.withContext(function($ctx2) {
  1921. return self._loadPackage_prefix_(each,aString);
  1922. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  1923. return self}, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.LegacyPackageHandler)})},
  1924. args: ["aCollection", "aString"],
  1925. source: "loadPackages: aCollection prefix: aString\x0a\x09aCollection do: [ :each |\x0a\x09\x09self loadPackage: each prefix: aString ]",
  1926. messageSends: ["do:", "loadPackage:prefix:"],
  1927. referencedClasses: []
  1928. }),
  1929. smalltalk.LegacyPackageHandler);
  1930. smalltalk.addMethod(
  1931. smalltalk.method({
  1932. selector: "setupPackageNamed:prefix:",
  1933. category: 'private',
  1934. fn: function (packageName,aString){
  1935. var self=this;
  1936. function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
  1937. return smalltalk.withContext(function($ctx1) {
  1938. var $1,$2;
  1939. $1=_st($Package())._named_(packageName);
  1940. _st($1)._setupClasses();
  1941. _st($1)._commitPathJs_(_st("/".__comma(aString)).__comma("/js"));
  1942. $2=_st($1)._commitPathSt_(_st("/".__comma(aString)).__comma("/st"));
  1943. return self}, function($ctx1) {$ctx1.fill(self,"setupPackageNamed:prefix:",{packageName:packageName,aString:aString},smalltalk.LegacyPackageHandler)})},
  1944. args: ["packageName", "aString"],
  1945. source: "setupPackageNamed: packageName prefix: aString\x0a\x0a\x09(Package named: packageName)\x0a\x09\x09setupClasses;\x0a\x09\x09commitPathJs: '/', aString, '/js';\x0a\x09\x09commitPathSt: '/', aString, '/st'",
  1946. messageSends: ["setupClasses", "named:", "commitPathJs:", ",", "commitPathSt:"],
  1947. referencedClasses: ["Package"]
  1948. }),
  1949. smalltalk.LegacyPackageHandler);
  1950. smalltalk.LegacyPackageHandler.klass.iVarNames = ['defaultCommitPathJs','defaultCommitPathSt'];
  1951. smalltalk.addMethod(
  1952. smalltalk.method({
  1953. selector: "commitPathsFromLoader",
  1954. category: 'commit paths',
  1955. fn: function (){
  1956. var self=this;
  1957. return smalltalk.withContext(function($ctx1) {
  1958. var commitPath = typeof amber !== 'undefined' && amber.commitPath;
  1959. if (!commitPath) return;
  1960. if (commitPath.js) self._defaultCommitPathJs_(commitPath.js);
  1961. if (commitPath.st) self._defaultCommitPathSt_(commitPath.st);
  1962. ;
  1963. return self}, function($ctx1) {$ctx1.fill(self,"commitPathsFromLoader",{},smalltalk.LegacyPackageHandler.klass)})},
  1964. args: [],
  1965. source: "commitPathsFromLoader\x0a\x09<\x0a\x09\x09var commitPath = typeof amber !== 'undefined' && amber.commitPath;\x0a\x09\x09if (!commitPath) return;\x0a\x09\x09if (commitPath.js) self._defaultCommitPathJs_(commitPath.js);\x0a\x09\x09if (commitPath.st) self._defaultCommitPathSt_(commitPath.st);\x0a\x09>",
  1966. messageSends: [],
  1967. referencedClasses: []
  1968. }),
  1969. smalltalk.LegacyPackageHandler.klass);
  1970. smalltalk.addMethod(
  1971. smalltalk.method({
  1972. selector: "defaultCommitPathJs",
  1973. category: 'commit paths',
  1974. fn: function (){
  1975. var self=this;
  1976. return smalltalk.withContext(function($ctx1) {
  1977. var $2,$1;
  1978. $2=self["@defaultCommitPathJs"];
  1979. if(($receiver = $2) == nil || $receiver == undefined){
  1980. self["@defaultCommitPathJs"]="js";
  1981. $1=self["@defaultCommitPathJs"];
  1982. } else {
  1983. $1=$2;
  1984. };
  1985. return $1;
  1986. }, function($ctx1) {$ctx1.fill(self,"defaultCommitPathJs",{},smalltalk.LegacyPackageHandler.klass)})},
  1987. args: [],
  1988. source: "defaultCommitPathJs\x0a\x09^ defaultCommitPathJs ifNil: [ defaultCommitPathJs := 'js']",
  1989. messageSends: ["ifNil:"],
  1990. referencedClasses: []
  1991. }),
  1992. smalltalk.LegacyPackageHandler.klass);
  1993. smalltalk.addMethod(
  1994. smalltalk.method({
  1995. selector: "defaultCommitPathJs:",
  1996. category: 'commit paths',
  1997. fn: function (aString){
  1998. var self=this;
  1999. return smalltalk.withContext(function($ctx1) {
  2000. self["@defaultCommitPathJs"]=aString;
  2001. return self}, function($ctx1) {$ctx1.fill(self,"defaultCommitPathJs:",{aString:aString},smalltalk.LegacyPackageHandler.klass)})},
  2002. args: ["aString"],
  2003. source: "defaultCommitPathJs: aString\x0a\x09defaultCommitPathJs := aString",
  2004. messageSends: [],
  2005. referencedClasses: []
  2006. }),
  2007. smalltalk.LegacyPackageHandler.klass);
  2008. smalltalk.addMethod(
  2009. smalltalk.method({
  2010. selector: "defaultCommitPathSt",
  2011. category: 'commit paths',
  2012. fn: function (){
  2013. var self=this;
  2014. return smalltalk.withContext(function($ctx1) {
  2015. var $2,$1;
  2016. $2=self["@defaultCommitPathSt"];
  2017. if(($receiver = $2) == nil || $receiver == undefined){
  2018. self["@defaultCommitPathSt"]="st";
  2019. $1=self["@defaultCommitPathSt"];
  2020. } else {
  2021. $1=$2;
  2022. };
  2023. return $1;
  2024. }, function($ctx1) {$ctx1.fill(self,"defaultCommitPathSt",{},smalltalk.LegacyPackageHandler.klass)})},
  2025. args: [],
  2026. source: "defaultCommitPathSt\x0a\x09^ defaultCommitPathSt ifNil: [ defaultCommitPathSt := 'st']",
  2027. messageSends: ["ifNil:"],
  2028. referencedClasses: []
  2029. }),
  2030. smalltalk.LegacyPackageHandler.klass);
  2031. smalltalk.addMethod(
  2032. smalltalk.method({
  2033. selector: "defaultCommitPathSt:",
  2034. category: 'commit paths',
  2035. fn: function (aString){
  2036. var self=this;
  2037. return smalltalk.withContext(function($ctx1) {
  2038. self["@defaultCommitPathSt"]=aString;
  2039. return self}, function($ctx1) {$ctx1.fill(self,"defaultCommitPathSt:",{aString:aString},smalltalk.LegacyPackageHandler.klass)})},
  2040. args: ["aString"],
  2041. source: "defaultCommitPathSt: aString\x0a\x09defaultCommitPathSt := aString",
  2042. messageSends: [],
  2043. referencedClasses: []
  2044. }),
  2045. smalltalk.LegacyPackageHandler.klass);
  2046. smalltalk.addMethod(
  2047. smalltalk.method({
  2048. selector: "initialize",
  2049. category: 'initialization',
  2050. fn: function (){
  2051. var self=this;
  2052. return smalltalk.withContext(function($ctx1) {
  2053. smalltalk.LegacyPackageHandler.klass.superclass.fn.prototype._initialize.apply(_st(self), []);
  2054. self._registerFor_("unknown");
  2055. self._commitPathsFromLoader();
  2056. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.LegacyPackageHandler.klass)})},
  2057. args: [],
  2058. source: "initialize\x0a\x09super initialize.\x0a\x09self registerFor: 'unknown'.\x0a\x09self commitPathsFromLoader",
  2059. messageSends: ["initialize", "registerFor:", "commitPathsFromLoader"],
  2060. referencedClasses: []
  2061. }),
  2062. smalltalk.LegacyPackageHandler.klass);
  2063. smalltalk.addMethod(
  2064. smalltalk.method({
  2065. selector: "loadPackages:prefix:",
  2066. category: 'loading',
  2067. fn: function (aCollection,aString){
  2068. var self=this;
  2069. return smalltalk.withContext(function($ctx1) {
  2070. var $1;
  2071. $1=_st(self._new())._loadPackages_prefix_(aCollection,aString);
  2072. return $1;
  2073. }, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.LegacyPackageHandler.klass)})},
  2074. args: ["aCollection", "aString"],
  2075. source: "loadPackages: aCollection prefix: aString\x0a\x09^ self new loadPackages: aCollection prefix: aString",
  2076. messageSends: ["loadPackages:prefix:", "new"],
  2077. referencedClasses: []
  2078. }),
  2079. smalltalk.LegacyPackageHandler.klass);
  2080. smalltalk.addMethod(
  2081. smalltalk.method({
  2082. selector: "resetCommitPaths",
  2083. category: 'commit paths',
  2084. fn: function (){
  2085. var self=this;
  2086. return smalltalk.withContext(function($ctx1) {
  2087. self["@defaultCommitPathJs"]=nil;
  2088. self["@defaultCommitPathSt"]=nil;
  2089. return self}, function($ctx1) {$ctx1.fill(self,"resetCommitPaths",{},smalltalk.LegacyPackageHandler.klass)})},
  2090. args: [],
  2091. source: "resetCommitPaths\x0a\x09defaultCommitPathJs := nil.\x0a\x09defaultCommitPathSt := nil",
  2092. messageSends: [],
  2093. referencedClasses: []
  2094. }),
  2095. smalltalk.LegacyPackageHandler.klass);
  2096. smalltalk.addClass('PluggableExporter', smalltalk.Object, ['recipe'], 'Importer-Exporter');
  2097. smalltalk.PluggableExporter.comment="I am an engine for exporting structured data on a Stream.\x0a\x0aMy instances are created using\x0a PluggableExporter newUsing: recipe,\x0awhere recipe is structured description of the exporting algorithm.\x0a\x0aThen actual exporting is done using\x0a aPluggableExporter export: data usingRecipe: recipe on: stream\x0a\x0aRecipe is an array, which can contain two kinds of elements:\x0a\x0a - an assocation where the key is the receiver and the value is a two-arguments selector\x0a In this case, `receiver perform: selector withArguments: { data. stream }` is called.\x0a\x09This essentially defines one step of export process.\x0a\x09The key (eg. receiver) is presumed to be some kind of 'repository' of the exporting methods\x0a\x09that just format appropriate aspect of data into a stream; like a class or a singleton,\x0a\x09so you can make the recipe itself decoupled from data.\x0a\x0a - a subarray, where first element is special and the rest is recursive recipe.\x0a\x0a `subarray first` must be an association similar to one above,\x0a\x09with key being the 'repository' receiver, but value is one-arg selector.\x0a\x09In this case, `receiver perform: selector withArguments: { data }` should create a collection.\x0a\x09Then, the sub-recipe (`subarray allButFirst`) is applied to every element of a collection, eg.\x0a\x09 collection do: [ :each | self export: each using: sa allButFirst on: stream ]\x0a \x0aI am used to export amber packages, so I have a convenience method\x0a`exportPackage: aPackage on: aStream`\x0awhich exports `aPackage` using the `recipe` passed on `newUsing:`\x0a(it is otherwise no special, so it may be renamed to export:on:)";
  2098. smalltalk.addMethod(
  2099. smalltalk.method({
  2100. selector: "export:usingRecipe:on:",
  2101. category: 'fileOut',
  2102. fn: function (anObject,anArray,aStream){
  2103. var self=this;
  2104. var args;
  2105. return smalltalk.withContext(function($ctx1) {
  2106. var $1;
  2107. args=[anObject,aStream];
  2108. _st(anArray)._do_((function(each){
  2109. var val;
  2110. return smalltalk.withContext(function($ctx2) {
  2111. val=_st(each)._value();
  2112. val;
  2113. $1=_st(val).__eq_eq(each);
  2114. if(smalltalk.assert($1)){
  2115. var selection;
  2116. selection=_st(_st(_st(each)._first())._key())._perform_withArguments_(_st(_st(each)._first())._value(),[anObject]);
  2117. selection;
  2118. return _st(selection)._do_((function(eachPart){
  2119. return smalltalk.withContext(function($ctx3) {
  2120. return self._export_usingRecipe_on_(eachPart,_st(each)._allButFirst(),aStream);
  2121. }, function($ctx3) {$ctx3.fillBlock({eachPart:eachPart},$ctx2)})}));
  2122. } else {
  2123. return _st(_st(each)._key())._perform_withArguments_(val,args);
  2124. };
  2125. }, function($ctx2) {$ctx2.fillBlock({each:each,val:val},$ctx1)})}));
  2126. return self}, function($ctx1) {$ctx1.fill(self,"export:usingRecipe:on:",{anObject:anObject,anArray:anArray,aStream:aStream,args:args},smalltalk.PluggableExporter)})},
  2127. args: ["anObject", "anArray", "aStream"],
  2128. source: "export: anObject usingRecipe: anArray on: aStream\x0a\x09| args |\x0a\x09args := { anObject. aStream }.\x0a\x09anArray do: [ :each | | val |\x0a\x09\x09val := each value.\x0a\x09\x09val == each\x0a\x09\x09\x09ifFalse: [ \x22association\x22\x0a\x09\x09\x09\x09each key perform: val withArguments: args ]\x0a\x09\x09\x09ifTrue: [ \x22sub-array\x22\x0a\x09\x09\x09\x09| selection |\x0a\x09\x09\x09\x09selection := each first key perform: each first value withArguments: { anObject }.\x0a\x09\x09\x09\x09selection do: [ :eachPart |\x09self export: eachPart usingRecipe: each allButFirst on: aStream ]]]",
  2129. messageSends: ["do:", "value", "ifFalse:ifTrue:", "perform:withArguments:", "key", "first", "export:usingRecipe:on:", "allButFirst", "=="],
  2130. referencedClasses: []
  2131. }),
  2132. smalltalk.PluggableExporter);
  2133. smalltalk.addMethod(
  2134. smalltalk.method({
  2135. selector: "exportAll",
  2136. category: 'fileOut',
  2137. fn: function (){
  2138. var self=this;
  2139. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  2140. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  2141. return smalltalk.withContext(function($ctx1) {
  2142. var $1;
  2143. $1=_st($String())._streamContents_((function(stream){
  2144. return smalltalk.withContext(function($ctx2) {
  2145. return _st(_st(_st($Smalltalk())._current())._packages())._do_((function(pkg){
  2146. return smalltalk.withContext(function($ctx3) {
  2147. return self._exportPackage_on_(pkg,stream);
  2148. }, function($ctx3) {$ctx3.fillBlock({pkg:pkg},$ctx2)})}));
  2149. }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1)})}));
  2150. return $1;
  2151. }, function($ctx1) {$ctx1.fill(self,"exportAll",{},smalltalk.PluggableExporter)})},
  2152. args: [],
  2153. source: "exportAll\x0a\x09\x22Export all packages in the system.\x22\x0a\x0a\x09^String streamContents: [:stream |\x0a\x09\x09Smalltalk current packages do: [:pkg |\x0a\x09\x09self exportPackage: pkg on: stream]]",
  2154. messageSends: ["streamContents:", "do:", "exportPackage:on:", "packages", "current"],
  2155. referencedClasses: ["Smalltalk", "String"]
  2156. }),
  2157. smalltalk.PluggableExporter);
  2158. smalltalk.addMethod(
  2159. smalltalk.method({
  2160. selector: "exportPackage:on:",
  2161. category: 'fileOut',
  2162. fn: function (aPackage,aStream){
  2163. var self=this;
  2164. return smalltalk.withContext(function($ctx1) {
  2165. self._export_usingRecipe_on_(aPackage,self._recipe(),aStream);
  2166. return self}, function($ctx1) {$ctx1.fill(self,"exportPackage:on:",{aPackage:aPackage,aStream:aStream},smalltalk.PluggableExporter)})},
  2167. args: ["aPackage", "aStream"],
  2168. source: "exportPackage: aPackage on: aStream\x0a\x09self export: aPackage usingRecipe: self recipe on: aStream",
  2169. messageSends: ["export:usingRecipe:on:", "recipe"],
  2170. referencedClasses: []
  2171. }),
  2172. smalltalk.PluggableExporter);
  2173. smalltalk.addMethod(
  2174. smalltalk.method({
  2175. selector: "recipe",
  2176. category: 'accessing',
  2177. fn: function (){
  2178. var self=this;
  2179. return smalltalk.withContext(function($ctx1) {
  2180. var $1;
  2181. $1=self["@recipe"];
  2182. return $1;
  2183. }, function($ctx1) {$ctx1.fill(self,"recipe",{},smalltalk.PluggableExporter)})},
  2184. args: [],
  2185. source: "recipe\x0a\x09^recipe",
  2186. messageSends: [],
  2187. referencedClasses: []
  2188. }),
  2189. smalltalk.PluggableExporter);
  2190. smalltalk.addMethod(
  2191. smalltalk.method({
  2192. selector: "recipe:",
  2193. category: 'accessing',
  2194. fn: function (anArray){
  2195. var self=this;
  2196. return smalltalk.withContext(function($ctx1) {
  2197. self["@recipe"]=anArray;
  2198. return self}, function($ctx1) {$ctx1.fill(self,"recipe:",{anArray:anArray},smalltalk.PluggableExporter)})},
  2199. args: ["anArray"],
  2200. source: "recipe: anArray\x0a\x09recipe := anArray",
  2201. messageSends: [],
  2202. referencedClasses: []
  2203. }),
  2204. smalltalk.PluggableExporter);
  2205. smalltalk.addMethod(
  2206. smalltalk.method({
  2207. selector: "newUsing:",
  2208. category: 'exporting-accessing',
  2209. fn: function (recipe){
  2210. var self=this;
  2211. return smalltalk.withContext(function($ctx1) {
  2212. var $2,$3,$1;
  2213. $2=self._new();
  2214. _st($2)._recipe_(recipe);
  2215. $3=_st($2)._yourself();
  2216. $1=$3;
  2217. return $1;
  2218. }, function($ctx1) {$ctx1.fill(self,"newUsing:",{recipe:recipe},smalltalk.PluggableExporter.klass)})},
  2219. args: ["recipe"],
  2220. source: "newUsing: recipe\x0a\x09^self new recipe: recipe; yourself",
  2221. messageSends: ["recipe:", "new", "yourself"],
  2222. referencedClasses: []
  2223. }),
  2224. smalltalk.PluggableExporter.klass);
  2225. smalltalk.addMethod(
  2226. smalltalk.method({
  2227. selector: "ownClassesOfPackage:",
  2228. category: 'exporting-accessing',
  2229. fn: function (package_){
  2230. var self=this;
  2231. return smalltalk.withContext(function($ctx1) {
  2232. var $1;
  2233. $1=_st(_st(package_)._sortedClasses())._asSet();
  2234. return $1;
  2235. }, function($ctx1) {$ctx1.fill(self,"ownClassesOfPackage:",{package_:package_},smalltalk.PluggableExporter.klass)})},
  2236. args: ["package"],
  2237. source: "ownClassesOfPackage: package\x0a\x09\x22Export classes in dependency order.\x0a\x09Update (issue #171): Remove duplicates for export\x22\x0a\x09^package sortedClasses asSet",
  2238. messageSends: ["asSet", "sortedClasses"],
  2239. referencedClasses: []
  2240. }),
  2241. smalltalk.PluggableExporter.klass);
  2242. smalltalk.addMethod(
  2243. smalltalk.method({
  2244. selector: "commit",
  2245. category: '*Importer-Exporter',
  2246. fn: function (){
  2247. var self=this;
  2248. return smalltalk.withContext(function($ctx1) {
  2249. var $1;
  2250. $1=_st(self._transport())._commit_(self);
  2251. return $1;
  2252. }, function($ctx1) {$ctx1.fill(self,"commit",{},smalltalk.Package)})},
  2253. args: [],
  2254. source: "commit\x0a\x09^ self transport commit: self",
  2255. messageSends: ["commit:", "transport"],
  2256. referencedClasses: []
  2257. }),
  2258. smalltalk.Package);
  2259. smalltalk.addMethod(
  2260. smalltalk.method({
  2261. selector: "commitPathJs",
  2262. category: '*Importer-Exporter',
  2263. fn: function (){
  2264. var self=this;
  2265. return smalltalk.withContext(function($ctx1) {
  2266. var $3,$2,$1;
  2267. $3=self["@extension"];
  2268. if(($receiver = $3) == nil || $receiver == undefined){
  2269. self["@extension"]=smalltalk.HashedCollection._from_([]);
  2270. $2=self["@extension"];
  2271. } else {
  2272. $2=$3;
  2273. };
  2274. $1=_st($2)._at_ifAbsentPut_("commitPathJs",(function(){
  2275. return smalltalk.withContext(function($ctx2) {
  2276. return _st(self._transport())._commitPathJsFor_(self);
  2277. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  2278. return $1;
  2279. }, function($ctx1) {$ctx1.fill(self,"commitPathJs",{},smalltalk.Package)})},
  2280. args: [],
  2281. source: "commitPathJs\x0a\x09^ (extension ifNil: [ extension := #{} ]) at: #commitPathJs ifAbsentPut: [self transport commitPathJsFor: self]",
  2282. messageSends: ["at:ifAbsentPut:", "commitPathJsFor:", "transport", "ifNil:"],
  2283. referencedClasses: []
  2284. }),
  2285. smalltalk.Package);
  2286. smalltalk.addMethod(
  2287. smalltalk.method({
  2288. selector: "commitPathJs:",
  2289. category: '*Importer-Exporter',
  2290. fn: function (aString){
  2291. var self=this;
  2292. return smalltalk.withContext(function($ctx1) {
  2293. var $3,$2,$1;
  2294. $3=self["@extension"];
  2295. if(($receiver = $3) == nil || $receiver == undefined){
  2296. self["@extension"]=smalltalk.HashedCollection._from_([]);
  2297. $2=self["@extension"];
  2298. } else {
  2299. $2=$3;
  2300. };
  2301. $1=_st($2)._at_put_("commitPathJs",aString);
  2302. return $1;
  2303. }, function($ctx1) {$ctx1.fill(self,"commitPathJs:",{aString:aString},smalltalk.Package)})},
  2304. args: ["aString"],
  2305. source: "commitPathJs: aString\x0a\x09^ (extension ifNil: [ extension := #{} ]) at: #commitPathJs put: aString",
  2306. messageSends: ["at:put:", "ifNil:"],
  2307. referencedClasses: []
  2308. }),
  2309. smalltalk.Package);
  2310. smalltalk.addMethod(
  2311. smalltalk.method({
  2312. selector: "commitPathSt",
  2313. category: '*Importer-Exporter',
  2314. fn: function (){
  2315. var self=this;
  2316. return smalltalk.withContext(function($ctx1) {
  2317. var $3,$2,$1;
  2318. $3=self["@extension"];
  2319. if(($receiver = $3) == nil || $receiver == undefined){
  2320. self["@extension"]=smalltalk.HashedCollection._from_([]);
  2321. $2=self["@extension"];
  2322. } else {
  2323. $2=$3;
  2324. };
  2325. $1=_st($2)._at_ifAbsentPut_("commitPathSt",(function(){
  2326. return smalltalk.withContext(function($ctx2) {
  2327. return _st(self._transport())._commitPathStFor_(self);
  2328. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  2329. return $1;
  2330. }, function($ctx1) {$ctx1.fill(self,"commitPathSt",{},smalltalk.Package)})},
  2331. args: [],
  2332. source: "commitPathSt\x0a\x09^ (extension ifNil: [ extension := #{} ]) at: #commitPathSt ifAbsentPut: [self transport commitPathStFor: self]",
  2333. messageSends: ["at:ifAbsentPut:", "commitPathStFor:", "transport", "ifNil:"],
  2334. referencedClasses: []
  2335. }),
  2336. smalltalk.Package);
  2337. smalltalk.addMethod(
  2338. smalltalk.method({
  2339. selector: "commitPathSt:",
  2340. category: '*Importer-Exporter',
  2341. fn: function (aString){
  2342. var self=this;
  2343. return smalltalk.withContext(function($ctx1) {
  2344. var $3,$2,$1;
  2345. $3=self["@extension"];
  2346. if(($receiver = $3) == nil || $receiver == undefined){
  2347. self["@extension"]=smalltalk.HashedCollection._from_([]);
  2348. $2=self["@extension"];
  2349. } else {
  2350. $2=$3;
  2351. };
  2352. $1=_st($2)._at_put_("commitPathSt",aString);
  2353. return $1;
  2354. }, function($ctx1) {$ctx1.fill(self,"commitPathSt:",{aString:aString},smalltalk.Package)})},
  2355. args: ["aString"],
  2356. source: "commitPathSt: aString\x0a\x09^ (extension ifNil: [ extension := #{} ]) at: #commitPathSt put: aString",
  2357. messageSends: ["at:put:", "ifNil:"],
  2358. referencedClasses: []
  2359. }),
  2360. smalltalk.Package);
  2361. smalltalk.addMethod(
  2362. smalltalk.method({
  2363. selector: "transport",
  2364. category: '*Importer-Exporter',
  2365. fn: function (){
  2366. var self=this;
  2367. function $PackageHandler(){return smalltalk.PackageHandler||(typeof PackageHandler=="undefined"?nil:PackageHandler)}
  2368. return smalltalk.withContext(function($ctx1) {
  2369. var $1;
  2370. $1=_st($PackageHandler())._for_(self._transportType());
  2371. return $1;
  2372. }, function($ctx1) {$ctx1.fill(self,"transport",{},smalltalk.Package)})},
  2373. args: [],
  2374. source: "transport\x0a\x09^ PackageHandler for: self transportType",
  2375. messageSends: ["for:", "transportType"],
  2376. referencedClasses: ["PackageHandler"]
  2377. }),
  2378. smalltalk.Package);
  2379. smalltalk.addMethod(
  2380. smalltalk.method({
  2381. selector: "transportType",
  2382. category: '*Importer-Exporter',
  2383. fn: function (){
  2384. var self=this;
  2385. return smalltalk.withContext(function($ctx1) {
  2386. return (self.transport && self.transport.type) || 'unknown';;
  2387. return self}, function($ctx1) {$ctx1.fill(self,"transportType",{},smalltalk.Package)})},
  2388. args: [],
  2389. source: "transportType\x0a\x09<return (self.transport && self.transport.type) || 'unknown';>",
  2390. messageSends: [],
  2391. referencedClasses: []
  2392. }),
  2393. smalltalk.Package);
  2394. })(global_smalltalk,global_nil,global__st);