2
0

Kernel-ImportExport.js 95 KB

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