Importer-Exporter.js 91 KB

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