Importer-Exporter.js 101 KB

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