Importer-Exporter.js 91 KB

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