Importer-Exporter.js 112 KB

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