Kernel-ImportExport.js 94 KB

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