2
0

Importer-Exporter.js 91 KB

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