Importer-Exporter.js 89 KB

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