1
0

Kernel-ImportExport.js 94 KB

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