1
0

Importer-Exporter.js 100 KB

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