1
0

Importer-Exporter.js 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200
  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.addClass('Exporter', smalltalk.AbstractExporter, [], 'Importer-Exporter');
  516. 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.).";
  517. smalltalk.addMethod(
  518. smalltalk.method({
  519. selector: "classNameFor:",
  520. category: 'convenience',
  521. fn: function (aClass){
  522. var self=this;
  523. return smalltalk.withContext(function($ctx1) {
  524. var $2,$3,$1;
  525. $2=_st(aClass)._isMetaclass();
  526. if(smalltalk.assert($2)){
  527. $1=_st(_st(_st(aClass)._instanceClass())._name()).__comma(".klass");
  528. } else {
  529. $3=_st(aClass)._isNil();
  530. if(smalltalk.assert($3)){
  531. $1="nil";
  532. } else {
  533. $1=_st(aClass)._name();
  534. };
  535. };
  536. return $1;
  537. }, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},smalltalk.Exporter)})},
  538. args: ["aClass"],
  539. 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 ] ]",
  540. messageSends: ["ifTrue:ifFalse:", ",", "name", "instanceClass", "isNil", "isMetaclass"],
  541. referencedClasses: []
  542. }),
  543. smalltalk.Exporter);
  544. smalltalk.addMethod(
  545. smalltalk.method({
  546. selector: "exportDefinitionOf:on:",
  547. category: 'output',
  548. fn: function (aClass,aStream){
  549. var self=this;
  550. return smalltalk.withContext(function($ctx1) {
  551. var $1,$2,$3,$4,$5,$6,$7;
  552. $1=aStream;
  553. _st($1)._lf();
  554. _st($1)._nextPutAll_("smalltalk.addClass(");
  555. _st($1)._nextPutAll_(_st("'".__comma(self._classNameFor_(aClass))).__comma("', "));
  556. _st($1)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aClass)._superclass())));
  557. $2=_st($1)._nextPutAll_(", [");
  558. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  559. return smalltalk.withContext(function($ctx2) {
  560. return _st(aStream)._nextPutAll_(_st("'".__comma(each)).__comma("'"));
  561. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  562. return smalltalk.withContext(function($ctx2) {
  563. return _st(aStream)._nextPutAll_(", ");
  564. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  565. $3=aStream;
  566. _st($3)._nextPutAll_("], '");
  567. _st($3)._nextPutAll_(_st(_st(aClass)._category()).__comma("'"));
  568. $4=_st($3)._nextPutAll_(");");
  569. $5=_st(_st(aClass)._comment())._notEmpty();
  570. if(smalltalk.assert($5)){
  571. $6=aStream;
  572. _st($6)._lf();
  573. _st($6)._nextPutAll_("smalltalk.");
  574. _st($6)._nextPutAll_(self._classNameFor_(aClass));
  575. _st($6)._nextPutAll_(".comment=");
  576. _st($6)._nextPutAll_(_st(_st(aClass)._comment())._asJavascript());
  577. $7=_st($6)._nextPutAll_(";");
  578. $7;
  579. };
  580. _st(aStream)._lf();
  581. return self}, function($ctx1) {$ctx1.fill(self,"exportDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.Exporter)})},
  582. args: ["aClass", "aStream"],
  583. 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",
  584. messageSends: ["lf", "nextPutAll:", ",", "classNameFor:", "superclass", "do:separatedBy:", "instanceVariableNames", "category", "ifTrue:", "asJavascript", "comment", "notEmpty"],
  585. referencedClasses: []
  586. }),
  587. smalltalk.Exporter);
  588. smalltalk.addMethod(
  589. smalltalk.method({
  590. selector: "exportMetaDefinitionOf:on:",
  591. category: 'output',
  592. fn: function (aClass,aStream){
  593. var self=this;
  594. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  595. return smalltalk.withContext(function($ctx1) {
  596. var $1,$2,$3;
  597. _st(aStream)._lf();
  598. $1=_st(_st(_st(aClass)._class())._instanceVariableNames())._isEmpty();
  599. if(! smalltalk.assert($1)){
  600. $2=aStream;
  601. _st($2)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aClass)._class())));
  602. $3=_st($2)._nextPutAll_(".iVarNames = [");
  603. $3;
  604. _st(_st(_st(aClass)._class())._instanceVariableNames())._do_separatedBy_((function(each){
  605. return smalltalk.withContext(function($ctx2) {
  606. return _st(aStream)._nextPutAll_(_st("'".__comma(each)).__comma("'"));
  607. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  608. return smalltalk.withContext(function($ctx2) {
  609. return _st(aStream)._nextPutAll_(",");
  610. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  611. _st(aStream)._nextPutAll_("];".__comma(_st($String())._lf()));
  612. };
  613. return self}, function($ctx1) {$ctx1.fill(self,"exportMetaDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.Exporter)})},
  614. args: ["aClass", "aStream"],
  615. 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]",
  616. messageSends: ["lf", "ifFalse:", "nextPutAll:", ",", "classNameFor:", "class", "do:separatedBy:", "instanceVariableNames", "isEmpty"],
  617. referencedClasses: ["String"]
  618. }),
  619. smalltalk.Exporter);
  620. smalltalk.addMethod(
  621. smalltalk.method({
  622. selector: "exportMethod:on:",
  623. category: 'output',
  624. fn: function (aMethod,aStream){
  625. var self=this;
  626. return smalltalk.withContext(function($ctx1) {
  627. var $1,$2,$3,$4;
  628. $1=aStream;
  629. _st($1)._nextPutAll_("smalltalk.addMethod(");
  630. _st($1)._lf();
  631. _st($1)._nextPutAll_("smalltalk.method({");
  632. _st($1)._lf();
  633. _st($1)._nextPutAll_(_st("selector: ".__comma(_st(_st(aMethod)._selector())._asJavascript())).__comma(","));
  634. _st($1)._lf();
  635. _st($1)._nextPutAll_(_st("category: '".__comma(_st(aMethod)._category())).__comma("',"));
  636. _st($1)._lf();
  637. _st($1)._nextPutAll_(_st("fn: ".__comma(_st(_st(aMethod)._fn())._compiledSource())).__comma(","));
  638. _st($1)._lf();
  639. _st($1)._nextPutAll_(_st("args: ".__comma(_st(_st(aMethod)._arguments())._asJavascript())).__comma(","));
  640. _st($1)._lf();
  641. _st($1)._nextPutAll_(_st("source: ".__comma(_st(_st(aMethod)._source())._asJavascript())).__comma(","));
  642. _st($1)._lf();
  643. _st($1)._nextPutAll_(_st("messageSends: ".__comma(_st(_st(aMethod)._messageSends())._asJavascript())).__comma(","));
  644. _st($1)._lf();
  645. $2=_st($1)._nextPutAll_("referencedClasses: ".__comma(_st(_st(aMethod)._referencedClasses())._asJavascript()));
  646. $3=aStream;
  647. _st($3)._lf();
  648. _st($3)._nextPutAll_("}),");
  649. _st($3)._lf();
  650. _st($3)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aMethod)._methodClass())));
  651. _st($3)._nextPutAll_(");");
  652. _st($3)._lf();
  653. $4=_st($3)._lf();
  654. return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:on:",{aMethod:aMethod,aStream:aStream},smalltalk.Exporter)})},
  655. args: ["aMethod", "aStream"],
  656. 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",
  657. messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "selector", "category", "compiledSource", "fn", "arguments", "source", "messageSends", "referencedClasses", "classNameFor:", "methodClass"],
  658. referencedClasses: []
  659. }),
  660. smalltalk.Exporter);
  661. smalltalk.addMethod(
  662. smalltalk.method({
  663. selector: "exportPackage:on:",
  664. category: 'output',
  665. fn: function (aPackage,aStream){
  666. var self=this;
  667. return smalltalk.withContext(function($ctx1) {
  668. var $1,$2;
  669. $1=self;
  670. _st($1)._exportPackagePrologueOf_on_(aPackage,aStream);
  671. _st($1)._exportPackageDefinitionOf_on_(aPackage,aStream);
  672. $2=_st($1)._exportPackageTransportOf_on_(aPackage,aStream);
  673. _st(_st(aPackage)._sortedClasses())._do_((function(each){
  674. return smalltalk.withContext(function($ctx2) {
  675. self._exportDefinitionOf_on_(each,aStream);
  676. _st(_st(each)._ownMethods())._do_((function(method){
  677. return smalltalk.withContext(function($ctx3) {
  678. return self._exportMethod_on_(method,aStream);
  679. }, function($ctx3) {$ctx3.fillBlock({method:method},$ctx2)})}));
  680. self._exportMetaDefinitionOf_on_(each,aStream);
  681. return _st(_st(_st(each)._class())._ownMethods())._do_((function(method){
  682. return smalltalk.withContext(function($ctx3) {
  683. return self._exportMethod_on_(method,aStream);
  684. }, function($ctx3) {$ctx3.fillBlock({method:method},$ctx2)})}));
  685. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  686. _st(self._extensionMethodsOfPackage_(aPackage))._do_((function(each){
  687. return smalltalk.withContext(function($ctx2) {
  688. return self._exportMethod_on_(each,aStream);
  689. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  690. self._exportPackageEpilogueOf_on_(aPackage,aStream);
  691. return self}, function($ctx1) {$ctx1.fill(self,"exportPackage:on:",{aPackage:aPackage,aStream:aStream},smalltalk.Exporter)})},
  692. args: ["aPackage", "aStream"],
  693. 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",
  694. messageSends: ["exportPackagePrologueOf:on:", "exportPackageDefinitionOf:on:", "exportPackageTransportOf:on:", "do:", "exportDefinitionOf:on:", "exportMethod:on:", "ownMethods", "exportMetaDefinitionOf:on:", "class", "sortedClasses", "extensionMethodsOfPackage:", "exportPackageEpilogueOf:on:"],
  695. referencedClasses: []
  696. }),
  697. smalltalk.Exporter);
  698. smalltalk.addMethod(
  699. smalltalk.method({
  700. selector: "exportPackageDefinitionOf:on:",
  701. category: 'output',
  702. fn: function (aPackage,aStream){
  703. var self=this;
  704. return smalltalk.withContext(function($ctx1) {
  705. var $1,$2;
  706. $1=aStream;
  707. _st($1)._nextPutAll_("smalltalk.addPackage(");
  708. _st($1)._nextPutAll_(_st("'".__comma(_st(aPackage)._name())).__comma("');"));
  709. $2=_st($1)._lf();
  710. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageDefinitionOf:on:",{aPackage:aPackage,aStream:aStream},smalltalk.Exporter)})},
  711. args: ["aPackage", "aStream"],
  712. source: "exportPackageDefinitionOf: aPackage on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: 'smalltalk.addPackage(';\x0a\x09\x09nextPutAll: '''', aPackage name, ''');';\x0a\x09\x09lf",
  713. messageSends: ["nextPutAll:", ",", "name", "lf"],
  714. referencedClasses: []
  715. }),
  716. smalltalk.Exporter);
  717. smalltalk.addMethod(
  718. smalltalk.method({
  719. selector: "exportPackageEpilogueOf:on:",
  720. category: 'output',
  721. fn: function (aPackage,aStream){
  722. var self=this;
  723. return smalltalk.withContext(function($ctx1) {
  724. var $1,$2;
  725. $1=aStream;
  726. _st($1)._nextPutAll_("})(global_smalltalk,global_nil,global__st);");
  727. $2=_st($1)._lf();
  728. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageEpilogueOf:on:",{aPackage:aPackage,aStream:aStream},smalltalk.Exporter)})},
  729. args: ["aPackage", "aStream"],
  730. source: "exportPackageEpilogueOf: aPackage on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: '})(global_smalltalk,global_nil,global__st);';\x0a\x09\x09lf",
  731. messageSends: ["nextPutAll:", "lf"],
  732. referencedClasses: []
  733. }),
  734. smalltalk.Exporter);
  735. smalltalk.addMethod(
  736. smalltalk.method({
  737. selector: "exportPackagePrologueOf:on:",
  738. category: 'output',
  739. fn: function (aPackage,aStream){
  740. var self=this;
  741. return smalltalk.withContext(function($ctx1) {
  742. var $1,$2;
  743. $1=aStream;
  744. _st($1)._nextPutAll_("(function(smalltalk,nil,_st){");
  745. $2=_st($1)._lf();
  746. return self}, function($ctx1) {$ctx1.fill(self,"exportPackagePrologueOf:on:",{aPackage:aPackage,aStream:aStream},smalltalk.Exporter)})},
  747. args: ["aPackage", "aStream"],
  748. source: "exportPackagePrologueOf: aPackage on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: '(function(smalltalk,nil,_st){';\x0a\x09\x09lf",
  749. messageSends: ["nextPutAll:", "lf"],
  750. referencedClasses: []
  751. }),
  752. smalltalk.Exporter);
  753. smalltalk.addMethod(
  754. smalltalk.method({
  755. selector: "exportPackageTransportOf:on:",
  756. category: 'output',
  757. fn: function (aPackage,aStream){
  758. var self=this;
  759. var json;
  760. return smalltalk.withContext(function($ctx1) {
  761. var $1,$2,$3;
  762. json=_st(aPackage)._transportJson();
  763. $1=_st(json).__eq("null");
  764. if(! smalltalk.assert($1)){
  765. $2=aStream;
  766. _st($2)._nextPutAll_("smalltalk.packages[");
  767. _st($2)._nextPutAll_(_st(_st(aPackage)._name())._asJavascript());
  768. _st($2)._nextPutAll_("].transport = ");
  769. _st($2)._nextPutAll_(json);
  770. _st($2)._nextPutAll_(";");
  771. $3=_st($2)._lf();
  772. $3;
  773. };
  774. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageTransportOf:on:",{aPackage:aPackage,aStream:aStream,json:json},smalltalk.Exporter)})},
  775. args: ["aPackage", "aStream"],
  776. 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 ]",
  777. messageSends: ["transportJson", "ifFalse:", "nextPutAll:", "asJavascript", "name", "lf", "="],
  778. referencedClasses: []
  779. }),
  780. smalltalk.Exporter);
  781. smalltalk.addMethod(
  782. smalltalk.method({
  783. selector: "ownMethodsOfClass:",
  784. category: 'accessing',
  785. fn: function (aClass){
  786. var self=this;
  787. return smalltalk.withContext(function($ctx1) {
  788. var $1;
  789. $1=_st(_st(_st(_st(aClass)._methodDictionary())._values())._sorted_((function(a,b){
  790. return smalltalk.withContext(function($ctx2) {
  791. return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  792. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})})))._reject_((function(each){
  793. return smalltalk.withContext(function($ctx2) {
  794. return _st(_st(each)._category())._match_("^\x5c*");
  795. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  796. return $1;
  797. }, function($ctx1) {$ctx1.fill(self,"ownMethodsOfClass:",{aClass:aClass},smalltalk.Exporter)})},
  798. args: ["aClass"],
  799. 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*')]",
  800. messageSends: ["reject:", "match:", "category", "sorted:", "<=", "selector", "values", "methodDictionary"],
  801. referencedClasses: []
  802. }),
  803. smalltalk.Exporter);
  804. smalltalk.addMethod(
  805. smalltalk.method({
  806. selector: "ownMethodsOfMetaClass:",
  807. category: 'accessing',
  808. fn: function (aClass){
  809. var self=this;
  810. return smalltalk.withContext(function($ctx1) {
  811. var $1;
  812. $1=self._ownMethodsOfClass_(_st(aClass)._class());
  813. return $1;
  814. }, function($ctx1) {$ctx1.fill(self,"ownMethodsOfMetaClass:",{aClass:aClass},smalltalk.Exporter)})},
  815. args: ["aClass"],
  816. source: "ownMethodsOfMetaClass: aClass\x0a\x09\x22Issue #143: sort methods alphabetically\x22\x0a\x0a\x09^self ownMethodsOfClass: aClass class",
  817. messageSends: ["ownMethodsOfClass:", "class"],
  818. referencedClasses: []
  819. }),
  820. smalltalk.Exporter);
  821. smalltalk.addClass('AmdExporter', smalltalk.Exporter, ['namespace'], 'Importer-Exporter');
  822. smalltalk.AmdExporter.comment="I am used to export Packages in an AMD (Asynchronous Module Definition) JavaScript format.";
  823. smalltalk.addMethod(
  824. smalltalk.method({
  825. selector: "amdNamesOfPackages:",
  826. category: 'private',
  827. fn: function (anArray){
  828. var self=this;
  829. return smalltalk.withContext(function($ctx1) {
  830. var $1;
  831. $1=_st(_st(anArray)._select_((function(each){
  832. return smalltalk.withContext(function($ctx2) {
  833. return _st(self._amdNamespaceOfPackage_(each))._notNil();
  834. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})})))._collect_((function(each){
  835. return smalltalk.withContext(function($ctx2) {
  836. return _st(_st(self._amdNamespaceOfPackage_(each)).__comma("/")).__comma(_st(each)._name());
  837. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  838. return $1;
  839. }, function($ctx1) {$ctx1.fill(self,"amdNamesOfPackages:",{anArray:anArray},smalltalk.AmdExporter)})},
  840. args: ["anArray"],
  841. source: "amdNamesOfPackages: anArray\x0a\x09^ (anArray\x0a\x09\x09select: [ :each | (self amdNamespaceOfPackage: each) notNil ])\x0a\x09\x09collect: [ :each | (self amdNamespaceOfPackage: each), '/', each name ]",
  842. messageSends: ["collect:", ",", "name", "amdNamespaceOfPackage:", "select:", "notNil"],
  843. referencedClasses: []
  844. }),
  845. smalltalk.AmdExporter);
  846. smalltalk.addMethod(
  847. smalltalk.method({
  848. selector: "amdNamespaceOfPackage:",
  849. category: 'private',
  850. fn: function (aPackage){
  851. var self=this;
  852. return smalltalk.withContext(function($ctx1) {
  853. var $2,$1;
  854. $2=_st(_st(_st(aPackage)._transport())._type()).__eq("amd");
  855. if(smalltalk.assert($2)){
  856. $1=_st(_st(aPackage)._transport())._namespace();
  857. } else {
  858. $1=nil;
  859. };
  860. return $1;
  861. }, function($ctx1) {$ctx1.fill(self,"amdNamespaceOfPackage:",{aPackage:aPackage},smalltalk.AmdExporter)})},
  862. args: ["aPackage"],
  863. source: "amdNamespaceOfPackage: aPackage\x0a\x09^ (aPackage transport type = 'amd')\x0a\x09\x09ifTrue: [ aPackage transport namespace ]\x0a\x09\x09ifFalse: [ nil ]",
  864. messageSends: ["ifTrue:ifFalse:", "namespace", "transport", "=", "type"],
  865. referencedClasses: []
  866. }),
  867. smalltalk.AmdExporter);
  868. smalltalk.addMethod(
  869. smalltalk.method({
  870. selector: "exportPackageEpilogueOf:on:",
  871. category: 'output',
  872. fn: function (aPackage,aStream){
  873. var self=this;
  874. return smalltalk.withContext(function($ctx1) {
  875. var $1,$2;
  876. $1=aStream;
  877. _st($1)._nextPutAll_("});");
  878. $2=_st($1)._lf();
  879. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageEpilogueOf:on:",{aPackage:aPackage,aStream:aStream},smalltalk.AmdExporter)})},
  880. args: ["aPackage", "aStream"],
  881. source: "exportPackageEpilogueOf: aPackage on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: '});';\x0a\x09\x09lf",
  882. messageSends: ["nextPutAll:", "lf"],
  883. referencedClasses: []
  884. }),
  885. smalltalk.AmdExporter);
  886. smalltalk.addMethod(
  887. smalltalk.method({
  888. selector: "exportPackagePrologueOf:on:",
  889. category: 'output',
  890. fn: function (aPackage,aStream){
  891. var self=this;
  892. return smalltalk.withContext(function($ctx1) {
  893. var $1,$2;
  894. $1=aStream;
  895. _st($1)._nextPutAll_("define(\x22");
  896. _st($1)._nextPutAll_(self._amdNamespaceOfPackage_(aPackage));
  897. _st($1)._nextPutAll_("/");
  898. _st($1)._nextPutAll_(_st(aPackage)._name());
  899. _st($1)._nextPutAll_("\x22, ");
  900. _st($1)._nextPutAll_(_st(["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st"].__comma(self._amdNamesOfPackages_(_st(aPackage)._loadDependencies())))._asJavascript());
  901. _st($1)._nextPutAll_(", function(smalltalk,nil,_st){");
  902. $2=_st($1)._lf();
  903. return self}, function($ctx1) {$ctx1.fill(self,"exportPackagePrologueOf:on:",{aPackage:aPackage,aStream:aStream},smalltalk.AmdExporter)})},
  904. args: ["aPackage", "aStream"],
  905. 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",
  906. messageSends: ["nextPutAll:", "amdNamespaceOfPackage:", "name", "asJavascript", ",", "amdNamesOfPackages:", "loadDependencies", "lf"],
  907. referencedClasses: []
  908. }),
  909. smalltalk.AmdExporter);
  910. smalltalk.addClass('ChunkParser', smalltalk.Object, ['stream'], 'Importer-Exporter');
  911. 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";
  912. smalltalk.addMethod(
  913. smalltalk.method({
  914. selector: "nextChunk",
  915. category: 'reading',
  916. fn: function (){
  917. var self=this;
  918. var char,result,chunk;
  919. return smalltalk.withContext(function($ctx1) {
  920. var $1,$2,$3;
  921. var $early={};
  922. try {
  923. result=""._writeStream();
  924. _st((function(){
  925. return smalltalk.withContext(function($ctx2) {
  926. char=_st(self["@stream"])._next();
  927. char;
  928. return _st(char)._notNil();
  929. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileTrue_((function(){
  930. return smalltalk.withContext(function($ctx2) {
  931. $1=_st(char).__eq("!");
  932. if(smalltalk.assert($1)){
  933. $2=_st(_st(self["@stream"])._peek()).__eq("!");
  934. if(smalltalk.assert($2)){
  935. _st(self["@stream"])._next();
  936. } else {
  937. $3=_st(_st(result)._contents())._trimBoth();
  938. throw $early=[$3];
  939. };
  940. };
  941. return _st(result)._nextPut_(char);
  942. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  943. return nil;
  944. }
  945. catch(e) {if(e===$early)return e[0]; throw e}
  946. }, function($ctx1) {$ctx1.fill(self,"nextChunk",{char:char,result:result,chunk:chunk},smalltalk.ChunkParser)})},
  947. args: [],
  948. 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",
  949. messageSends: ["writeStream", "whileTrue:", "ifTrue:", "ifTrue:ifFalse:", "next", "trimBoth", "contents", "=", "peek", "nextPut:", "notNil"],
  950. referencedClasses: []
  951. }),
  952. smalltalk.ChunkParser);
  953. smalltalk.addMethod(
  954. smalltalk.method({
  955. selector: "stream:",
  956. category: 'accessing',
  957. fn: function (aStream){
  958. var self=this;
  959. return smalltalk.withContext(function($ctx1) {
  960. self["@stream"]=aStream;
  961. return self}, function($ctx1) {$ctx1.fill(self,"stream:",{aStream:aStream},smalltalk.ChunkParser)})},
  962. args: ["aStream"],
  963. source: "stream: aStream\x0a\x09stream := aStream",
  964. messageSends: [],
  965. referencedClasses: []
  966. }),
  967. smalltalk.ChunkParser);
  968. smalltalk.addMethod(
  969. smalltalk.method({
  970. selector: "on:",
  971. category: 'instance creation',
  972. fn: function (aStream){
  973. var self=this;
  974. return smalltalk.withContext(function($ctx1) {
  975. var $1;
  976. $1=_st(self._new())._stream_(aStream);
  977. return $1;
  978. }, function($ctx1) {$ctx1.fill(self,"on:",{aStream:aStream},smalltalk.ChunkParser.klass)})},
  979. args: ["aStream"],
  980. source: "on: aStream\x0a\x09^self new stream: aStream",
  981. messageSends: ["stream:", "new"],
  982. referencedClasses: []
  983. }),
  984. smalltalk.ChunkParser.klass);
  985. smalltalk.addClass('ExportMethodProtocol', smalltalk.Object, ['name', 'theClass'], 'Importer-Exporter');
  986. 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.";
  987. smalltalk.addMethod(
  988. smalltalk.method({
  989. selector: "methods",
  990. category: 'accessing',
  991. fn: function (){
  992. var self=this;
  993. return smalltalk.withContext(function($ctx1) {
  994. var $1;
  995. $1=_st(self._theClass())._methodsInProtocol_(self._name());
  996. return $1;
  997. }, function($ctx1) {$ctx1.fill(self,"methods",{},smalltalk.ExportMethodProtocol)})},
  998. args: [],
  999. source: "methods\x0a\x09^ self theClass methodsInProtocol: self name",
  1000. messageSends: ["methodsInProtocol:", "name", "theClass"],
  1001. referencedClasses: []
  1002. }),
  1003. smalltalk.ExportMethodProtocol);
  1004. smalltalk.addMethod(
  1005. smalltalk.method({
  1006. selector: "name",
  1007. category: 'accessing',
  1008. fn: function (){
  1009. var self=this;
  1010. return smalltalk.withContext(function($ctx1) {
  1011. var $1;
  1012. $1=self["@name"];
  1013. return $1;
  1014. }, function($ctx1) {$ctx1.fill(self,"name",{},smalltalk.ExportMethodProtocol)})},
  1015. args: [],
  1016. source: "name\x0a\x09^name",
  1017. messageSends: [],
  1018. referencedClasses: []
  1019. }),
  1020. smalltalk.ExportMethodProtocol);
  1021. smalltalk.addMethod(
  1022. smalltalk.method({
  1023. selector: "name:",
  1024. category: 'accessing',
  1025. fn: function (aString){
  1026. var self=this;
  1027. return smalltalk.withContext(function($ctx1) {
  1028. self["@name"]=aString;
  1029. return self}, function($ctx1) {$ctx1.fill(self,"name:",{aString:aString},smalltalk.ExportMethodProtocol)})},
  1030. args: ["aString"],
  1031. source: "name: aString\x0a\x09name := aString",
  1032. messageSends: [],
  1033. referencedClasses: []
  1034. }),
  1035. smalltalk.ExportMethodProtocol);
  1036. smalltalk.addMethod(
  1037. smalltalk.method({
  1038. selector: "sortedMethods",
  1039. category: 'accessing',
  1040. fn: function (){
  1041. var self=this;
  1042. return smalltalk.withContext(function($ctx1) {
  1043. var $1;
  1044. $1=_st(self._methods())._sorted_((function(a,b){
  1045. return smalltalk.withContext(function($ctx2) {
  1046. return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  1047. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})}));
  1048. return $1;
  1049. }, function($ctx1) {$ctx1.fill(self,"sortedMethods",{},smalltalk.ExportMethodProtocol)})},
  1050. args: [],
  1051. source: "sortedMethods\x0a\x09^ self methods sorted: [ :a :b | a selector <= b selector ]",
  1052. messageSends: ["sorted:", "<=", "selector", "methods"],
  1053. referencedClasses: []
  1054. }),
  1055. smalltalk.ExportMethodProtocol);
  1056. smalltalk.addMethod(
  1057. smalltalk.method({
  1058. selector: "theClass",
  1059. category: 'accessing',
  1060. fn: function (){
  1061. var self=this;
  1062. return smalltalk.withContext(function($ctx1) {
  1063. var $1;
  1064. $1=self["@theClass"];
  1065. return $1;
  1066. }, function($ctx1) {$ctx1.fill(self,"theClass",{},smalltalk.ExportMethodProtocol)})},
  1067. args: [],
  1068. source: "theClass\x0a\x09^theClass",
  1069. messageSends: [],
  1070. referencedClasses: []
  1071. }),
  1072. smalltalk.ExportMethodProtocol);
  1073. smalltalk.addMethod(
  1074. smalltalk.method({
  1075. selector: "theClass:",
  1076. category: 'accessing',
  1077. fn: function (aClass){
  1078. var self=this;
  1079. return smalltalk.withContext(function($ctx1) {
  1080. self["@theClass"]=aClass;
  1081. return self}, function($ctx1) {$ctx1.fill(self,"theClass:",{aClass:aClass},smalltalk.ExportMethodProtocol)})},
  1082. args: ["aClass"],
  1083. source: "theClass: aClass\x0a\x09theClass := aClass",
  1084. messageSends: [],
  1085. referencedClasses: []
  1086. }),
  1087. smalltalk.ExportMethodProtocol);
  1088. smalltalk.addMethod(
  1089. smalltalk.method({
  1090. selector: "name:theClass:",
  1091. category: 'instance creation',
  1092. fn: function (aString,aClass){
  1093. var self=this;
  1094. return smalltalk.withContext(function($ctx1) {
  1095. var $2,$3,$1;
  1096. $2=self._new();
  1097. _st($2)._name_(aString);
  1098. _st($2)._theClass_(aClass);
  1099. $3=_st($2)._yourself();
  1100. $1=$3;
  1101. return $1;
  1102. }, function($ctx1) {$ctx1.fill(self,"name:theClass:",{aString:aString,aClass:aClass},smalltalk.ExportMethodProtocol.klass)})},
  1103. args: ["aString", "aClass"],
  1104. source: "name: aString theClass: aClass\x0a\x09^self new\x0a\x09\x09name: aString;\x0a\x09\x09theClass: aClass;\x0a\x09\x09yourself",
  1105. messageSends: ["name:", "new", "theClass:", "yourself"],
  1106. referencedClasses: []
  1107. }),
  1108. smalltalk.ExportMethodProtocol.klass);
  1109. smalltalk.addClass('Importer', smalltalk.Object, [], 'Importer-Exporter');
  1110. smalltalk.Importer.comment="I can import Amber code from a string in the chunk format.\x0a\x0a## API\x0a\x0a Importer new import: aString";
  1111. smalltalk.addMethod(
  1112. smalltalk.method({
  1113. selector: "import:",
  1114. category: 'fileIn',
  1115. fn: function (aStream){
  1116. var self=this;
  1117. var chunk,result,parser,lastEmpty;
  1118. function $ChunkParser(){return smalltalk.ChunkParser||(typeof ChunkParser=="undefined"?nil:ChunkParser)}
  1119. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  1120. return smalltalk.withContext(function($ctx1) {
  1121. var $1,$2;
  1122. parser=_st($ChunkParser())._on_(aStream);
  1123. lastEmpty=false;
  1124. _st((function(){
  1125. return smalltalk.withContext(function($ctx2) {
  1126. chunk=_st(parser)._nextChunk();
  1127. chunk;
  1128. return _st(chunk)._isNil();
  1129. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
  1130. return smalltalk.withContext(function($ctx2) {
  1131. $1=_st(chunk)._isEmpty();
  1132. if(smalltalk.assert($1)){
  1133. lastEmpty=true;
  1134. return lastEmpty;
  1135. } else {
  1136. result=_st(_st($Compiler())._new())._evaluateExpression_(chunk);
  1137. result;
  1138. $2=lastEmpty;
  1139. if(smalltalk.assert($2)){
  1140. lastEmpty=false;
  1141. lastEmpty;
  1142. return _st(result)._scanFrom_(parser);
  1143. };
  1144. };
  1145. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1146. return self}, function($ctx1) {$ctx1.fill(self,"import:",{aStream:aStream,chunk:chunk,result:result,parser:parser,lastEmpty:lastEmpty},smalltalk.Importer)})},
  1147. args: ["aStream"],
  1148. 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]]]",
  1149. messageSends: ["on:", "whileFalse:", "ifTrue:ifFalse:", "evaluateExpression:", "new", "ifTrue:", "scanFrom:", "isEmpty", "nextChunk", "isNil"],
  1150. referencedClasses: ["ChunkParser", "Compiler"]
  1151. }),
  1152. smalltalk.Importer);
  1153. smalltalk.addClass('MethodCategory', smalltalk.Object, ['methods', 'name', 'theClass'], 'Importer-Exporter');
  1154. 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.";
  1155. smalltalk.addMethod(
  1156. smalltalk.method({
  1157. selector: "methods",
  1158. category: 'accessing',
  1159. fn: function (){
  1160. var self=this;
  1161. return smalltalk.withContext(function($ctx1) {
  1162. var $1;
  1163. $1=self["@methods"];
  1164. return $1;
  1165. }, function($ctx1) {$ctx1.fill(self,"methods",{},smalltalk.MethodCategory)})},
  1166. args: [],
  1167. source: "methods\x0a\x09^methods",
  1168. messageSends: [],
  1169. referencedClasses: []
  1170. }),
  1171. smalltalk.MethodCategory);
  1172. smalltalk.addMethod(
  1173. smalltalk.method({
  1174. selector: "methods:",
  1175. category: 'accessing',
  1176. fn: function (aCollection){
  1177. var self=this;
  1178. return smalltalk.withContext(function($ctx1) {
  1179. self["@methods"]=aCollection;
  1180. return self}, function($ctx1) {$ctx1.fill(self,"methods:",{aCollection:aCollection},smalltalk.MethodCategory)})},
  1181. args: ["aCollection"],
  1182. source: "methods: aCollection\x0a\x09methods := aCollection",
  1183. messageSends: [],
  1184. referencedClasses: []
  1185. }),
  1186. smalltalk.MethodCategory);
  1187. smalltalk.addMethod(
  1188. smalltalk.method({
  1189. selector: "name",
  1190. category: 'accessing',
  1191. fn: function (){
  1192. var self=this;
  1193. return smalltalk.withContext(function($ctx1) {
  1194. var $1;
  1195. $1=self["@name"];
  1196. return $1;
  1197. }, function($ctx1) {$ctx1.fill(self,"name",{},smalltalk.MethodCategory)})},
  1198. args: [],
  1199. source: "name\x0a\x09^name",
  1200. messageSends: [],
  1201. referencedClasses: []
  1202. }),
  1203. smalltalk.MethodCategory);
  1204. smalltalk.addMethod(
  1205. smalltalk.method({
  1206. selector: "name:",
  1207. category: 'accessing',
  1208. fn: function (aString){
  1209. var self=this;
  1210. return smalltalk.withContext(function($ctx1) {
  1211. self["@name"]=aString;
  1212. return self}, function($ctx1) {$ctx1.fill(self,"name:",{aString:aString},smalltalk.MethodCategory)})},
  1213. args: ["aString"],
  1214. source: "name: aString\x0a\x09name := aString",
  1215. messageSends: [],
  1216. referencedClasses: []
  1217. }),
  1218. smalltalk.MethodCategory);
  1219. smalltalk.addMethod(
  1220. smalltalk.method({
  1221. selector: "theClass",
  1222. category: 'accessing',
  1223. fn: function (){
  1224. var self=this;
  1225. return smalltalk.withContext(function($ctx1) {
  1226. var $1;
  1227. $1=self["@theClass"];
  1228. return $1;
  1229. }, function($ctx1) {$ctx1.fill(self,"theClass",{},smalltalk.MethodCategory)})},
  1230. args: [],
  1231. source: "theClass\x0a\x09^theClass",
  1232. messageSends: [],
  1233. referencedClasses: []
  1234. }),
  1235. smalltalk.MethodCategory);
  1236. smalltalk.addMethod(
  1237. smalltalk.method({
  1238. selector: "theClass:",
  1239. category: 'accessing',
  1240. fn: function (aClass){
  1241. var self=this;
  1242. return smalltalk.withContext(function($ctx1) {
  1243. self["@theClass"]=aClass;
  1244. return self}, function($ctx1) {$ctx1.fill(self,"theClass:",{aClass:aClass},smalltalk.MethodCategory)})},
  1245. args: ["aClass"],
  1246. source: "theClass: aClass\x0a\x09theClass := aClass",
  1247. messageSends: [],
  1248. referencedClasses: []
  1249. }),
  1250. smalltalk.MethodCategory);
  1251. smalltalk.addMethod(
  1252. smalltalk.method({
  1253. selector: "name:theClass:methods:",
  1254. category: 'not yet classified',
  1255. fn: function (aString,aClass,anArray){
  1256. var self=this;
  1257. return smalltalk.withContext(function($ctx1) {
  1258. var $2,$3,$1;
  1259. $2=self._new();
  1260. _st($2)._name_(aString);
  1261. _st($2)._theClass_(aClass);
  1262. _st($2)._methods_(anArray);
  1263. $3=_st($2)._yourself();
  1264. $1=$3;
  1265. return $1;
  1266. }, function($ctx1) {$ctx1.fill(self,"name:theClass:methods:",{aString:aString,aClass:aClass,anArray:anArray},smalltalk.MethodCategory.klass)})},
  1267. args: ["aString", "aClass", "anArray"],
  1268. 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",
  1269. messageSends: ["name:", "new", "theClass:", "methods:", "yourself"],
  1270. referencedClasses: []
  1271. }),
  1272. smalltalk.MethodCategory.klass);
  1273. smalltalk.addClass('PackageHandler', smalltalk.InterfacingObject, [], 'Importer-Exporter');
  1274. 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.";
  1275. smalltalk.addMethod(
  1276. smalltalk.method({
  1277. selector: "ajaxPutAt:data:",
  1278. category: 'private',
  1279. fn: function (aURL,aString){
  1280. var self=this;
  1281. return smalltalk.withContext(function($ctx1) {
  1282. 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){
  1283. return smalltalk.withContext(function($ctx2) {
  1284. return self._error_(_st(_st(_st("Commiting ".__comma(aURL)).__comma(" failed with reason: \x22")).__comma(_st(xhr)._responseText())).__comma("\x22"));
  1285. }, function($ctx2) {$ctx2.fillBlock({xhr:xhr},$ctx1)})}))]));
  1286. return self}, function($ctx1) {$ctx1.fill(self,"ajaxPutAt:data:",{aURL:aURL,aString:aString},smalltalk.PackageHandler)})},
  1287. args: ["aURL", "aString"],
  1288. 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'] }",
  1289. messageSends: ["ajax:", "->", "error:", ",", "responseText"],
  1290. referencedClasses: []
  1291. }),
  1292. smalltalk.PackageHandler);
  1293. smalltalk.addMethod(
  1294. smalltalk.method({
  1295. selector: "chunkContentsFor:",
  1296. category: 'accessing',
  1297. fn: function (aPackage){
  1298. var self=this;
  1299. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  1300. return smalltalk.withContext(function($ctx1) {
  1301. var $1;
  1302. $1=_st($String())._streamContents_((function(str){
  1303. return smalltalk.withContext(function($ctx2) {
  1304. return _st(self._chunkExporter())._exportPackage_on_(aPackage,str);
  1305. }, function($ctx2) {$ctx2.fillBlock({str:str},$ctx1)})}));
  1306. return $1;
  1307. }, function($ctx1) {$ctx1.fill(self,"chunkContentsFor:",{aPackage:aPackage},smalltalk.PackageHandler)})},
  1308. args: ["aPackage"],
  1309. source: "chunkContentsFor: aPackage\x0a\x09^ String streamContents: [ :str |\x0a\x09\x09self chunkExporter exportPackage: aPackage on: str ]",
  1310. messageSends: ["streamContents:", "exportPackage:on:", "chunkExporter"],
  1311. referencedClasses: ["String"]
  1312. }),
  1313. smalltalk.PackageHandler);
  1314. smalltalk.addMethod(
  1315. smalltalk.method({
  1316. selector: "chunkExporter",
  1317. category: 'factory',
  1318. fn: function (){
  1319. var self=this;
  1320. return smalltalk.withContext(function($ctx1) {
  1321. var $1;
  1322. $1=_st(self._chunkExporterClass())._new();
  1323. return $1;
  1324. }, function($ctx1) {$ctx1.fill(self,"chunkExporter",{},smalltalk.PackageHandler)})},
  1325. args: [],
  1326. source: "chunkExporter\x0a\x09^ self chunkExporterClass new",
  1327. messageSends: ["new", "chunkExporterClass"],
  1328. referencedClasses: []
  1329. }),
  1330. smalltalk.PackageHandler);
  1331. smalltalk.addMethod(
  1332. smalltalk.method({
  1333. selector: "chunkExporterClass",
  1334. category: 'accessing',
  1335. fn: function (){
  1336. var self=this;
  1337. function $ChunkExporter(){return smalltalk.ChunkExporter||(typeof ChunkExporter=="undefined"?nil:ChunkExporter)}
  1338. return smalltalk.withContext(function($ctx1) {
  1339. var $1;
  1340. $1=$ChunkExporter();
  1341. return $1;
  1342. }, function($ctx1) {$ctx1.fill(self,"chunkExporterClass",{},smalltalk.PackageHandler)})},
  1343. args: [],
  1344. source: "chunkExporterClass\x0a\x09^ ChunkExporter",
  1345. messageSends: [],
  1346. referencedClasses: ["ChunkExporter"]
  1347. }),
  1348. smalltalk.PackageHandler);
  1349. smalltalk.addMethod(
  1350. smalltalk.method({
  1351. selector: "commit:",
  1352. category: 'committing',
  1353. fn: function (aPackage){
  1354. var self=this;
  1355. return smalltalk.withContext(function($ctx1) {
  1356. _st([(function(){
  1357. return smalltalk.withContext(function($ctx2) {
  1358. return self._commitStFileFor_(aPackage);
  1359. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(function(){
  1360. return smalltalk.withContext(function($ctx2) {
  1361. return self._commitJsFileFor_(aPackage);
  1362. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})])._do_displayingProgress_((function(each){
  1363. return smalltalk.withContext(function($ctx2) {
  1364. return _st(each)._value();
  1365. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),"Committing package ".__comma(_st(aPackage)._name()));
  1366. return self}, function($ctx1) {$ctx1.fill(self,"commit:",{aPackage:aPackage},smalltalk.PackageHandler)})},
  1367. args: ["aPackage"],
  1368. 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",
  1369. messageSends: ["do:displayingProgress:", "value", ",", "name", "commitStFileFor:", "commitJsFileFor:"],
  1370. referencedClasses: []
  1371. }),
  1372. smalltalk.PackageHandler);
  1373. smalltalk.addMethod(
  1374. smalltalk.method({
  1375. selector: "commitJsFileFor:",
  1376. category: 'committing',
  1377. fn: function (aPackage){
  1378. var self=this;
  1379. return smalltalk.withContext(function($ctx1) {
  1380. self._ajaxPutAt_data_(_st(_st(_st(self._commitPathJsFor_(aPackage)).__comma("/")).__comma(_st(aPackage)._name())).__comma(".js"),self._contentsFor_(aPackage));
  1381. return self}, function($ctx1) {$ctx1.fill(self,"commitJsFileFor:",{aPackage:aPackage},smalltalk.PackageHandler)})},
  1382. args: ["aPackage"],
  1383. source: "commitJsFileFor: aPackage\x0a\x09self \x0a\x09\x09ajaxPutAt: (self commitPathJsFor: aPackage), '/', aPackage name, '.js'\x0a\x09\x09data: (self contentsFor: aPackage)",
  1384. messageSends: ["ajaxPutAt:data:", ",", "name", "commitPathJsFor:", "contentsFor:"],
  1385. referencedClasses: []
  1386. }),
  1387. smalltalk.PackageHandler);
  1388. smalltalk.addMethod(
  1389. smalltalk.method({
  1390. selector: "commitPathJsFor:",
  1391. category: 'accessing',
  1392. fn: function (aPackage){
  1393. var self=this;
  1394. return smalltalk.withContext(function($ctx1) {
  1395. self._subclassResponsibility();
  1396. return self}, function($ctx1) {$ctx1.fill(self,"commitPathJsFor:",{aPackage:aPackage},smalltalk.PackageHandler)})},
  1397. args: ["aPackage"],
  1398. source: "commitPathJsFor: aPackage\x0a\x09self subclassResponsibility",
  1399. messageSends: ["subclassResponsibility"],
  1400. referencedClasses: []
  1401. }),
  1402. smalltalk.PackageHandler);
  1403. smalltalk.addMethod(
  1404. smalltalk.method({
  1405. selector: "commitPathStFor:",
  1406. category: 'accessing',
  1407. fn: function (aPackage){
  1408. var self=this;
  1409. return smalltalk.withContext(function($ctx1) {
  1410. self._subclassResponsibility();
  1411. return self}, function($ctx1) {$ctx1.fill(self,"commitPathStFor:",{aPackage:aPackage},smalltalk.PackageHandler)})},
  1412. args: ["aPackage"],
  1413. source: "commitPathStFor: aPackage\x0a\x09self subclassResponsibility",
  1414. messageSends: ["subclassResponsibility"],
  1415. referencedClasses: []
  1416. }),
  1417. smalltalk.PackageHandler);
  1418. smalltalk.addMethod(
  1419. smalltalk.method({
  1420. selector: "commitStFileFor:",
  1421. category: 'committing',
  1422. fn: function (aPackage){
  1423. var self=this;
  1424. return smalltalk.withContext(function($ctx1) {
  1425. self._ajaxPutAt_data_(_st(_st(_st(self._commitPathStFor_(aPackage)).__comma("/")).__comma(_st(aPackage)._name())).__comma(".st"),self._chunkContentsFor_(aPackage));
  1426. return self}, function($ctx1) {$ctx1.fill(self,"commitStFileFor:",{aPackage:aPackage},smalltalk.PackageHandler)})},
  1427. args: ["aPackage"],
  1428. source: "commitStFileFor: aPackage\x0a\x09self \x0a\x09\x09ajaxPutAt: (self commitPathStFor: aPackage), '/', aPackage name, '.st'\x0a\x09\x09data: (self chunkContentsFor: aPackage)",
  1429. messageSends: ["ajaxPutAt:data:", ",", "name", "commitPathStFor:", "chunkContentsFor:"],
  1430. referencedClasses: []
  1431. }),
  1432. smalltalk.PackageHandler);
  1433. smalltalk.addMethod(
  1434. smalltalk.method({
  1435. selector: "contentsFor:",
  1436. category: 'accessing',
  1437. fn: function (aPackage){
  1438. var self=this;
  1439. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  1440. return smalltalk.withContext(function($ctx1) {
  1441. var $1;
  1442. $1=_st($String())._streamContents_((function(str){
  1443. return smalltalk.withContext(function($ctx2) {
  1444. return _st(self._exporter())._exportPackage_on_(aPackage,str);
  1445. }, function($ctx2) {$ctx2.fillBlock({str:str},$ctx1)})}));
  1446. return $1;
  1447. }, function($ctx1) {$ctx1.fill(self,"contentsFor:",{aPackage:aPackage},smalltalk.PackageHandler)})},
  1448. args: ["aPackage"],
  1449. source: "contentsFor: aPackage\x0a\x09^ String streamContents: [ :str |\x0a\x09\x09self exporter exportPackage: aPackage on: str ]",
  1450. messageSends: ["streamContents:", "exportPackage:on:", "exporter"],
  1451. referencedClasses: ["String"]
  1452. }),
  1453. smalltalk.PackageHandler);
  1454. smalltalk.addMethod(
  1455. smalltalk.method({
  1456. selector: "exporter",
  1457. category: 'factory',
  1458. fn: function (){
  1459. var self=this;
  1460. return smalltalk.withContext(function($ctx1) {
  1461. var $1;
  1462. $1=_st(self._exporterClass())._new();
  1463. return $1;
  1464. }, function($ctx1) {$ctx1.fill(self,"exporter",{},smalltalk.PackageHandler)})},
  1465. args: [],
  1466. source: "exporter\x0a\x09^ self exporterClass new",
  1467. messageSends: ["new", "exporterClass"],
  1468. referencedClasses: []
  1469. }),
  1470. smalltalk.PackageHandler);
  1471. smalltalk.addMethod(
  1472. smalltalk.method({
  1473. selector: "exporterClass",
  1474. category: 'accessing',
  1475. fn: function (){
  1476. var self=this;
  1477. function $Exporter(){return smalltalk.Exporter||(typeof Exporter=="undefined"?nil:Exporter)}
  1478. return smalltalk.withContext(function($ctx1) {
  1479. var $1;
  1480. $1=$Exporter();
  1481. return $1;
  1482. }, function($ctx1) {$ctx1.fill(self,"exporterClass",{},smalltalk.PackageHandler)})},
  1483. args: [],
  1484. source: "exporterClass\x0a\x09^ Exporter",
  1485. messageSends: [],
  1486. referencedClasses: ["Exporter"]
  1487. }),
  1488. smalltalk.PackageHandler);
  1489. smalltalk.addClass('AmdPackageHandler', smalltalk.PackageHandler, [], 'Importer-Exporter');
  1490. 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.";
  1491. smalltalk.addMethod(
  1492. smalltalk.method({
  1493. selector: "commitPathJsFor:",
  1494. category: 'accessing',
  1495. fn: function (aPackage){
  1496. var self=this;
  1497. return smalltalk.withContext(function($ctx1) {
  1498. var $1;
  1499. $1=self._toUrl_(self._namespaceFor_(aPackage));
  1500. return $1;
  1501. }, function($ctx1) {$ctx1.fill(self,"commitPathJsFor:",{aPackage:aPackage},smalltalk.AmdPackageHandler)})},
  1502. args: ["aPackage"],
  1503. source: "commitPathJsFor: aPackage\x0a\x09^self toUrl: (self namespaceFor: aPackage)",
  1504. messageSends: ["toUrl:", "namespaceFor:"],
  1505. referencedClasses: []
  1506. }),
  1507. smalltalk.AmdPackageHandler);
  1508. smalltalk.addMethod(
  1509. smalltalk.method({
  1510. selector: "commitPathStFor:",
  1511. category: 'accessing',
  1512. fn: function (aPackage){
  1513. var self=this;
  1514. return smalltalk.withContext(function($ctx1) {
  1515. var $1;
  1516. $1=self._toUrl_(_st(self._namespaceFor_(aPackage)).__comma("/_source"));
  1517. return $1;
  1518. }, function($ctx1) {$ctx1.fill(self,"commitPathStFor:",{aPackage:aPackage},smalltalk.AmdPackageHandler)})},
  1519. args: ["aPackage"],
  1520. source: "commitPathStFor: aPackage\x0a\x09\x22if _source is not mapped, .st commit will likely fail\x22\x0a\x09^self toUrl: (self namespaceFor: aPackage), '/_source'.",
  1521. messageSends: ["toUrl:", ",", "namespaceFor:"],
  1522. referencedClasses: []
  1523. }),
  1524. smalltalk.AmdPackageHandler);
  1525. smalltalk.addMethod(
  1526. smalltalk.method({
  1527. selector: "exporterClass",
  1528. category: 'accessing',
  1529. fn: function (){
  1530. var self=this;
  1531. function $AmdExporter(){return smalltalk.AmdExporter||(typeof AmdExporter=="undefined"?nil:AmdExporter)}
  1532. return smalltalk.withContext(function($ctx1) {
  1533. var $1;
  1534. $1=$AmdExporter();
  1535. return $1;
  1536. }, function($ctx1) {$ctx1.fill(self,"exporterClass",{},smalltalk.AmdPackageHandler)})},
  1537. args: [],
  1538. source: "exporterClass\x0a\x09^ AmdExporter",
  1539. messageSends: [],
  1540. referencedClasses: ["AmdExporter"]
  1541. }),
  1542. smalltalk.AmdPackageHandler);
  1543. smalltalk.addMethod(
  1544. smalltalk.method({
  1545. selector: "namespaceFor:",
  1546. category: 'committing',
  1547. fn: function (aPackage){
  1548. var self=this;
  1549. return smalltalk.withContext(function($ctx1) {
  1550. var $1;
  1551. $1=_st(_st(aPackage)._transport())._namespace();
  1552. return $1;
  1553. }, function($ctx1) {$ctx1.fill(self,"namespaceFor:",{aPackage:aPackage},smalltalk.AmdPackageHandler)})},
  1554. args: ["aPackage"],
  1555. source: "namespaceFor: aPackage\x0a\x09^ aPackage transport namespace",
  1556. messageSends: ["namespace", "transport"],
  1557. referencedClasses: []
  1558. }),
  1559. smalltalk.AmdPackageHandler);
  1560. smalltalk.addMethod(
  1561. smalltalk.method({
  1562. selector: "toUrl:",
  1563. category: 'private',
  1564. fn: function (aString){
  1565. var self=this;
  1566. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1567. return smalltalk.withContext(function($ctx1) {
  1568. var $2,$1;
  1569. $2=_st(_st($Smalltalk())._current())._amdRequire();
  1570. if(($receiver = $2) == nil || $receiver == undefined){
  1571. $1=self._error_("AMD loader not present");
  1572. } else {
  1573. var require;
  1574. require=$receiver;
  1575. $1=_st(_st(require)._basicAt_("toUrl"))._value_(aString);
  1576. };
  1577. return $1;
  1578. }, function($ctx1) {$ctx1.fill(self,"toUrl:",{aString:aString},smalltalk.AmdPackageHandler)})},
  1579. args: ["aString"],
  1580. 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 ]",
  1581. messageSends: ["ifNil:ifNotNil:", "error:", "value:", "basicAt:", "amdRequire", "current"],
  1582. referencedClasses: ["Smalltalk"]
  1583. }),
  1584. smalltalk.AmdPackageHandler);
  1585. smalltalk.addMethod(
  1586. smalltalk.method({
  1587. selector: "defaultNamespace",
  1588. category: 'commit paths',
  1589. fn: function (){
  1590. var self=this;
  1591. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1592. return smalltalk.withContext(function($ctx1) {
  1593. var $1;
  1594. $1=_st(_st($Smalltalk())._current())._defaultAmdNamespace();
  1595. return $1;
  1596. }, function($ctx1) {$ctx1.fill(self,"defaultNamespace",{},smalltalk.AmdPackageHandler.klass)})},
  1597. args: [],
  1598. source: "defaultNamespace\x0a\x09^ Smalltalk current defaultAmdNamespace",
  1599. messageSends: ["defaultAmdNamespace", "current"],
  1600. referencedClasses: ["Smalltalk"]
  1601. }),
  1602. smalltalk.AmdPackageHandler.klass);
  1603. smalltalk.addMethod(
  1604. smalltalk.method({
  1605. selector: "defaultNamespace:",
  1606. category: 'commit paths',
  1607. fn: function (aString){
  1608. var self=this;
  1609. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1610. return smalltalk.withContext(function($ctx1) {
  1611. _st(_st($Smalltalk())._current())._defaultAMDNamespace_(aString);
  1612. return self}, function($ctx1) {$ctx1.fill(self,"defaultNamespace:",{aString:aString},smalltalk.AmdPackageHandler.klass)})},
  1613. args: ["aString"],
  1614. source: "defaultNamespace: aString\x0a\x09Smalltalk current defaultAMDNamespace: aString",
  1615. messageSends: ["defaultAMDNamespace:", "current"],
  1616. referencedClasses: ["Smalltalk"]
  1617. }),
  1618. smalltalk.AmdPackageHandler.klass);
  1619. smalltalk.addMethod(
  1620. smalltalk.method({
  1621. selector: "initialize",
  1622. category: 'initialization',
  1623. fn: function (){
  1624. var self=this;
  1625. function $AMDPackageTransport(){return smalltalk.AMDPackageTransport||(typeof AMDPackageTransport=="undefined"?nil:AMDPackageTransport)}
  1626. return smalltalk.withContext(function($ctx1) {
  1627. smalltalk.AmdPackageHandler.klass.superclass.fn.prototype._initialize.apply(_st(self), []);
  1628. self._registerFor_(_st($AMDPackageTransport())._type());
  1629. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.AmdPackageHandler.klass)})},
  1630. args: [],
  1631. source: "initialize\x0a\x09super initialize.\x0a\x09self registerFor: AMDPackageTransport type",
  1632. messageSends: ["initialize", "registerFor:", "type"],
  1633. referencedClasses: ["AMDPackageTransport"]
  1634. }),
  1635. smalltalk.AmdPackageHandler.klass);
  1636. smalltalk.addMethod(
  1637. smalltalk.method({
  1638. selector: "resetCommitPaths",
  1639. category: 'commit paths',
  1640. fn: function (){
  1641. var self=this;
  1642. return smalltalk.withContext(function($ctx1) {
  1643. self["@defaultNamespace"]=nil;
  1644. return self}, function($ctx1) {$ctx1.fill(self,"resetCommitPaths",{},smalltalk.AmdPackageHandler.klass)})},
  1645. args: [],
  1646. source: "resetCommitPaths\x0a\x09defaultNamespace := nil",
  1647. messageSends: [],
  1648. referencedClasses: []
  1649. }),
  1650. smalltalk.AmdPackageHandler.klass);
  1651. smalltalk.addClass('PackageTransport', smalltalk.Object, ['package'], 'Importer-Exporter');
  1652. smalltalk.PackageTransport.comment="I represent the transport mechanism used to commit a package.\x0a\x0aMy concrete subclasses have a `#handler` to which committing is delegated.";
  1653. smalltalk.addMethod(
  1654. smalltalk.method({
  1655. selector: "commit",
  1656. category: 'committing',
  1657. fn: function (){
  1658. var self=this;
  1659. return smalltalk.withContext(function($ctx1) {
  1660. _st(self._commitHandler())._commit_(self._package());
  1661. return self}, function($ctx1) {$ctx1.fill(self,"commit",{},smalltalk.PackageTransport)})},
  1662. args: [],
  1663. source: "commit\x0a\x09self commitHandler commit: self package",
  1664. messageSends: ["commit:", "package", "commitHandler"],
  1665. referencedClasses: []
  1666. }),
  1667. smalltalk.PackageTransport);
  1668. smalltalk.addMethod(
  1669. smalltalk.method({
  1670. selector: "commitHandler",
  1671. category: 'factory',
  1672. fn: function (){
  1673. var self=this;
  1674. return smalltalk.withContext(function($ctx1) {
  1675. var $1;
  1676. $1=_st(self._commitHandlerClass())._new();
  1677. return $1;
  1678. }, function($ctx1) {$ctx1.fill(self,"commitHandler",{},smalltalk.PackageTransport)})},
  1679. args: [],
  1680. source: "commitHandler\x0a\x09^ self commitHandlerClass new",
  1681. messageSends: ["new", "commitHandlerClass"],
  1682. referencedClasses: []
  1683. }),
  1684. smalltalk.PackageTransport);
  1685. smalltalk.addMethod(
  1686. smalltalk.method({
  1687. selector: "commitHandlerClass",
  1688. category: 'accessing',
  1689. fn: function (){
  1690. var self=this;
  1691. return smalltalk.withContext(function($ctx1) {
  1692. self._subclassResponsibility();
  1693. return self}, function($ctx1) {$ctx1.fill(self,"commitHandlerClass",{},smalltalk.PackageTransport)})},
  1694. args: [],
  1695. source: "commitHandlerClass\x0a\x09self subclassResponsibility",
  1696. messageSends: ["subclassResponsibility"],
  1697. referencedClasses: []
  1698. }),
  1699. smalltalk.PackageTransport);
  1700. smalltalk.addMethod(
  1701. smalltalk.method({
  1702. selector: "package",
  1703. category: 'accessing',
  1704. fn: function (){
  1705. var self=this;
  1706. return smalltalk.withContext(function($ctx1) {
  1707. var $1;
  1708. $1=self["@package"];
  1709. return $1;
  1710. }, function($ctx1) {$ctx1.fill(self,"package",{},smalltalk.PackageTransport)})},
  1711. args: [],
  1712. source: "package\x0a\x09^ package",
  1713. messageSends: [],
  1714. referencedClasses: []
  1715. }),
  1716. smalltalk.PackageTransport);
  1717. smalltalk.addMethod(
  1718. smalltalk.method({
  1719. selector: "package:",
  1720. category: 'accessing',
  1721. fn: function (aPackage){
  1722. var self=this;
  1723. return smalltalk.withContext(function($ctx1) {
  1724. self["@package"]=aPackage;
  1725. return self}, function($ctx1) {$ctx1.fill(self,"package:",{aPackage:aPackage},smalltalk.PackageTransport)})},
  1726. args: ["aPackage"],
  1727. source: "package: aPackage\x0a\x09package := aPackage",
  1728. messageSends: [],
  1729. referencedClasses: []
  1730. }),
  1731. smalltalk.PackageTransport);
  1732. smalltalk.addMethod(
  1733. smalltalk.method({
  1734. selector: "setupFromJson:",
  1735. category: 'initialization',
  1736. fn: function (anObject){
  1737. var self=this;
  1738. return smalltalk.withContext(function($ctx1) {
  1739. return self}, function($ctx1) {$ctx1.fill(self,"setupFromJson:",{anObject:anObject},smalltalk.PackageTransport)})},
  1740. args: ["anObject"],
  1741. source: "setupFromJson: anObject\x0a\x09\x22no op. override if needed in subclasses\x22",
  1742. messageSends: [],
  1743. referencedClasses: []
  1744. }),
  1745. smalltalk.PackageTransport);
  1746. smalltalk.addMethod(
  1747. smalltalk.method({
  1748. selector: "type",
  1749. category: 'accessing',
  1750. fn: function (){
  1751. var self=this;
  1752. return smalltalk.withContext(function($ctx1) {
  1753. var $1;
  1754. $1=_st(self._class())._type();
  1755. return $1;
  1756. }, function($ctx1) {$ctx1.fill(self,"type",{},smalltalk.PackageTransport)})},
  1757. args: [],
  1758. source: "type\x0a\x09^ self class type",
  1759. messageSends: ["type", "class"],
  1760. referencedClasses: []
  1761. }),
  1762. smalltalk.PackageTransport);
  1763. smalltalk.PackageTransport.klass.iVarNames = ['registry'];
  1764. smalltalk.addMethod(
  1765. smalltalk.method({
  1766. selector: "classRegisteredFor:",
  1767. category: 'accessing',
  1768. fn: function (aString){
  1769. var self=this;
  1770. return smalltalk.withContext(function($ctx1) {
  1771. var $1;
  1772. $1=_st(self["@registry"])._at_(aString);
  1773. return $1;
  1774. }, function($ctx1) {$ctx1.fill(self,"classRegisteredFor:",{aString:aString},smalltalk.PackageTransport.klass)})},
  1775. args: ["aString"],
  1776. source: "classRegisteredFor: aString\x0a\x09^ registry at: aString",
  1777. messageSends: ["at:"],
  1778. referencedClasses: []
  1779. }),
  1780. smalltalk.PackageTransport.klass);
  1781. smalltalk.addMethod(
  1782. smalltalk.method({
  1783. selector: "for:",
  1784. category: 'accessing',
  1785. fn: function (aString){
  1786. var self=this;
  1787. return smalltalk.withContext(function($ctx1) {
  1788. var $1;
  1789. $1=_st(self._classRegisteredFor_(aString))._new();
  1790. return $1;
  1791. }, function($ctx1) {$ctx1.fill(self,"for:",{aString:aString},smalltalk.PackageTransport.klass)})},
  1792. args: ["aString"],
  1793. source: "for: aString\x0a\x09^ (self classRegisteredFor: aString) new",
  1794. messageSends: ["new", "classRegisteredFor:"],
  1795. referencedClasses: []
  1796. }),
  1797. smalltalk.PackageTransport.klass);
  1798. smalltalk.addMethod(
  1799. smalltalk.method({
  1800. selector: "initialize",
  1801. category: 'initialization',
  1802. fn: function (){
  1803. var self=this;
  1804. return smalltalk.withContext(function($ctx1) {
  1805. smalltalk.PackageTransport.klass.superclass.fn.prototype._initialize.apply(_st(self), []);
  1806. self["@registry"]=smalltalk.HashedCollection._from_([]);
  1807. self._register();
  1808. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.PackageTransport.klass)})},
  1809. args: [],
  1810. source: "initialize\x0a\x09super initialize.\x0a\x09registry := #{}.\x0a\x09self register",
  1811. messageSends: ["initialize", "register"],
  1812. referencedClasses: []
  1813. }),
  1814. smalltalk.PackageTransport.klass);
  1815. smalltalk.addMethod(
  1816. smalltalk.method({
  1817. selector: "register",
  1818. category: 'registration',
  1819. fn: function (){
  1820. var self=this;
  1821. function $PackageTransport(){return smalltalk.PackageTransport||(typeof PackageTransport=="undefined"?nil:PackageTransport)}
  1822. return smalltalk.withContext(function($ctx1) {
  1823. _st($PackageTransport())._register_(self);
  1824. return self}, function($ctx1) {$ctx1.fill(self,"register",{},smalltalk.PackageTransport.klass)})},
  1825. args: [],
  1826. source: "register\x0a\x09PackageTransport register: self",
  1827. messageSends: ["register:"],
  1828. referencedClasses: ["PackageTransport"]
  1829. }),
  1830. smalltalk.PackageTransport.klass);
  1831. smalltalk.addMethod(
  1832. smalltalk.method({
  1833. selector: "register:",
  1834. category: 'registration',
  1835. fn: function (aClass){
  1836. var self=this;
  1837. return smalltalk.withContext(function($ctx1) {
  1838. var $1;
  1839. $1=_st(aClass)._type();
  1840. if(($receiver = $1) == nil || $receiver == undefined){
  1841. $1;
  1842. } else {
  1843. _st(self["@registry"])._at_put_(_st(aClass)._type(),aClass);
  1844. };
  1845. return self}, function($ctx1) {$ctx1.fill(self,"register:",{aClass:aClass},smalltalk.PackageTransport.klass)})},
  1846. args: ["aClass"],
  1847. source: "register: aClass\x0a\x09aClass type ifNotNil: [\x0a\x09\x09registry at: aClass type put: aClass ]",
  1848. messageSends: ["ifNotNil:", "at:put:", "type"],
  1849. referencedClasses: []
  1850. }),
  1851. smalltalk.PackageTransport.klass);
  1852. smalltalk.addMethod(
  1853. smalltalk.method({
  1854. selector: "type",
  1855. category: 'accessing',
  1856. fn: function (){
  1857. var self=this;
  1858. return smalltalk.withContext(function($ctx1) {
  1859. return nil;
  1860. }, function($ctx1) {$ctx1.fill(self,"type",{},smalltalk.PackageTransport.klass)})},
  1861. args: [],
  1862. source: "type\x0a\x09\x22Override in subclasses\x22\x0a\x09^ nil",
  1863. messageSends: [],
  1864. referencedClasses: []
  1865. }),
  1866. smalltalk.PackageTransport.klass);
  1867. smalltalk.addClass('AmdPackageTransport', smalltalk.PackageTransport, ['namespace'], 'Importer-Exporter');
  1868. smalltalk.AmdPackageTransport.comment="I am the default transport for committing packages.\x0a\x0aSee `AmdExporter` and `AmdPackageHandler`.";
  1869. smalltalk.addMethod(
  1870. smalltalk.method({
  1871. selector: "commitHandlerClass",
  1872. category: 'accessing',
  1873. fn: function (){
  1874. var self=this;
  1875. function $AmdPackageHandler(){return smalltalk.AmdPackageHandler||(typeof AmdPackageHandler=="undefined"?nil:AmdPackageHandler)}
  1876. return smalltalk.withContext(function($ctx1) {
  1877. var $1;
  1878. $1=$AmdPackageHandler();
  1879. return $1;
  1880. }, function($ctx1) {$ctx1.fill(self,"commitHandlerClass",{},smalltalk.AmdPackageTransport)})},
  1881. args: [],
  1882. source: "commitHandlerClass\x0a\x09^ AmdPackageHandler",
  1883. messageSends: [],
  1884. referencedClasses: ["AmdPackageHandler"]
  1885. }),
  1886. smalltalk.AmdPackageTransport);
  1887. smalltalk.addMethod(
  1888. smalltalk.method({
  1889. selector: "defaultNamespace",
  1890. category: 'defaults',
  1891. fn: function (){
  1892. var self=this;
  1893. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1894. return smalltalk.withContext(function($ctx1) {
  1895. var $1;
  1896. $1=_st(_st($Smalltalk())._current())._defaultAmdNamespace();
  1897. return $1;
  1898. }, function($ctx1) {$ctx1.fill(self,"defaultNamespace",{},smalltalk.AmdPackageTransport)})},
  1899. args: [],
  1900. source: "defaultNamespace\x0a\x09^ Smalltalk current defaultAmdNamespace",
  1901. messageSends: ["defaultAmdNamespace", "current"],
  1902. referencedClasses: ["Smalltalk"]
  1903. }),
  1904. smalltalk.AmdPackageTransport);
  1905. smalltalk.addMethod(
  1906. smalltalk.method({
  1907. selector: "namespace",
  1908. category: 'accessing',
  1909. fn: function (){
  1910. var self=this;
  1911. return smalltalk.withContext(function($ctx1) {
  1912. var $2,$1;
  1913. $2=self["@namespace"];
  1914. if(($receiver = $2) == nil || $receiver == undefined){
  1915. $1=self._defaultNamespace();
  1916. } else {
  1917. $1=$2;
  1918. };
  1919. return $1;
  1920. }, function($ctx1) {$ctx1.fill(self,"namespace",{},smalltalk.AmdPackageTransport)})},
  1921. args: [],
  1922. source: "namespace\x0a\x09^ namespace ifNil: [ self defaultNamespace ]",
  1923. messageSends: ["ifNil:", "defaultNamespace"],
  1924. referencedClasses: []
  1925. }),
  1926. smalltalk.AmdPackageTransport);
  1927. smalltalk.addMethod(
  1928. smalltalk.method({
  1929. selector: "namespace:",
  1930. category: 'accessing',
  1931. fn: function (aString){
  1932. var self=this;
  1933. return smalltalk.withContext(function($ctx1) {
  1934. self["@namespace"]=aString;
  1935. return self}, function($ctx1) {$ctx1.fill(self,"namespace:",{aString:aString},smalltalk.AmdPackageTransport)})},
  1936. args: ["aString"],
  1937. source: "namespace: aString\x0a\x09namespace := aString",
  1938. messageSends: [],
  1939. referencedClasses: []
  1940. }),
  1941. smalltalk.AmdPackageTransport);
  1942. smalltalk.addMethod(
  1943. smalltalk.method({
  1944. selector: "setupFromJson:",
  1945. category: 'initialization',
  1946. fn: function (anObject){
  1947. var self=this;
  1948. return smalltalk.withContext(function($ctx1) {
  1949. self._namespace_(_st(anObject)._at_("amdNamespace"));
  1950. return self}, function($ctx1) {$ctx1.fill(self,"setupFromJson:",{anObject:anObject},smalltalk.AmdPackageTransport)})},
  1951. args: ["anObject"],
  1952. source: "setupFromJson: anObject\x0a\x09self namespace: (anObject at: 'amdNamespace')",
  1953. messageSends: ["namespace:", "at:"],
  1954. referencedClasses: []
  1955. }),
  1956. smalltalk.AmdPackageTransport);
  1957. smalltalk.addMethod(
  1958. smalltalk.method({
  1959. selector: "namespace:",
  1960. category: 'instance creation',
  1961. fn: function (aString){
  1962. var self=this;
  1963. return smalltalk.withContext(function($ctx1) {
  1964. var $2,$3,$1;
  1965. $2=self._new();
  1966. _st($2)._namespace_(aString);
  1967. $3=_st($2)._yourself();
  1968. $1=$3;
  1969. return $1;
  1970. }, function($ctx1) {$ctx1.fill(self,"namespace:",{aString:aString},smalltalk.AmdPackageTransport.klass)})},
  1971. args: ["aString"],
  1972. source: "namespace: aString\x0a\x09^ self new\x0a\x09\x09namespace: aString;\x0a\x09\x09yourself",
  1973. messageSends: ["namespace:", "new", "yourself"],
  1974. referencedClasses: []
  1975. }),
  1976. smalltalk.AmdPackageTransport.klass);
  1977. smalltalk.addMethod(
  1978. smalltalk.method({
  1979. selector: "type",
  1980. category: 'accessing',
  1981. fn: function (){
  1982. var self=this;
  1983. return smalltalk.withContext(function($ctx1) {
  1984. return "amd";
  1985. }, function($ctx1) {$ctx1.fill(self,"type",{},smalltalk.AmdPackageTransport.klass)})},
  1986. args: [],
  1987. source: "type\x0a\x09^ 'amd'",
  1988. messageSends: [],
  1989. referencedClasses: []
  1990. }),
  1991. smalltalk.AmdPackageTransport.klass);
  1992. smalltalk.addMethod(
  1993. smalltalk.method({
  1994. selector: "commit",
  1995. category: '*Importer-Exporter',
  1996. fn: function (){
  1997. var self=this;
  1998. return smalltalk.withContext(function($ctx1) {
  1999. var $1;
  2000. $1=_st(self._transport())._commit();
  2001. return $1;
  2002. }, function($ctx1) {$ctx1.fill(self,"commit",{},smalltalk.Package)})},
  2003. args: [],
  2004. source: "commit\x0a\x09^ self transport commit",
  2005. messageSends: ["commit", "transport"],
  2006. referencedClasses: []
  2007. }),
  2008. smalltalk.Package);
  2009. smalltalk.addMethod(
  2010. smalltalk.method({
  2011. selector: "transportJson",
  2012. category: '*Importer-Exporter',
  2013. fn: function (){
  2014. var self=this;
  2015. return smalltalk.withContext(function($ctx1) {
  2016. return JSON.stringify(self.transport || null);;
  2017. return self}, function($ctx1) {$ctx1.fill(self,"transportJson",{},smalltalk.Package)})},
  2018. args: [],
  2019. source: "transportJson\x0a\x09<return JSON.stringify(self.transport || null);>",
  2020. messageSends: [],
  2021. referencedClasses: []
  2022. }),
  2023. smalltalk.Package);
  2024. smalltalk.addMethod(
  2025. smalltalk.method({
  2026. selector: "transportType",
  2027. category: '*Importer-Exporter',
  2028. fn: function (){
  2029. var self=this;
  2030. return smalltalk.withContext(function($ctx1) {
  2031. return (self.transport && self.transport.type) || 'unknown';;
  2032. return self}, function($ctx1) {$ctx1.fill(self,"transportType",{},smalltalk.Package)})},
  2033. args: [],
  2034. source: "transportType\x0a\x09<return (self.transport && self.transport.type) || 'unknown';>",
  2035. messageSends: [],
  2036. referencedClasses: []
  2037. }),
  2038. smalltalk.Package);
  2039. smalltalk.addMethod(
  2040. smalltalk.method({
  2041. selector: "transport",
  2042. category: '*Importer-Exporter',
  2043. fn: function (){
  2044. var self=this;
  2045. function $PackageTransport(){return smalltalk.PackageTransport||(typeof PackageTransport=="undefined"?nil:PackageTransport)}
  2046. return smalltalk.withContext(function($ctx1) {
  2047. var $2,$3,$1;
  2048. $2=_st($PackageTransport())._for_(self._transportType());
  2049. _st($2)._setupFromJson_(self._basicTransport());
  2050. _st($2)._package_(self);
  2051. $3=_st($2)._yourself();
  2052. $1=$3;
  2053. return $1;
  2054. }, function($ctx1) {$ctx1.fill(self,"transport",{},smalltalk.Package)})},
  2055. args: [],
  2056. source: "transport\x0a\x09^ (PackageTransport for: self transportType)\x0a\x09\x09setupFromJson: self basicTransport;\x0a\x09\x09package: self;\x0a\x09\x09yourself",
  2057. messageSends: ["setupFromJson:", "basicTransport", "for:", "transportType", "package:", "yourself"],
  2058. referencedClasses: ["PackageTransport"]
  2059. }),
  2060. smalltalk.Package);
  2061. smalltalk.addMethod(
  2062. smalltalk.method({
  2063. selector: "basicTransport",
  2064. category: '*Importer-Exporter',
  2065. fn: function (){
  2066. var self=this;
  2067. return smalltalk.withContext(function($ctx1) {
  2068. return self.transport;
  2069. return self}, function($ctx1) {$ctx1.fill(self,"basicTransport",{},smalltalk.Package)})},
  2070. args: [],
  2071. source: "basicTransport\x0a\x09<return self.transport>",
  2072. messageSends: [],
  2073. referencedClasses: []
  2074. }),
  2075. smalltalk.Package);
  2076. });