Kernel-ImportExport.js 99 KB

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