Importer-Exporter.js 112 KB

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