Importer-Exporter.js 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046
  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:", "isMetaclass", ",", "name", "instanceClass", "isNil"],
  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,1)})}));
  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:", "extensionProtocolsOfPackage:", "addAll:", "methods"],
  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 $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  98. function $ExportMethodProtocol(){return smalltalk.ExportMethodProtocol||(typeof ExportMethodProtocol=="undefined"?nil:ExportMethodProtocol)}
  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,2)})}));
  112. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  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:", "classes", "current", "class", "ifTrue:", "includes:", "protocols", "add:", "name:theClass:"],
  119. referencedClasses: ["OrderedCollection", "Smalltalk", "ExportMethodProtocol"]
  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,1)})}),(function(){
  179. return smalltalk.withContext(function($ctx2) {
  180. return _st(aStream)._nextPutAll_(" ");
  181. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  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:", "notEmpty", "comment", "chunkEscape:"],
  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,2)})}),(function(){
  223. return smalltalk.withContext(function($ctx2) {
  224. return _st(aStream)._nextPutAll_(" ");
  225. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
  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:", "isEmpty", "instanceVariableNames", "class", "nextPutAll:", "classNameFor:", "do:separatedBy:", "lf"],
  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,1)})}));
  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:", "sortedClasses", "exportDefinitionOf:on:", "exportProtocols:on:", "ownMethodProtocolsOfClass:", "exportMetaDefinitionOf:on:", "class", "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,1)})}));
  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:", "methods", "exportMethod:on:", "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,1)})}));
  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 $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
  385. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  386. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  387. function $MethodCategory(){return smalltalk.MethodCategory||(typeof MethodCategory=="undefined"?nil:MethodCategory)}
  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,3)})}));
  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,5)})})))._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,6)})})));
  412. }, function($ctx3) {$ctx3.fillBlock({aClass:aClass},$ctx2,2)})}));
  413. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  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:", "sortedClasses:", "classes", "current", "class", "protocolsDo:", "ifTrue:", "=", ",", "at:put:", "addAll:", "collect:", "sorted:", "keys", "<=", "name:theClass:methods:", "at:"],
  420. referencedClasses: ["OrderedCollection", "Package", "Smalltalk", "Dictionary", "MethodCategory"]
  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,1)})}));
  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:", "methods", "<=", "selector"],
  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,1)})}));
  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,3)})})))._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,4)})}));
  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:", "match:", "at:put:", "collect:", "sorted:", "keys", "<=", "name:theClass:methods:", "at:"],
  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,1)})}));
  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:", "ownProtocols", "name:theClass:"],
  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:", "isMetaclass", ",", "name", "instanceClass", "isNil"],
  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,1)})}),(function(){
  562. return smalltalk.withContext(function($ctx2) {
  563. return _st(aStream)._nextPutAll_(", ");
  564. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  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:", "notEmpty", "comment", "asJavascript"],
  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,2)})}),(function(){
  608. return smalltalk.withContext(function($ctx2) {
  609. return _st(aStream)._nextPutAll_(",");
  610. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
  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:", "isEmpty", "instanceVariableNames", "class", "nextPutAll:", ",", "classNameFor:", "do:separatedBy:"],
  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,2)})}));
  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,3)})}));
  685. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  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,4)})}));
  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:", "sortedClasses", "exportDefinitionOf:on:", "ownMethods", "exportMethod:on:", "exportMetaDefinitionOf:on:", "class", "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. return smalltalk.withContext(function($ctx1) {
  760. var $1,$2;
  761. $1=aStream;
  762. _st($1)._nextPutAll_("smalltalk.packages[");
  763. _st($1)._nextPutAll_(_st(_st(aPackage)._name())._asJavascript());
  764. _st($1)._nextPutAll_("].transport = ");
  765. _st($1)._nextPutAll_(_st(_st(aPackage)._transport())._asJSONString());
  766. _st($1)._nextPutAll_(";");
  767. $2=_st($1)._lf();
  768. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageTransportOf:on:",{aPackage:aPackage,aStream:aStream},smalltalk.Exporter)})},
  769. args: ["aPackage", "aStream"],
  770. source: "exportPackageTransportOf: aPackage on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: 'smalltalk.packages[';\x0a\x09\x09nextPutAll: aPackage name asJavascript;\x0a\x09\x09nextPutAll: '].transport = ';\x0a\x09\x09nextPutAll: aPackage transport asJSONString;\x0a\x09\x09nextPutAll: ';';\x0a\x09\x09lf",
  771. messageSends: ["nextPutAll:", "asJavascript", "name", "asJSONString", "transport", "lf"],
  772. referencedClasses: []
  773. }),
  774. smalltalk.Exporter);
  775. smalltalk.addMethod(
  776. smalltalk.method({
  777. selector: "ownMethodsOfClass:",
  778. category: 'accessing',
  779. fn: function (aClass){
  780. var self=this;
  781. return smalltalk.withContext(function($ctx1) {
  782. var $1;
  783. $1=_st(_st(_st(_st(aClass)._methodDictionary())._values())._sorted_((function(a,b){
  784. return smalltalk.withContext(function($ctx2) {
  785. return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  786. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1,1)})})))._reject_((function(each){
  787. return smalltalk.withContext(function($ctx2) {
  788. return _st(_st(each)._category())._match_("^\x5c*");
  789. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  790. return $1;
  791. }, function($ctx1) {$ctx1.fill(self,"ownMethodsOfClass:",{aClass:aClass},smalltalk.Exporter)})},
  792. args: ["aClass"],
  793. 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*')]",
  794. messageSends: ["reject:", "sorted:", "values", "methodDictionary", "<=", "selector", "match:", "category"],
  795. referencedClasses: []
  796. }),
  797. smalltalk.Exporter);
  798. smalltalk.addMethod(
  799. smalltalk.method({
  800. selector: "ownMethodsOfMetaClass:",
  801. category: 'accessing',
  802. fn: function (aClass){
  803. var self=this;
  804. return smalltalk.withContext(function($ctx1) {
  805. var $1;
  806. $1=self._ownMethodsOfClass_(_st(aClass)._class());
  807. return $1;
  808. }, function($ctx1) {$ctx1.fill(self,"ownMethodsOfMetaClass:",{aClass:aClass},smalltalk.Exporter)})},
  809. args: ["aClass"],
  810. source: "ownMethodsOfMetaClass: aClass\x0a\x09\x22Issue #143: sort methods alphabetically\x22\x0a\x0a\x09^self ownMethodsOfClass: aClass class",
  811. messageSends: ["ownMethodsOfClass:", "class"],
  812. referencedClasses: []
  813. }),
  814. smalltalk.Exporter);
  815. smalltalk.addClass('AmdExporter', smalltalk.Exporter, ['namespace'], 'Importer-Exporter');
  816. smalltalk.AmdExporter.comment="I am used to export Packages in an AMD (Asynchronous Module Definition) JavaScript format.";
  817. smalltalk.addMethod(
  818. smalltalk.method({
  819. selector: "amdNamesOfPackages:",
  820. category: 'private',
  821. fn: function (anArray){
  822. var self=this;
  823. return smalltalk.withContext(function($ctx1) {
  824. var $1;
  825. $1=_st(_st(anArray)._select_((function(each){
  826. return smalltalk.withContext(function($ctx2) {
  827. return _st(self._amdNamespaceOfPackage_(each))._notNil();
  828. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})))._collect_((function(each){
  829. return smalltalk.withContext(function($ctx2) {
  830. return _st(_st(self._amdNamespaceOfPackage_(each)).__comma("/")).__comma(_st(each)._name());
  831. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  832. return $1;
  833. }, function($ctx1) {$ctx1.fill(self,"amdNamesOfPackages:",{anArray:anArray},smalltalk.AmdExporter)})},
  834. args: ["anArray"],
  835. source: "amdNamesOfPackages: anArray\x0a\x09^ (anArray\x0a\x09\x09select: [ :each | (self amdNamespaceOfPackage: each) notNil ])\x0a\x09\x09collect: [ :each | (self amdNamespaceOfPackage: each), '/', each name ]",
  836. messageSends: ["collect:", "select:", "notNil", "amdNamespaceOfPackage:", ",", "name"],
  837. referencedClasses: []
  838. }),
  839. smalltalk.AmdExporter);
  840. smalltalk.addMethod(
  841. smalltalk.method({
  842. selector: "amdNamespaceOfPackage:",
  843. category: 'private',
  844. fn: function (aPackage){
  845. var self=this;
  846. return smalltalk.withContext(function($ctx1) {
  847. var $2,$1;
  848. $2=_st(_st(_st(aPackage)._transport())._type()).__eq("amd");
  849. if(smalltalk.assert($2)){
  850. $1=_st(_st(aPackage)._transport())._namespace();
  851. } else {
  852. $1=nil;
  853. };
  854. return $1;
  855. }, function($ctx1) {$ctx1.fill(self,"amdNamespaceOfPackage:",{aPackage:aPackage},smalltalk.AmdExporter)})},
  856. args: ["aPackage"],
  857. source: "amdNamespaceOfPackage: aPackage\x0a\x09^ (aPackage transport type = 'amd')\x0a\x09\x09ifTrue: [ aPackage transport namespace ]\x0a\x09\x09ifFalse: [ nil ]",
  858. messageSends: ["ifTrue:ifFalse:", "=", "type", "transport", "namespace"],
  859. referencedClasses: []
  860. }),
  861. smalltalk.AmdExporter);
  862. smalltalk.addMethod(
  863. smalltalk.method({
  864. selector: "exportPackageEpilogueOf:on:",
  865. category: 'output',
  866. fn: function (aPackage,aStream){
  867. var self=this;
  868. return smalltalk.withContext(function($ctx1) {
  869. var $1,$2;
  870. $1=aStream;
  871. _st($1)._nextPutAll_("});");
  872. $2=_st($1)._lf();
  873. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageEpilogueOf:on:",{aPackage:aPackage,aStream:aStream},smalltalk.AmdExporter)})},
  874. args: ["aPackage", "aStream"],
  875. source: "exportPackageEpilogueOf: aPackage on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: '});';\x0a\x09\x09lf",
  876. messageSends: ["nextPutAll:", "lf"],
  877. referencedClasses: []
  878. }),
  879. smalltalk.AmdExporter);
  880. smalltalk.addMethod(
  881. smalltalk.method({
  882. selector: "exportPackagePrologueOf:on:",
  883. category: 'output',
  884. fn: function (aPackage,aStream){
  885. var self=this;
  886. return smalltalk.withContext(function($ctx1) {
  887. var $1,$2;
  888. $1=aStream;
  889. _st($1)._nextPutAll_("define(\x22");
  890. _st($1)._nextPutAll_(self._amdNamespaceOfPackage_(aPackage));
  891. _st($1)._nextPutAll_("/");
  892. _st($1)._nextPutAll_(_st(aPackage)._name());
  893. _st($1)._nextPutAll_("\x22, ");
  894. _st($1)._nextPutAll_(_st(["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st"].__comma(self._amdNamesOfPackages_(_st(aPackage)._loadDependencies())))._asJavascript());
  895. _st($1)._nextPutAll_(", function(smalltalk,nil,_st){");
  896. $2=_st($1)._lf();
  897. return self}, function($ctx1) {$ctx1.fill(self,"exportPackagePrologueOf:on:",{aPackage:aPackage,aStream:aStream},smalltalk.AmdExporter)})},
  898. args: ["aPackage", "aStream"],
  899. 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",
  900. messageSends: ["nextPutAll:", "amdNamespaceOfPackage:", "name", "asJavascript", ",", "amdNamesOfPackages:", "loadDependencies", "lf"],
  901. referencedClasses: []
  902. }),
  903. smalltalk.AmdExporter);
  904. smalltalk.addClass('ChunkParser', smalltalk.Object, ['stream'], 'Importer-Exporter');
  905. 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";
  906. smalltalk.addMethod(
  907. smalltalk.method({
  908. selector: "nextChunk",
  909. category: 'reading',
  910. fn: function (){
  911. var self=this;
  912. var char,result,chunk;
  913. return smalltalk.withContext(function($ctx1) {
  914. var $1,$2,$3;
  915. var $early={};
  916. try {
  917. result=""._writeStream();
  918. _st((function(){
  919. return smalltalk.withContext(function($ctx2) {
  920. char=_st(self["@stream"])._next();
  921. char;
  922. return _st(char)._notNil();
  923. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileTrue_((function(){
  924. return smalltalk.withContext(function($ctx2) {
  925. $1=_st(char).__eq("!");
  926. if(smalltalk.assert($1)){
  927. $2=_st(_st(self["@stream"])._peek()).__eq("!");
  928. if(smalltalk.assert($2)){
  929. _st(self["@stream"])._next();
  930. } else {
  931. $3=_st(_st(result)._contents())._trimBoth();
  932. throw $early=[$3];
  933. };
  934. };
  935. return _st(result)._nextPut_(char);
  936. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  937. return nil;
  938. }
  939. catch(e) {if(e===$early)return e[0]; throw e}
  940. }, function($ctx1) {$ctx1.fill(self,"nextChunk",{char:char,result:result,chunk:chunk},smalltalk.ChunkParser)})},
  941. args: [],
  942. 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",
  943. messageSends: ["writeStream", "whileTrue:", "next", "notNil", "ifTrue:", "=", "ifTrue:ifFalse:", "peek", "trimBoth", "contents", "nextPut:"],
  944. referencedClasses: []
  945. }),
  946. smalltalk.ChunkParser);
  947. smalltalk.addMethod(
  948. smalltalk.method({
  949. selector: "stream:",
  950. category: 'accessing',
  951. fn: function (aStream){
  952. var self=this;
  953. return smalltalk.withContext(function($ctx1) {
  954. self["@stream"]=aStream;
  955. return self}, function($ctx1) {$ctx1.fill(self,"stream:",{aStream:aStream},smalltalk.ChunkParser)})},
  956. args: ["aStream"],
  957. source: "stream: aStream\x0a\x09stream := aStream",
  958. messageSends: [],
  959. referencedClasses: []
  960. }),
  961. smalltalk.ChunkParser);
  962. smalltalk.addMethod(
  963. smalltalk.method({
  964. selector: "on:",
  965. category: 'instance creation',
  966. fn: function (aStream){
  967. var self=this;
  968. return smalltalk.withContext(function($ctx1) {
  969. var $1;
  970. $1=_st(self._new())._stream_(aStream);
  971. return $1;
  972. }, function($ctx1) {$ctx1.fill(self,"on:",{aStream:aStream},smalltalk.ChunkParser.klass)})},
  973. args: ["aStream"],
  974. source: "on: aStream\x0a\x09^self new stream: aStream",
  975. messageSends: ["stream:", "new"],
  976. referencedClasses: []
  977. }),
  978. smalltalk.ChunkParser.klass);
  979. smalltalk.addClass('ExportMethodProtocol', smalltalk.Object, ['name', 'theClass'], 'Importer-Exporter');
  980. 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.";
  981. smalltalk.addMethod(
  982. smalltalk.method({
  983. selector: "methods",
  984. category: 'accessing',
  985. fn: function (){
  986. var self=this;
  987. return smalltalk.withContext(function($ctx1) {
  988. var $1;
  989. $1=_st(self._theClass())._methodsInProtocol_(self._name());
  990. return $1;
  991. }, function($ctx1) {$ctx1.fill(self,"methods",{},smalltalk.ExportMethodProtocol)})},
  992. args: [],
  993. source: "methods\x0a\x09^ self theClass methodsInProtocol: self name",
  994. messageSends: ["methodsInProtocol:", "theClass", "name"],
  995. referencedClasses: []
  996. }),
  997. smalltalk.ExportMethodProtocol);
  998. smalltalk.addMethod(
  999. smalltalk.method({
  1000. selector: "name",
  1001. category: 'accessing',
  1002. fn: function (){
  1003. var self=this;
  1004. return smalltalk.withContext(function($ctx1) {
  1005. var $1;
  1006. $1=self["@name"];
  1007. return $1;
  1008. }, function($ctx1) {$ctx1.fill(self,"name",{},smalltalk.ExportMethodProtocol)})},
  1009. args: [],
  1010. source: "name\x0a\x09^name",
  1011. messageSends: [],
  1012. referencedClasses: []
  1013. }),
  1014. smalltalk.ExportMethodProtocol);
  1015. smalltalk.addMethod(
  1016. smalltalk.method({
  1017. selector: "name:",
  1018. category: 'accessing',
  1019. fn: function (aString){
  1020. var self=this;
  1021. return smalltalk.withContext(function($ctx1) {
  1022. self["@name"]=aString;
  1023. return self}, function($ctx1) {$ctx1.fill(self,"name:",{aString:aString},smalltalk.ExportMethodProtocol)})},
  1024. args: ["aString"],
  1025. source: "name: aString\x0a\x09name := aString",
  1026. messageSends: [],
  1027. referencedClasses: []
  1028. }),
  1029. smalltalk.ExportMethodProtocol);
  1030. smalltalk.addMethod(
  1031. smalltalk.method({
  1032. selector: "sortedMethods",
  1033. category: 'accessing',
  1034. fn: function (){
  1035. var self=this;
  1036. return smalltalk.withContext(function($ctx1) {
  1037. var $1;
  1038. $1=_st(self._methods())._sorted_((function(a,b){
  1039. return smalltalk.withContext(function($ctx2) {
  1040. return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  1041. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1,1)})}));
  1042. return $1;
  1043. }, function($ctx1) {$ctx1.fill(self,"sortedMethods",{},smalltalk.ExportMethodProtocol)})},
  1044. args: [],
  1045. source: "sortedMethods\x0a\x09^ self methods sorted: [ :a :b | a selector <= b selector ]",
  1046. messageSends: ["sorted:", "methods", "<=", "selector"],
  1047. referencedClasses: []
  1048. }),
  1049. smalltalk.ExportMethodProtocol);
  1050. smalltalk.addMethod(
  1051. smalltalk.method({
  1052. selector: "theClass",
  1053. category: 'accessing',
  1054. fn: function (){
  1055. var self=this;
  1056. return smalltalk.withContext(function($ctx1) {
  1057. var $1;
  1058. $1=self["@theClass"];
  1059. return $1;
  1060. }, function($ctx1) {$ctx1.fill(self,"theClass",{},smalltalk.ExportMethodProtocol)})},
  1061. args: [],
  1062. source: "theClass\x0a\x09^theClass",
  1063. messageSends: [],
  1064. referencedClasses: []
  1065. }),
  1066. smalltalk.ExportMethodProtocol);
  1067. smalltalk.addMethod(
  1068. smalltalk.method({
  1069. selector: "theClass:",
  1070. category: 'accessing',
  1071. fn: function (aClass){
  1072. var self=this;
  1073. return smalltalk.withContext(function($ctx1) {
  1074. self["@theClass"]=aClass;
  1075. return self}, function($ctx1) {$ctx1.fill(self,"theClass:",{aClass:aClass},smalltalk.ExportMethodProtocol)})},
  1076. args: ["aClass"],
  1077. source: "theClass: aClass\x0a\x09theClass := aClass",
  1078. messageSends: [],
  1079. referencedClasses: []
  1080. }),
  1081. smalltalk.ExportMethodProtocol);
  1082. smalltalk.addMethod(
  1083. smalltalk.method({
  1084. selector: "name:theClass:",
  1085. category: 'instance creation',
  1086. fn: function (aString,aClass){
  1087. var self=this;
  1088. return smalltalk.withContext(function($ctx1) {
  1089. var $2,$3,$1;
  1090. $2=self._new();
  1091. _st($2)._name_(aString);
  1092. _st($2)._theClass_(aClass);
  1093. $3=_st($2)._yourself();
  1094. $1=$3;
  1095. return $1;
  1096. }, function($ctx1) {$ctx1.fill(self,"name:theClass:",{aString:aString,aClass:aClass},smalltalk.ExportMethodProtocol.klass)})},
  1097. args: ["aString", "aClass"],
  1098. source: "name: aString theClass: aClass\x0a\x09^self new\x0a\x09\x09name: aString;\x0a\x09\x09theClass: aClass;\x0a\x09\x09yourself",
  1099. messageSends: ["name:", "new", "theClass:", "yourself"],
  1100. referencedClasses: []
  1101. }),
  1102. smalltalk.ExportMethodProtocol.klass);
  1103. smalltalk.addClass('Importer', smalltalk.Object, [], 'Importer-Exporter');
  1104. smalltalk.Importer.comment="I can import Amber code from a string in the chunk format.\x0a\x0a## API\x0a\x0a Importer new import: aString";
  1105. smalltalk.addMethod(
  1106. smalltalk.method({
  1107. selector: "import:",
  1108. category: 'fileIn',
  1109. fn: function (aStream){
  1110. var self=this;
  1111. var chunk,result,parser,lastEmpty;
  1112. function $ChunkParser(){return smalltalk.ChunkParser||(typeof ChunkParser=="undefined"?nil:ChunkParser)}
  1113. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  1114. return smalltalk.withContext(function($ctx1) {
  1115. var $1,$2;
  1116. parser=_st($ChunkParser())._on_(aStream);
  1117. lastEmpty=false;
  1118. _st((function(){
  1119. return smalltalk.withContext(function($ctx2) {
  1120. chunk=_st(parser)._nextChunk();
  1121. chunk;
  1122. return _st(chunk)._isNil();
  1123. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
  1124. return smalltalk.withContext(function($ctx2) {
  1125. $1=_st(chunk)._isEmpty();
  1126. if(smalltalk.assert($1)){
  1127. lastEmpty=true;
  1128. return lastEmpty;
  1129. } else {
  1130. result=_st(_st($Compiler())._new())._evaluateExpression_(chunk);
  1131. result;
  1132. $2=lastEmpty;
  1133. if(smalltalk.assert($2)){
  1134. lastEmpty=false;
  1135. lastEmpty;
  1136. return _st(result)._scanFrom_(parser);
  1137. };
  1138. };
  1139. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1140. return self}, function($ctx1) {$ctx1.fill(self,"import:",{aStream:aStream,chunk:chunk,result:result,parser:parser,lastEmpty:lastEmpty},smalltalk.Importer)})},
  1141. args: ["aStream"],
  1142. 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]]]",
  1143. messageSends: ["on:", "whileFalse:", "nextChunk", "isNil", "ifTrue:ifFalse:", "isEmpty", "evaluateExpression:", "new", "ifTrue:", "scanFrom:"],
  1144. referencedClasses: ["ChunkParser", "Compiler"]
  1145. }),
  1146. smalltalk.Importer);
  1147. smalltalk.addClass('PackageHandler', smalltalk.InterfacingObject, [], 'Importer-Exporter');
  1148. 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.";
  1149. smalltalk.addMethod(
  1150. smalltalk.method({
  1151. selector: "ajaxPutAt:data:",
  1152. category: 'private',
  1153. fn: function (aURL,aString){
  1154. var self=this;
  1155. return smalltalk.withContext(function($ctx1) {
  1156. 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){
  1157. return smalltalk.withContext(function($ctx2) {
  1158. return self._error_(_st(_st(_st("Commiting ".__comma(aURL)).__comma(" failed with reason: \x22")).__comma(_st(xhr)._responseText())).__comma("\x22"));
  1159. }, function($ctx2) {$ctx2.fillBlock({xhr:xhr},$ctx1,1)})}))]));
  1160. return self}, function($ctx1) {$ctx1.fill(self,"ajaxPutAt:data:",{aURL:aURL,aString:aString},smalltalk.PackageHandler)})},
  1161. args: ["aURL", "aString"],
  1162. 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'] }",
  1163. messageSends: ["ajax:", "->", "error:", ",", "responseText"],
  1164. referencedClasses: []
  1165. }),
  1166. smalltalk.PackageHandler);
  1167. smalltalk.addMethod(
  1168. smalltalk.method({
  1169. selector: "chunkContentsFor:",
  1170. category: 'accessing',
  1171. fn: function (aPackage){
  1172. var self=this;
  1173. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  1174. return smalltalk.withContext(function($ctx1) {
  1175. var $1;
  1176. $1=_st($String())._streamContents_((function(str){
  1177. return smalltalk.withContext(function($ctx2) {
  1178. return _st(self._chunkExporter())._exportPackage_on_(aPackage,str);
  1179. }, function($ctx2) {$ctx2.fillBlock({str:str},$ctx1,1)})}));
  1180. return $1;
  1181. }, function($ctx1) {$ctx1.fill(self,"chunkContentsFor:",{aPackage:aPackage},smalltalk.PackageHandler)})},
  1182. args: ["aPackage"],
  1183. source: "chunkContentsFor: aPackage\x0a\x09^ String streamContents: [ :str |\x0a\x09\x09self chunkExporter exportPackage: aPackage on: str ]",
  1184. messageSends: ["streamContents:", "exportPackage:on:", "chunkExporter"],
  1185. referencedClasses: ["String"]
  1186. }),
  1187. smalltalk.PackageHandler);
  1188. smalltalk.addMethod(
  1189. smalltalk.method({
  1190. selector: "chunkExporter",
  1191. category: 'factory',
  1192. fn: function (){
  1193. var self=this;
  1194. return smalltalk.withContext(function($ctx1) {
  1195. var $1;
  1196. $1=_st(self._chunkExporterClass())._new();
  1197. return $1;
  1198. }, function($ctx1) {$ctx1.fill(self,"chunkExporter",{},smalltalk.PackageHandler)})},
  1199. args: [],
  1200. source: "chunkExporter\x0a\x09^ self chunkExporterClass new",
  1201. messageSends: ["new", "chunkExporterClass"],
  1202. referencedClasses: []
  1203. }),
  1204. smalltalk.PackageHandler);
  1205. smalltalk.addMethod(
  1206. smalltalk.method({
  1207. selector: "chunkExporterClass",
  1208. category: 'accessing',
  1209. fn: function (){
  1210. var self=this;
  1211. function $ChunkExporter(){return smalltalk.ChunkExporter||(typeof ChunkExporter=="undefined"?nil:ChunkExporter)}
  1212. return smalltalk.withContext(function($ctx1) {
  1213. var $1;
  1214. $1=$ChunkExporter();
  1215. return $1;
  1216. }, function($ctx1) {$ctx1.fill(self,"chunkExporterClass",{},smalltalk.PackageHandler)})},
  1217. args: [],
  1218. source: "chunkExporterClass\x0a\x09^ ChunkExporter",
  1219. messageSends: [],
  1220. referencedClasses: ["ChunkExporter"]
  1221. }),
  1222. smalltalk.PackageHandler);
  1223. smalltalk.addMethod(
  1224. smalltalk.method({
  1225. selector: "commit:",
  1226. category: 'committing',
  1227. fn: function (aPackage){
  1228. var self=this;
  1229. return smalltalk.withContext(function($ctx1) {
  1230. _st([(function(){
  1231. return smalltalk.withContext(function($ctx2) {
  1232. return self._commitStFileFor_(aPackage);
  1233. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(){
  1234. return smalltalk.withContext(function($ctx2) {
  1235. return self._commitJsFileFor_(aPackage);
  1236. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})})])._do_displayingProgress_((function(each){
  1237. return smalltalk.withContext(function($ctx2) {
  1238. return _st(each)._value();
  1239. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,3)})}),"Committing package ".__comma(_st(aPackage)._name()));
  1240. return self}, function($ctx1) {$ctx1.fill(self,"commit:",{aPackage:aPackage},smalltalk.PackageHandler)})},
  1241. args: ["aPackage"],
  1242. 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",
  1243. messageSends: ["do:displayingProgress:", "commitStFileFor:", "commitJsFileFor:", "value", ",", "name"],
  1244. referencedClasses: []
  1245. }),
  1246. smalltalk.PackageHandler);
  1247. smalltalk.addMethod(
  1248. smalltalk.method({
  1249. selector: "commitJsFileFor:",
  1250. category: 'committing',
  1251. fn: function (aPackage){
  1252. var self=this;
  1253. return smalltalk.withContext(function($ctx1) {
  1254. self._ajaxPutAt_data_(_st(_st(_st(self._commitPathJsFor_(aPackage)).__comma("/")).__comma(_st(aPackage)._name())).__comma(".js"),self._contentsFor_(aPackage));
  1255. return self}, function($ctx1) {$ctx1.fill(self,"commitJsFileFor:",{aPackage:aPackage},smalltalk.PackageHandler)})},
  1256. args: ["aPackage"],
  1257. source: "commitJsFileFor: aPackage\x0a\x09self \x0a\x09\x09ajaxPutAt: (self commitPathJsFor: aPackage), '/', aPackage name, '.js'\x0a\x09\x09data: (self contentsFor: aPackage)",
  1258. messageSends: ["ajaxPutAt:data:", ",", "commitPathJsFor:", "name", "contentsFor:"],
  1259. referencedClasses: []
  1260. }),
  1261. smalltalk.PackageHandler);
  1262. smalltalk.addMethod(
  1263. smalltalk.method({
  1264. selector: "commitPathJsFor:",
  1265. category: 'accessing',
  1266. fn: function (aPackage){
  1267. var self=this;
  1268. return smalltalk.withContext(function($ctx1) {
  1269. self._subclassResponsibility();
  1270. return self}, function($ctx1) {$ctx1.fill(self,"commitPathJsFor:",{aPackage:aPackage},smalltalk.PackageHandler)})},
  1271. args: ["aPackage"],
  1272. source: "commitPathJsFor: aPackage\x0a\x09self subclassResponsibility",
  1273. messageSends: ["subclassResponsibility"],
  1274. referencedClasses: []
  1275. }),
  1276. smalltalk.PackageHandler);
  1277. smalltalk.addMethod(
  1278. smalltalk.method({
  1279. selector: "commitPathStFor:",
  1280. category: 'accessing',
  1281. fn: function (aPackage){
  1282. var self=this;
  1283. return smalltalk.withContext(function($ctx1) {
  1284. self._subclassResponsibility();
  1285. return self}, function($ctx1) {$ctx1.fill(self,"commitPathStFor:",{aPackage:aPackage},smalltalk.PackageHandler)})},
  1286. args: ["aPackage"],
  1287. source: "commitPathStFor: aPackage\x0a\x09self subclassResponsibility",
  1288. messageSends: ["subclassResponsibility"],
  1289. referencedClasses: []
  1290. }),
  1291. smalltalk.PackageHandler);
  1292. smalltalk.addMethod(
  1293. smalltalk.method({
  1294. selector: "commitStFileFor:",
  1295. category: 'committing',
  1296. fn: function (aPackage){
  1297. var self=this;
  1298. return smalltalk.withContext(function($ctx1) {
  1299. self._ajaxPutAt_data_(_st(_st(_st(self._commitPathStFor_(aPackage)).__comma("/")).__comma(_st(aPackage)._name())).__comma(".st"),self._chunkContentsFor_(aPackage));
  1300. return self}, function($ctx1) {$ctx1.fill(self,"commitStFileFor:",{aPackage:aPackage},smalltalk.PackageHandler)})},
  1301. args: ["aPackage"],
  1302. source: "commitStFileFor: aPackage\x0a\x09self \x0a\x09\x09ajaxPutAt: (self commitPathStFor: aPackage), '/', aPackage name, '.st'\x0a\x09\x09data: (self chunkContentsFor: aPackage)",
  1303. messageSends: ["ajaxPutAt:data:", ",", "commitPathStFor:", "name", "chunkContentsFor:"],
  1304. referencedClasses: []
  1305. }),
  1306. smalltalk.PackageHandler);
  1307. smalltalk.addMethod(
  1308. smalltalk.method({
  1309. selector: "contentsFor:",
  1310. category: 'accessing',
  1311. fn: function (aPackage){
  1312. var self=this;
  1313. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  1314. return smalltalk.withContext(function($ctx1) {
  1315. var $1;
  1316. $1=_st($String())._streamContents_((function(str){
  1317. return smalltalk.withContext(function($ctx2) {
  1318. return _st(self._exporter())._exportPackage_on_(aPackage,str);
  1319. }, function($ctx2) {$ctx2.fillBlock({str:str},$ctx1,1)})}));
  1320. return $1;
  1321. }, function($ctx1) {$ctx1.fill(self,"contentsFor:",{aPackage:aPackage},smalltalk.PackageHandler)})},
  1322. args: ["aPackage"],
  1323. source: "contentsFor: aPackage\x0a\x09^ String streamContents: [ :str |\x0a\x09\x09self exporter exportPackage: aPackage on: str ]",
  1324. messageSends: ["streamContents:", "exportPackage:on:", "exporter"],
  1325. referencedClasses: ["String"]
  1326. }),
  1327. smalltalk.PackageHandler);
  1328. smalltalk.addMethod(
  1329. smalltalk.method({
  1330. selector: "exporter",
  1331. category: 'factory',
  1332. fn: function (){
  1333. var self=this;
  1334. return smalltalk.withContext(function($ctx1) {
  1335. var $1;
  1336. $1=_st(self._exporterClass())._new();
  1337. return $1;
  1338. }, function($ctx1) {$ctx1.fill(self,"exporter",{},smalltalk.PackageHandler)})},
  1339. args: [],
  1340. source: "exporter\x0a\x09^ self exporterClass new",
  1341. messageSends: ["new", "exporterClass"],
  1342. referencedClasses: []
  1343. }),
  1344. smalltalk.PackageHandler);
  1345. smalltalk.addMethod(
  1346. smalltalk.method({
  1347. selector: "exporterClass",
  1348. category: 'accessing',
  1349. fn: function (){
  1350. var self=this;
  1351. function $Exporter(){return smalltalk.Exporter||(typeof Exporter=="undefined"?nil:Exporter)}
  1352. return smalltalk.withContext(function($ctx1) {
  1353. var $1;
  1354. $1=$Exporter();
  1355. return $1;
  1356. }, function($ctx1) {$ctx1.fill(self,"exporterClass",{},smalltalk.PackageHandler)})},
  1357. args: [],
  1358. source: "exporterClass\x0a\x09^ Exporter",
  1359. messageSends: [],
  1360. referencedClasses: ["Exporter"]
  1361. }),
  1362. smalltalk.PackageHandler);
  1363. smalltalk.addClass('AmdPackageHandler', smalltalk.PackageHandler, [], 'Importer-Exporter');
  1364. 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.";
  1365. smalltalk.addMethod(
  1366. smalltalk.method({
  1367. selector: "commitPathJsFor:",
  1368. category: 'accessing',
  1369. fn: function (aPackage){
  1370. var self=this;
  1371. return smalltalk.withContext(function($ctx1) {
  1372. var $1;
  1373. $1=self._toUrl_(self._namespaceFor_(aPackage));
  1374. return $1;
  1375. }, function($ctx1) {$ctx1.fill(self,"commitPathJsFor:",{aPackage:aPackage},smalltalk.AmdPackageHandler)})},
  1376. args: ["aPackage"],
  1377. source: "commitPathJsFor: aPackage\x0a\x09^self toUrl: (self namespaceFor: aPackage)",
  1378. messageSends: ["toUrl:", "namespaceFor:"],
  1379. referencedClasses: []
  1380. }),
  1381. smalltalk.AmdPackageHandler);
  1382. smalltalk.addMethod(
  1383. smalltalk.method({
  1384. selector: "commitPathStFor:",
  1385. category: 'accessing',
  1386. fn: function (aPackage){
  1387. var self=this;
  1388. return smalltalk.withContext(function($ctx1) {
  1389. var $1;
  1390. $1=self._toUrl_(_st(self._namespaceFor_(aPackage)).__comma("/_source"));
  1391. return $1;
  1392. }, function($ctx1) {$ctx1.fill(self,"commitPathStFor:",{aPackage:aPackage},smalltalk.AmdPackageHandler)})},
  1393. args: ["aPackage"],
  1394. source: "commitPathStFor: aPackage\x0a\x09\x22if _source is not mapped, .st commit will likely fail\x22\x0a\x09^self toUrl: (self namespaceFor: aPackage), '/_source'.",
  1395. messageSends: ["toUrl:", ",", "namespaceFor:"],
  1396. referencedClasses: []
  1397. }),
  1398. smalltalk.AmdPackageHandler);
  1399. smalltalk.addMethod(
  1400. smalltalk.method({
  1401. selector: "exporterClass",
  1402. category: 'accessing',
  1403. fn: function (){
  1404. var self=this;
  1405. function $AmdExporter(){return smalltalk.AmdExporter||(typeof AmdExporter=="undefined"?nil:AmdExporter)}
  1406. return smalltalk.withContext(function($ctx1) {
  1407. var $1;
  1408. $1=$AmdExporter();
  1409. return $1;
  1410. }, function($ctx1) {$ctx1.fill(self,"exporterClass",{},smalltalk.AmdPackageHandler)})},
  1411. args: [],
  1412. source: "exporterClass\x0a\x09^ AmdExporter",
  1413. messageSends: [],
  1414. referencedClasses: ["AmdExporter"]
  1415. }),
  1416. smalltalk.AmdPackageHandler);
  1417. smalltalk.addMethod(
  1418. smalltalk.method({
  1419. selector: "namespaceFor:",
  1420. category: 'committing',
  1421. fn: function (aPackage){
  1422. var self=this;
  1423. return smalltalk.withContext(function($ctx1) {
  1424. var $1;
  1425. $1=_st(_st(aPackage)._transport())._namespace();
  1426. return $1;
  1427. }, function($ctx1) {$ctx1.fill(self,"namespaceFor:",{aPackage:aPackage},smalltalk.AmdPackageHandler)})},
  1428. args: ["aPackage"],
  1429. source: "namespaceFor: aPackage\x0a\x09^ aPackage transport namespace",
  1430. messageSends: ["namespace", "transport"],
  1431. referencedClasses: []
  1432. }),
  1433. smalltalk.AmdPackageHandler);
  1434. smalltalk.addMethod(
  1435. smalltalk.method({
  1436. selector: "toUrl:",
  1437. category: 'private',
  1438. fn: function (aString){
  1439. var self=this;
  1440. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1441. return smalltalk.withContext(function($ctx1) {
  1442. var $2,$1;
  1443. $2=_st(_st($Smalltalk())._current())._amdRequire();
  1444. if(($receiver = $2) == nil || $receiver == null){
  1445. $1=self._error_("AMD loader not present");
  1446. } else {
  1447. var require;
  1448. require=$receiver;
  1449. $1=_st(_st(require)._basicAt_("toUrl"))._value_(aString);
  1450. };
  1451. return $1;
  1452. }, function($ctx1) {$ctx1.fill(self,"toUrl:",{aString:aString},smalltalk.AmdPackageHandler)})},
  1453. args: ["aString"],
  1454. 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 ]",
  1455. messageSends: ["ifNil:ifNotNil:", "amdRequire", "current", "error:", "value:", "basicAt:"],
  1456. referencedClasses: ["Smalltalk"]
  1457. }),
  1458. smalltalk.AmdPackageHandler);
  1459. smalltalk.addMethod(
  1460. smalltalk.method({
  1461. selector: "defaultNamespace",
  1462. category: 'commit paths',
  1463. fn: function (){
  1464. var self=this;
  1465. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1466. return smalltalk.withContext(function($ctx1) {
  1467. var $1;
  1468. $1=_st(_st($Smalltalk())._current())._defaultAmdNamespace();
  1469. return $1;
  1470. }, function($ctx1) {$ctx1.fill(self,"defaultNamespace",{},smalltalk.AmdPackageHandler.klass)})},
  1471. args: [],
  1472. source: "defaultNamespace\x0a\x09^ Smalltalk current defaultAmdNamespace",
  1473. messageSends: ["defaultAmdNamespace", "current"],
  1474. referencedClasses: ["Smalltalk"]
  1475. }),
  1476. smalltalk.AmdPackageHandler.klass);
  1477. smalltalk.addMethod(
  1478. smalltalk.method({
  1479. selector: "defaultNamespace:",
  1480. category: 'commit paths',
  1481. fn: function (aString){
  1482. var self=this;
  1483. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1484. return smalltalk.withContext(function($ctx1) {
  1485. _st(_st($Smalltalk())._current())._defaultAmdNamespace_(aString);
  1486. return self}, function($ctx1) {$ctx1.fill(self,"defaultNamespace:",{aString:aString},smalltalk.AmdPackageHandler.klass)})},
  1487. args: ["aString"],
  1488. source: "defaultNamespace: aString\x0a\x09Smalltalk current defaultAmdNamespace: aString",
  1489. messageSends: ["defaultAmdNamespace:", "current"],
  1490. referencedClasses: ["Smalltalk"]
  1491. }),
  1492. smalltalk.AmdPackageHandler.klass);
  1493. smalltalk.addClass('PackageTransport', smalltalk.Object, ['package'], 'Importer-Exporter');
  1494. 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.";
  1495. smalltalk.addMethod(
  1496. smalltalk.method({
  1497. selector: "asJSON",
  1498. category: 'converting',
  1499. fn: function (){
  1500. var self=this;
  1501. return smalltalk.withContext(function($ctx1) {
  1502. var $1;
  1503. $1=smalltalk.HashedCollection._from_(["type".__minus_gt(self._type())]);
  1504. return $1;
  1505. }, function($ctx1) {$ctx1.fill(self,"asJSON",{},smalltalk.PackageTransport)})},
  1506. args: [],
  1507. source: "asJSON\x0a\x09^ #{ 'type' -> self type }",
  1508. messageSends: ["->", "type"],
  1509. referencedClasses: []
  1510. }),
  1511. smalltalk.PackageTransport);
  1512. smalltalk.addMethod(
  1513. smalltalk.method({
  1514. selector: "commit",
  1515. category: 'committing',
  1516. fn: function (){
  1517. var self=this;
  1518. return smalltalk.withContext(function($ctx1) {
  1519. _st(self._commitHandler())._commit_(self._package());
  1520. return self}, function($ctx1) {$ctx1.fill(self,"commit",{},smalltalk.PackageTransport)})},
  1521. args: [],
  1522. source: "commit\x0a\x09self commitHandler commit: self package",
  1523. messageSends: ["commit:", "commitHandler", "package"],
  1524. referencedClasses: []
  1525. }),
  1526. smalltalk.PackageTransport);
  1527. smalltalk.addMethod(
  1528. smalltalk.method({
  1529. selector: "commitHandler",
  1530. category: 'factory',
  1531. fn: function (){
  1532. var self=this;
  1533. return smalltalk.withContext(function($ctx1) {
  1534. var $1;
  1535. $1=_st(self._commitHandlerClass())._new();
  1536. return $1;
  1537. }, function($ctx1) {$ctx1.fill(self,"commitHandler",{},smalltalk.PackageTransport)})},
  1538. args: [],
  1539. source: "commitHandler\x0a\x09^ self commitHandlerClass new",
  1540. messageSends: ["new", "commitHandlerClass"],
  1541. referencedClasses: []
  1542. }),
  1543. smalltalk.PackageTransport);
  1544. smalltalk.addMethod(
  1545. smalltalk.method({
  1546. selector: "commitHandlerClass",
  1547. category: 'accessing',
  1548. fn: function (){
  1549. var self=this;
  1550. return smalltalk.withContext(function($ctx1) {
  1551. self._subclassResponsibility();
  1552. return self}, function($ctx1) {$ctx1.fill(self,"commitHandlerClass",{},smalltalk.PackageTransport)})},
  1553. args: [],
  1554. source: "commitHandlerClass\x0a\x09self subclassResponsibility",
  1555. messageSends: ["subclassResponsibility"],
  1556. referencedClasses: []
  1557. }),
  1558. smalltalk.PackageTransport);
  1559. smalltalk.addMethod(
  1560. smalltalk.method({
  1561. selector: "package",
  1562. category: 'accessing',
  1563. fn: function (){
  1564. var self=this;
  1565. return smalltalk.withContext(function($ctx1) {
  1566. var $1;
  1567. $1=self["@package"];
  1568. return $1;
  1569. }, function($ctx1) {$ctx1.fill(self,"package",{},smalltalk.PackageTransport)})},
  1570. args: [],
  1571. source: "package\x0a\x09^ package",
  1572. messageSends: [],
  1573. referencedClasses: []
  1574. }),
  1575. smalltalk.PackageTransport);
  1576. smalltalk.addMethod(
  1577. smalltalk.method({
  1578. selector: "package:",
  1579. category: 'accessing',
  1580. fn: function (aPackage){
  1581. var self=this;
  1582. return smalltalk.withContext(function($ctx1) {
  1583. self["@package"]=aPackage;
  1584. return self}, function($ctx1) {$ctx1.fill(self,"package:",{aPackage:aPackage},smalltalk.PackageTransport)})},
  1585. args: ["aPackage"],
  1586. source: "package: aPackage\x0a\x09package := aPackage",
  1587. messageSends: [],
  1588. referencedClasses: []
  1589. }),
  1590. smalltalk.PackageTransport);
  1591. smalltalk.addMethod(
  1592. smalltalk.method({
  1593. selector: "setupFromJson:",
  1594. category: 'initialization',
  1595. fn: function (anObject){
  1596. var self=this;
  1597. return smalltalk.withContext(function($ctx1) {
  1598. return self}, function($ctx1) {$ctx1.fill(self,"setupFromJson:",{anObject:anObject},smalltalk.PackageTransport)})},
  1599. args: ["anObject"],
  1600. source: "setupFromJson: anObject\x0a\x09\x22no op. override if needed in subclasses\x22",
  1601. messageSends: [],
  1602. referencedClasses: []
  1603. }),
  1604. smalltalk.PackageTransport);
  1605. smalltalk.addMethod(
  1606. smalltalk.method({
  1607. selector: "type",
  1608. category: 'accessing',
  1609. fn: function (){
  1610. var self=this;
  1611. return smalltalk.withContext(function($ctx1) {
  1612. var $1;
  1613. $1=_st(self._class())._type();
  1614. return $1;
  1615. }, function($ctx1) {$ctx1.fill(self,"type",{},smalltalk.PackageTransport)})},
  1616. args: [],
  1617. source: "type\x0a\x09^ self class type",
  1618. messageSends: ["type", "class"],
  1619. referencedClasses: []
  1620. }),
  1621. smalltalk.PackageTransport);
  1622. smalltalk.PackageTransport.klass.iVarNames = ['registry'];
  1623. smalltalk.addMethod(
  1624. smalltalk.method({
  1625. selector: "classRegisteredFor:",
  1626. category: 'accessing',
  1627. fn: function (aString){
  1628. var self=this;
  1629. return smalltalk.withContext(function($ctx1) {
  1630. var $1;
  1631. $1=_st(self["@registry"])._at_(aString);
  1632. return $1;
  1633. }, function($ctx1) {$ctx1.fill(self,"classRegisteredFor:",{aString:aString},smalltalk.PackageTransport.klass)})},
  1634. args: ["aString"],
  1635. source: "classRegisteredFor: aString\x0a\x09^ registry at: aString",
  1636. messageSends: ["at:"],
  1637. referencedClasses: []
  1638. }),
  1639. smalltalk.PackageTransport.klass);
  1640. smalltalk.addMethod(
  1641. smalltalk.method({
  1642. selector: "defaultType",
  1643. category: 'accessing',
  1644. fn: function (){
  1645. var self=this;
  1646. function $AmdPackageTransport(){return smalltalk.AmdPackageTransport||(typeof AmdPackageTransport=="undefined"?nil:AmdPackageTransport)}
  1647. return smalltalk.withContext(function($ctx1) {
  1648. var $1;
  1649. $1=_st($AmdPackageTransport())._type();
  1650. return $1;
  1651. }, function($ctx1) {$ctx1.fill(self,"defaultType",{},smalltalk.PackageTransport.klass)})},
  1652. args: [],
  1653. source: "defaultType\x0a\x09^ AmdPackageTransport type",
  1654. messageSends: ["type"],
  1655. referencedClasses: ["AmdPackageTransport"]
  1656. }),
  1657. smalltalk.PackageTransport.klass);
  1658. smalltalk.addMethod(
  1659. smalltalk.method({
  1660. selector: "for:",
  1661. category: 'instance creation',
  1662. fn: function (aString){
  1663. var self=this;
  1664. return smalltalk.withContext(function($ctx1) {
  1665. var $1;
  1666. $1=_st(self._classRegisteredFor_(aString))._new();
  1667. return $1;
  1668. }, function($ctx1) {$ctx1.fill(self,"for:",{aString:aString},smalltalk.PackageTransport.klass)})},
  1669. args: ["aString"],
  1670. source: "for: aString\x0a\x09^ (self classRegisteredFor: aString) new",
  1671. messageSends: ["new", "classRegisteredFor:"],
  1672. referencedClasses: []
  1673. }),
  1674. smalltalk.PackageTransport.klass);
  1675. smalltalk.addMethod(
  1676. smalltalk.method({
  1677. selector: "fromJson:",
  1678. category: 'instance creation',
  1679. fn: function (anObject){
  1680. var self=this;
  1681. return smalltalk.withContext(function($ctx1) {
  1682. var $1,$2,$4,$5,$3;
  1683. $1=anObject;
  1684. if(($receiver = $1) == nil || $receiver == null){
  1685. $2=self._for_(self._defaultType());
  1686. return $2;
  1687. } else {
  1688. $1;
  1689. };
  1690. $4=self._for_(_st(anObject)._type());
  1691. _st($4)._setupFromJson_(anObject);
  1692. $5=_st($4)._yourself();
  1693. $3=$5;
  1694. return $3;
  1695. }, function($ctx1) {$ctx1.fill(self,"fromJson:",{anObject:anObject},smalltalk.PackageTransport.klass)})},
  1696. args: ["anObject"],
  1697. source: "fromJson: anObject\x0a\x09anObject ifNil: [ ^ self for: self defaultType ].\x0a\x09\x0a\x09^ (self for: anObject type)\x0a\x09\x09setupFromJson: anObject;\x0a\x09\x09yourself",
  1698. messageSends: ["ifNil:", "for:", "defaultType", "setupFromJson:", "type", "yourself"],
  1699. referencedClasses: []
  1700. }),
  1701. smalltalk.PackageTransport.klass);
  1702. smalltalk.addMethod(
  1703. smalltalk.method({
  1704. selector: "initialize",
  1705. category: 'initialization',
  1706. fn: function (){
  1707. var self=this;
  1708. return smalltalk.withContext(function($ctx1) {
  1709. smalltalk.PackageTransport.klass.superclass.fn.prototype._initialize.apply(_st(self), []);
  1710. self["@registry"]=smalltalk.HashedCollection._from_([]);
  1711. self._register();
  1712. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.PackageTransport.klass)})},
  1713. args: [],
  1714. source: "initialize\x0a\x09super initialize.\x0a\x09registry := #{}.\x0a\x09self register",
  1715. messageSends: ["initialize", "register"],
  1716. referencedClasses: []
  1717. }),
  1718. smalltalk.PackageTransport.klass);
  1719. smalltalk.addMethod(
  1720. smalltalk.method({
  1721. selector: "register",
  1722. category: 'registration',
  1723. fn: function (){
  1724. var self=this;
  1725. function $PackageTransport(){return smalltalk.PackageTransport||(typeof PackageTransport=="undefined"?nil:PackageTransport)}
  1726. return smalltalk.withContext(function($ctx1) {
  1727. _st($PackageTransport())._register_(self);
  1728. return self}, function($ctx1) {$ctx1.fill(self,"register",{},smalltalk.PackageTransport.klass)})},
  1729. args: [],
  1730. source: "register\x0a\x09PackageTransport register: self",
  1731. messageSends: ["register:"],
  1732. referencedClasses: ["PackageTransport"]
  1733. }),
  1734. smalltalk.PackageTransport.klass);
  1735. smalltalk.addMethod(
  1736. smalltalk.method({
  1737. selector: "register:",
  1738. category: 'registration',
  1739. fn: function (aClass){
  1740. var self=this;
  1741. return smalltalk.withContext(function($ctx1) {
  1742. var $1;
  1743. $1=_st(aClass)._type();
  1744. if(($receiver = $1) == nil || $receiver == null){
  1745. $1;
  1746. } else {
  1747. _st(self["@registry"])._at_put_(_st(aClass)._type(),aClass);
  1748. };
  1749. return self}, function($ctx1) {$ctx1.fill(self,"register:",{aClass:aClass},smalltalk.PackageTransport.klass)})},
  1750. args: ["aClass"],
  1751. source: "register: aClass\x0a\x09aClass type ifNotNil: [\x0a\x09\x09registry at: aClass type put: aClass ]",
  1752. messageSends: ["ifNotNil:", "type", "at:put:"],
  1753. referencedClasses: []
  1754. }),
  1755. smalltalk.PackageTransport.klass);
  1756. smalltalk.addMethod(
  1757. smalltalk.method({
  1758. selector: "type",
  1759. category: 'accessing',
  1760. fn: function (){
  1761. var self=this;
  1762. return smalltalk.withContext(function($ctx1) {
  1763. return nil;
  1764. }, function($ctx1) {$ctx1.fill(self,"type",{},smalltalk.PackageTransport.klass)})},
  1765. args: [],
  1766. source: "type\x0a\x09\x22Override in subclasses\x22\x0a\x09^ nil",
  1767. messageSends: [],
  1768. referencedClasses: []
  1769. }),
  1770. smalltalk.PackageTransport.klass);
  1771. smalltalk.addClass('AmdPackageTransport', smalltalk.PackageTransport, ['namespace'], 'Importer-Exporter');
  1772. smalltalk.AmdPackageTransport.comment="I am the default transport for committing packages.\x0a\x0aSee `AmdExporter` and `AmdPackageHandler`.";
  1773. smalltalk.addMethod(
  1774. smalltalk.method({
  1775. selector: "asJSON",
  1776. category: 'converting',
  1777. fn: function (){
  1778. var self=this;
  1779. return smalltalk.withContext(function($ctx1) {
  1780. var $2,$3,$1;
  1781. $2=smalltalk.AmdPackageTransport.superclass.fn.prototype._asJSON.apply(_st(self), []);
  1782. _st($2)._at_put_("amdNamespace",self._namespace());
  1783. $3=_st($2)._yourself();
  1784. $1=$3;
  1785. return $1;
  1786. }, function($ctx1) {$ctx1.fill(self,"asJSON",{},smalltalk.AmdPackageTransport)})},
  1787. args: [],
  1788. source: "asJSON\x0a\x09^ super asJSON\x0a\x09\x09at: 'amdNamespace' put: self namespace;\x0a\x09\x09yourself",
  1789. messageSends: ["at:put:", "asJSON", "namespace", "yourself"],
  1790. referencedClasses: []
  1791. }),
  1792. smalltalk.AmdPackageTransport);
  1793. smalltalk.addMethod(
  1794. smalltalk.method({
  1795. selector: "commitHandlerClass",
  1796. category: 'accessing',
  1797. fn: function (){
  1798. var self=this;
  1799. function $AmdPackageHandler(){return smalltalk.AmdPackageHandler||(typeof AmdPackageHandler=="undefined"?nil:AmdPackageHandler)}
  1800. return smalltalk.withContext(function($ctx1) {
  1801. var $1;
  1802. $1=$AmdPackageHandler();
  1803. return $1;
  1804. }, function($ctx1) {$ctx1.fill(self,"commitHandlerClass",{},smalltalk.AmdPackageTransport)})},
  1805. args: [],
  1806. source: "commitHandlerClass\x0a\x09^ AmdPackageHandler",
  1807. messageSends: [],
  1808. referencedClasses: ["AmdPackageHandler"]
  1809. }),
  1810. smalltalk.AmdPackageTransport);
  1811. smalltalk.addMethod(
  1812. smalltalk.method({
  1813. selector: "defaultNamespace",
  1814. category: 'defaults',
  1815. fn: function (){
  1816. var self=this;
  1817. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1818. return smalltalk.withContext(function($ctx1) {
  1819. var $1;
  1820. $1=_st(_st($Smalltalk())._current())._defaultAmdNamespace();
  1821. return $1;
  1822. }, function($ctx1) {$ctx1.fill(self,"defaultNamespace",{},smalltalk.AmdPackageTransport)})},
  1823. args: [],
  1824. source: "defaultNamespace\x0a\x09^ Smalltalk current defaultAmdNamespace",
  1825. messageSends: ["defaultAmdNamespace", "current"],
  1826. referencedClasses: ["Smalltalk"]
  1827. }),
  1828. smalltalk.AmdPackageTransport);
  1829. smalltalk.addMethod(
  1830. smalltalk.method({
  1831. selector: "namespace",
  1832. category: 'accessing',
  1833. fn: function (){
  1834. var self=this;
  1835. return smalltalk.withContext(function($ctx1) {
  1836. var $2,$1;
  1837. $2=self["@namespace"];
  1838. if(($receiver = $2) == nil || $receiver == null){
  1839. $1=self._defaultNamespace();
  1840. } else {
  1841. $1=$2;
  1842. };
  1843. return $1;
  1844. }, function($ctx1) {$ctx1.fill(self,"namespace",{},smalltalk.AmdPackageTransport)})},
  1845. args: [],
  1846. source: "namespace\x0a\x09^ namespace ifNil: [ self defaultNamespace ]",
  1847. messageSends: ["ifNil:", "defaultNamespace"],
  1848. referencedClasses: []
  1849. }),
  1850. smalltalk.AmdPackageTransport);
  1851. smalltalk.addMethod(
  1852. smalltalk.method({
  1853. selector: "namespace:",
  1854. category: 'accessing',
  1855. fn: function (aString){
  1856. var self=this;
  1857. return smalltalk.withContext(function($ctx1) {
  1858. self["@namespace"]=aString;
  1859. return self}, function($ctx1) {$ctx1.fill(self,"namespace:",{aString:aString},smalltalk.AmdPackageTransport)})},
  1860. args: ["aString"],
  1861. source: "namespace: aString\x0a\x09namespace := aString",
  1862. messageSends: [],
  1863. referencedClasses: []
  1864. }),
  1865. smalltalk.AmdPackageTransport);
  1866. smalltalk.addMethod(
  1867. smalltalk.method({
  1868. selector: "setupFromJson:",
  1869. category: 'initialization',
  1870. fn: function (anObject){
  1871. var self=this;
  1872. return smalltalk.withContext(function($ctx1) {
  1873. self._namespace_(_st(anObject)._at_("amdNamespace"));
  1874. return self}, function($ctx1) {$ctx1.fill(self,"setupFromJson:",{anObject:anObject},smalltalk.AmdPackageTransport)})},
  1875. args: ["anObject"],
  1876. source: "setupFromJson: anObject\x0a\x09self namespace: (anObject at: 'amdNamespace')",
  1877. messageSends: ["namespace:", "at:"],
  1878. referencedClasses: []
  1879. }),
  1880. smalltalk.AmdPackageTransport);
  1881. smalltalk.addMethod(
  1882. smalltalk.method({
  1883. selector: "namespace:",
  1884. category: 'instance creation',
  1885. fn: function (aString){
  1886. var self=this;
  1887. return smalltalk.withContext(function($ctx1) {
  1888. var $2,$3,$1;
  1889. $2=self._new();
  1890. _st($2)._namespace_(aString);
  1891. $3=_st($2)._yourself();
  1892. $1=$3;
  1893. return $1;
  1894. }, function($ctx1) {$ctx1.fill(self,"namespace:",{aString:aString},smalltalk.AmdPackageTransport.klass)})},
  1895. args: ["aString"],
  1896. source: "namespace: aString\x0a\x09^ self new\x0a\x09\x09namespace: aString;\x0a\x09\x09yourself",
  1897. messageSends: ["namespace:", "new", "yourself"],
  1898. referencedClasses: []
  1899. }),
  1900. smalltalk.AmdPackageTransport.klass);
  1901. smalltalk.addMethod(
  1902. smalltalk.method({
  1903. selector: "type",
  1904. category: 'accessing',
  1905. fn: function (){
  1906. var self=this;
  1907. return smalltalk.withContext(function($ctx1) {
  1908. return "amd";
  1909. }, function($ctx1) {$ctx1.fill(self,"type",{},smalltalk.AmdPackageTransport.klass)})},
  1910. args: [],
  1911. source: "type\x0a\x09^ 'amd'",
  1912. messageSends: [],
  1913. referencedClasses: []
  1914. }),
  1915. smalltalk.AmdPackageTransport.klass);
  1916. smalltalk.addMethod(
  1917. smalltalk.method({
  1918. selector: "commit",
  1919. category: '*Importer-Exporter',
  1920. fn: function (){
  1921. var self=this;
  1922. return smalltalk.withContext(function($ctx1) {
  1923. var $1;
  1924. $1=_st(self._transport())._commit();
  1925. return $1;
  1926. }, function($ctx1) {$ctx1.fill(self,"commit",{},smalltalk.Package)})},
  1927. args: [],
  1928. source: "commit\x0a\x09^ self transport commit",
  1929. messageSends: ["commit", "transport"],
  1930. referencedClasses: []
  1931. }),
  1932. smalltalk.Package);
  1933. });