Importer-Exporter.js 137 KB

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