Kernel-ImportExport.js 95 KB

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