Importer-Exporter.js 88 KB

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