1
0

Importer-Exporter.js 91 KB

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