Importer-Exporter.js 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027
  1. define("amber/Importer-Exporter", ["amber_vm/smalltalk","amber_vm/nil","amber_vm/_st"], function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Importer-Exporter');
  3. smalltalk.addClass('ChunkParser', smalltalk.Object, ['stream'], 'Importer-Exporter');
  4. 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";
  5. smalltalk.addMethod(
  6. smalltalk.method({
  7. selector: "nextChunk",
  8. category: 'reading',
  9. fn: function (){
  10. var self=this;
  11. var char,result,chunk;
  12. return smalltalk.withContext(function($ctx1) {
  13. var $1,$2,$3;
  14. var $early={};
  15. try {
  16. result=""._writeStream();
  17. _st((function(){
  18. return smalltalk.withContext(function($ctx2) {
  19. char=_st(self["@stream"])._next();
  20. char;
  21. return _st(char)._notNil();
  22. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileTrue_((function(){
  23. return smalltalk.withContext(function($ctx2) {
  24. $1=_st(char).__eq("!");
  25. if(smalltalk.assert($1)){
  26. $2=_st(_st(self["@stream"])._peek()).__eq("!");
  27. if(smalltalk.assert($2)){
  28. _st(self["@stream"])._next();
  29. } else {
  30. $3=_st(_st(result)._contents())._trimBoth();
  31. throw $early=[$3];
  32. };
  33. };
  34. return _st(result)._nextPut_(char);
  35. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  36. return nil;
  37. }
  38. catch(e) {if(e===$early)return e[0]; throw e}
  39. }, function($ctx1) {$ctx1.fill(self,"nextChunk",{char:char,result:result,chunk:chunk},smalltalk.ChunkParser)})},
  40. args: [],
  41. 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 metod 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",
  42. messageSends: ["writeStream", "whileTrue:", "ifTrue:", "ifTrue:ifFalse:", "next", "trimBoth", "contents", "=", "peek", "nextPut:", "notNil"],
  43. referencedClasses: []
  44. }),
  45. smalltalk.ChunkParser);
  46. smalltalk.addMethod(
  47. smalltalk.method({
  48. selector: "stream:",
  49. category: 'accessing',
  50. fn: function (aStream){
  51. var self=this;
  52. return smalltalk.withContext(function($ctx1) {
  53. self["@stream"]=aStream;
  54. return self}, function($ctx1) {$ctx1.fill(self,"stream:",{aStream:aStream},smalltalk.ChunkParser)})},
  55. args: ["aStream"],
  56. source: "stream: aStream\x0a\x09stream := aStream",
  57. messageSends: [],
  58. referencedClasses: []
  59. }),
  60. smalltalk.ChunkParser);
  61. smalltalk.addMethod(
  62. smalltalk.method({
  63. selector: "on:",
  64. category: 'not yet classified',
  65. fn: function (aStream){
  66. var self=this;
  67. return smalltalk.withContext(function($ctx1) {
  68. var $1;
  69. $1=_st(self._new())._stream_(aStream);
  70. return $1;
  71. }, function($ctx1) {$ctx1.fill(self,"on:",{aStream:aStream},smalltalk.ChunkParser.klass)})},
  72. args: ["aStream"],
  73. source: "on: aStream\x0a\x09^self new stream: aStream",
  74. messageSends: ["stream:", "new"],
  75. referencedClasses: []
  76. }),
  77. smalltalk.ChunkParser.klass);
  78. smalltalk.addClass('Exporter', smalltalk.Object, [], 'Importer-Exporter');
  79. 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.).\x0a\x0a## API\x0a\x0aUse `#exportAll`, `#exportClass:` or `#exportPackage:` methods.";
  80. smalltalk.addMethod(
  81. smalltalk.method({
  82. selector: "classNameFor:",
  83. category: 'private',
  84. fn: function (aClass){
  85. var self=this;
  86. return smalltalk.withContext(function($ctx1) {
  87. var $2,$3,$1;
  88. $2=_st(aClass)._isMetaclass();
  89. if(smalltalk.assert($2)){
  90. $1=_st(_st(_st(aClass)._instanceClass())._name()).__comma(".klass");
  91. } else {
  92. $3=_st(aClass)._isNil();
  93. if(smalltalk.assert($3)){
  94. $1="nil";
  95. } else {
  96. $1=_st(aClass)._name();
  97. };
  98. };
  99. return $1;
  100. }, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},smalltalk.Exporter)})},
  101. args: ["aClass"],
  102. source: "classNameFor: aClass\x0a\x09^aClass isMetaclass\x0a\x09\x09ifTrue: [aClass instanceClass name, '.klass']\x0a\x09\x09ifFalse: [\x0a\x09\x09aClass isNil\x0a\x09\x09\x09ifTrue: ['nil']\x0a\x09\x09\x09ifFalse: [aClass name]]",
  103. messageSends: ["ifTrue:ifFalse:", ",", "name", "instanceClass", "isNil", "isMetaclass"],
  104. referencedClasses: []
  105. }),
  106. smalltalk.Exporter);
  107. smalltalk.addMethod(
  108. smalltalk.method({
  109. selector: "exportAll",
  110. category: 'fileOut',
  111. fn: function (){
  112. var self=this;
  113. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  114. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  115. return smalltalk.withContext(function($ctx1) {
  116. var $1;
  117. $1=_st($String())._streamContents_((function(stream){
  118. return smalltalk.withContext(function($ctx2) {
  119. return _st(_st(_st($Smalltalk())._current())._packages())._do_((function(pkg){
  120. return smalltalk.withContext(function($ctx3) {
  121. return _st(stream)._nextPutAll_(self._exportPackage_(_st(pkg)._name()));
  122. }, function($ctx3) {$ctx3.fillBlock({pkg:pkg},$ctx2)})}));
  123. }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1)})}));
  124. return $1;
  125. }, function($ctx1) {$ctx1.fill(self,"exportAll",{},smalltalk.Exporter)})},
  126. args: [],
  127. source: "exportAll\x0a\x09\x22Export all packages in the system.\x22\x0a\x0a\x09^String streamContents: [:stream |\x0a\x09\x09Smalltalk current packages do: [:pkg |\x0a\x09\x09stream nextPutAll: (self exportPackage: pkg name)]]",
  128. messageSends: ["streamContents:", "do:", "nextPutAll:", "exportPackage:", "name", "packages", "current"],
  129. referencedClasses: ["Smalltalk", "String"]
  130. }),
  131. smalltalk.Exporter);
  132. smalltalk.addMethod(
  133. smalltalk.method({
  134. selector: "exportClass:",
  135. category: 'fileOut',
  136. fn: function (aClass){
  137. var self=this;
  138. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  139. return smalltalk.withContext(function($ctx1) {
  140. var $1;
  141. $1=_st($String())._streamContents_((function(stream){
  142. return smalltalk.withContext(function($ctx2) {
  143. self._exportDefinitionOf_on_(aClass,stream);
  144. self._exportMethodsOf_on_(aClass,stream);
  145. self._exportMetaDefinitionOf_on_(aClass,stream);
  146. return self._exportMethodsOf_on_(_st(aClass)._class(),stream);
  147. }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1)})}));
  148. return $1;
  149. }, function($ctx1) {$ctx1.fill(self,"exportClass:",{aClass:aClass},smalltalk.Exporter)})},
  150. args: ["aClass"],
  151. source: "exportClass: aClass\x0a\x09\x22Export a single class. Subclasses override these methods.\x22\x0a\x0a\x09^String streamContents: [:stream |\x0a\x09\x09self exportDefinitionOf: aClass on: stream.\x0a\x09\x09self exportMethodsOf: aClass on: stream.\x0a\x09\x09self exportMetaDefinitionOf: aClass on: stream.\x0a\x09\x09self exportMethodsOf: aClass class on: stream]",
  152. messageSends: ["streamContents:", "exportDefinitionOf:on:", "exportMethodsOf:on:", "exportMetaDefinitionOf:on:", "class"],
  153. referencedClasses: ["String"]
  154. }),
  155. smalltalk.Exporter);
  156. smalltalk.addMethod(
  157. smalltalk.method({
  158. selector: "exportDefinitionOf:on:",
  159. category: 'private',
  160. fn: function (aClass,aStream){
  161. var self=this;
  162. return smalltalk.withContext(function($ctx1) {
  163. var $1,$2,$3,$4,$5,$6,$7;
  164. $1=aStream;
  165. _st($1)._nextPutAll_("smalltalk.addClass(");
  166. _st($1)._nextPutAll_(_st("'".__comma(self._classNameFor_(aClass))).__comma("', "));
  167. _st($1)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aClass)._superclass())));
  168. $2=_st($1)._nextPutAll_(", [");
  169. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  170. return smalltalk.withContext(function($ctx2) {
  171. return _st(aStream)._nextPutAll_(_st("'".__comma(each)).__comma("'"));
  172. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  173. return smalltalk.withContext(function($ctx2) {
  174. return _st(aStream)._nextPutAll_(", ");
  175. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  176. $3=aStream;
  177. _st($3)._nextPutAll_("], '");
  178. _st($3)._nextPutAll_(_st(_st(aClass)._category()).__comma("'"));
  179. $4=_st($3)._nextPutAll_(");");
  180. $5=_st(_st(aClass)._comment())._notEmpty();
  181. if(smalltalk.assert($5)){
  182. $6=aStream;
  183. _st($6)._lf();
  184. _st($6)._nextPutAll_("smalltalk.");
  185. _st($6)._nextPutAll_(self._classNameFor_(aClass));
  186. _st($6)._nextPutAll_(".comment=");
  187. _st($6)._nextPutAll_(_st(_st(aClass)._comment())._asJavascript());
  188. $7=_st($6)._nextPutAll_(";");
  189. $7;
  190. };
  191. _st(aStream)._lf();
  192. return self}, function($ctx1) {$ctx1.fill(self,"exportDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.Exporter)})},
  193. args: ["aClass", "aStream"],
  194. source: "exportDefinitionOf: aClass on: aStream\x0a\x09aStream\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",
  195. messageSends: ["nextPutAll:", ",", "classNameFor:", "superclass", "do:separatedBy:", "instanceVariableNames", "category", "ifTrue:", "lf", "asJavascript", "comment", "notEmpty"],
  196. referencedClasses: []
  197. }),
  198. smalltalk.Exporter);
  199. smalltalk.addMethod(
  200. smalltalk.method({
  201. selector: "exportMetaDefinitionOf:on:",
  202. category: 'private',
  203. fn: function (aClass,aStream){
  204. var self=this;
  205. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  206. return smalltalk.withContext(function($ctx1) {
  207. var $1,$2,$3;
  208. $1=_st(_st(_st(aClass)._class())._instanceVariableNames())._isEmpty();
  209. if(! smalltalk.assert($1)){
  210. $2=aStream;
  211. _st($2)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aClass)._class())));
  212. $3=_st($2)._nextPutAll_(".iVarNames = [");
  213. $3;
  214. _st(_st(_st(aClass)._class())._instanceVariableNames())._do_separatedBy_((function(each){
  215. return smalltalk.withContext(function($ctx2) {
  216. return _st(aStream)._nextPutAll_(_st("'".__comma(each)).__comma("'"));
  217. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  218. return smalltalk.withContext(function($ctx2) {
  219. return _st(aStream)._nextPutAll_(",");
  220. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  221. _st(aStream)._nextPutAll_("];".__comma(_st($String())._lf()));
  222. };
  223. return self}, function($ctx1) {$ctx1.fill(self,"exportMetaDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.Exporter)})},
  224. args: ["aClass", "aStream"],
  225. source: "exportMetaDefinitionOf: aClass on: aStream\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]",
  226. messageSends: ["ifFalse:", "nextPutAll:", ",", "classNameFor:", "class", "do:separatedBy:", "instanceVariableNames", "lf", "isEmpty"],
  227. referencedClasses: ["String"]
  228. }),
  229. smalltalk.Exporter);
  230. smalltalk.addMethod(
  231. smalltalk.method({
  232. selector: "exportMethod:of:on:",
  233. category: 'private',
  234. fn: function (aMethod,aClass,aStream){
  235. var self=this;
  236. return smalltalk.withContext(function($ctx1) {
  237. var $1,$2,$3,$4;
  238. $1=aStream;
  239. _st($1)._nextPutAll_("smalltalk.addMethod(");
  240. _st($1)._lf();
  241. _st($1)._nextPutAll_("smalltalk.method({");
  242. _st($1)._lf();
  243. _st($1)._nextPutAll_(_st("selector: ".__comma(_st(_st(aMethod)._selector())._asJavascript())).__comma(","));
  244. _st($1)._lf();
  245. _st($1)._nextPutAll_(_st("category: '".__comma(_st(aMethod)._category())).__comma("',"));
  246. _st($1)._lf();
  247. _st($1)._nextPutAll_(_st("fn: ".__comma(_st(_st(aMethod)._fn())._compiledSource())).__comma(","));
  248. _st($1)._lf();
  249. _st($1)._nextPutAll_(_st("args: ".__comma(_st(_st(aMethod)._arguments())._asJavascript())).__comma(","));
  250. _st($1)._lf();
  251. _st($1)._nextPutAll_(_st("source: ".__comma(_st(_st(aMethod)._source())._asJavascript())).__comma(","));
  252. _st($1)._lf();
  253. _st($1)._nextPutAll_(_st("messageSends: ".__comma(_st(_st(aMethod)._messageSends())._asJavascript())).__comma(","));
  254. _st($1)._lf();
  255. $2=_st($1)._nextPutAll_("referencedClasses: ".__comma(_st(_st(aMethod)._referencedClasses())._asJavascript()));
  256. $3=aStream;
  257. _st($3)._lf();
  258. _st($3)._nextPutAll_("}),");
  259. _st($3)._lf();
  260. _st($3)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(aClass)));
  261. _st($3)._nextPutAll_(");");
  262. _st($3)._lf();
  263. $4=_st($3)._lf();
  264. return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:of:on:",{aMethod:aMethod,aClass:aClass,aStream:aStream},smalltalk.Exporter)})},
  265. args: ["aMethod", "aClass", "aStream"],
  266. source: "exportMethod: aMethod of: aClass 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: aClass);\x0a\x09\x09nextPutAll: ');';lf;lf",
  267. messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "selector", "category", "compiledSource", "fn", "arguments", "source", "messageSends", "referencedClasses", "classNameFor:"],
  268. referencedClasses: []
  269. }),
  270. smalltalk.Exporter);
  271. smalltalk.addMethod(
  272. smalltalk.method({
  273. selector: "exportMethodsOf:on:",
  274. category: 'private',
  275. fn: function (aClass,aStream){
  276. var self=this;
  277. return smalltalk.withContext(function($ctx1) {
  278. var $1;
  279. _st(_st(_st(_st(aClass)._methodDictionary())._values())._sorted_((function(a,b){
  280. return smalltalk.withContext(function($ctx2) {
  281. return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  282. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})})))._do_((function(each){
  283. return smalltalk.withContext(function($ctx2) {
  284. $1=_st(_st(each)._category())._match_("^\x5c*");
  285. if(! smalltalk.assert($1)){
  286. return self._exportMethod_of_on_(each,aClass,aStream);
  287. };
  288. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  289. _st(aStream)._lf();
  290. return self}, function($ctx1) {$ctx1.fill(self,"exportMethodsOf:on:",{aClass:aClass,aStream:aStream},smalltalk.Exporter)})},
  291. args: ["aClass", "aStream"],
  292. source: "exportMethodsOf: aClass on: aStream\x0a\x09\x22Issue #143: sort methods alphabetically\x22\x0a\x0a\x09((aClass methodDictionary values) sorted: [:a :b | a selector <= b selector]) do: [:each |\x0a\x09\x09(each category match: '^\x5c*') ifFalse: [\x0a\x09\x09\x09self exportMethod: each of: aClass on: aStream]].\x0a\x09aStream lf",
  293. messageSends: ["do:", "ifFalse:", "exportMethod:of:on:", "match:", "category", "sorted:", "<=", "selector", "values", "methodDictionary", "lf"],
  294. referencedClasses: []
  295. }),
  296. smalltalk.Exporter);
  297. smalltalk.addMethod(
  298. smalltalk.method({
  299. selector: "exportPackage:",
  300. category: 'fileOut',
  301. fn: function (packageName){
  302. var self=this;
  303. var package_;
  304. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  305. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  306. return smalltalk.withContext(function($ctx1) {
  307. var $1;
  308. $1=_st($String())._streamContents_((function(stream){
  309. return smalltalk.withContext(function($ctx2) {
  310. package_=_st(_st($Smalltalk())._current())._packageAt_(packageName);
  311. package_;
  312. self._exportPackagePrologueOf_on_(package_,stream);
  313. return _st((function(){
  314. return smalltalk.withContext(function($ctx3) {
  315. self._exportPackageDefinitionOf_on_(package_,stream);
  316. _st(_st(_st(package_)._sortedClasses())._asSet())._do_((function(each){
  317. return smalltalk.withContext(function($ctx4) {
  318. return _st(stream)._nextPutAll_(self._exportClass_(each));
  319. }, function($ctx4) {$ctx4.fillBlock({each:each},$ctx3)})}));
  320. return self._exportPackageExtensionsOf_on_(package_,stream);
  321. }, function($ctx3) {$ctx3.fillBlock({},$ctx2)})}))._ensure_((function(){
  322. return smalltalk.withContext(function($ctx3) {
  323. return self._exportPackageEpilogueOn_(stream);
  324. }, function($ctx3) {$ctx3.fillBlock({},$ctx2)})}));
  325. }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1)})}));
  326. return $1;
  327. }, function($ctx1) {$ctx1.fill(self,"exportPackage:",{packageName:packageName,package_:package_},smalltalk.Exporter)})},
  328. args: ["packageName"],
  329. source: "exportPackage: packageName\x0a\x09\x22Export a given package by name.\x22\x0a\x0a\x09| package |\x0a\x09^String streamContents: [:stream |\x0a\x09\x09package := Smalltalk current packageAt: packageName.\x0a\x09\x09self exportPackagePrologueOf: package on: stream.\x0a\x09\x09[\x0a\x09\x09\x09self exportPackageDefinitionOf: package on: stream.\x0a\x0a\x09\x09\x09\x22Export classes in dependency order.\x0a\x09\x09\x09Update (issue #171): Remove duplicates for export\x22\x0a\x09\x09\x09package sortedClasses asSet do: [:each |\x0a\x09\x09\x09\x09\x09\x09stream nextPutAll: (self exportClass: each)].\x0a\x09\x09\x09self exportPackageExtensionsOf: package on: stream\x0a\x09\x09] ensure: [\x0a\x09\x09\x09self exportPackageEpilogueOn: stream\x0a\x09\x09]]",
  330. messageSends: ["streamContents:", "packageAt:", "current", "exportPackagePrologueOf:on:", "ensure:", "exportPackageEpilogueOn:", "exportPackageDefinitionOf:on:", "do:", "nextPutAll:", "exportClass:", "asSet", "sortedClasses", "exportPackageExtensionsOf:on:"],
  331. referencedClasses: ["Smalltalk", "String"]
  332. }),
  333. smalltalk.Exporter);
  334. smalltalk.addMethod(
  335. smalltalk.method({
  336. selector: "exportPackageDefinitionOf:on:",
  337. category: 'private',
  338. fn: function (package_,aStream){
  339. var self=this;
  340. return smalltalk.withContext(function($ctx1) {
  341. var $1,$2;
  342. $1=aStream;
  343. _st($1)._nextPutAll_("smalltalk.addPackage(");
  344. _st($1)._nextPutAll_(_st("'".__comma(_st(package_)._name())).__comma("');"));
  345. $2=_st($1)._lf();
  346. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageDefinitionOf:on:",{package_:package_,aStream:aStream},smalltalk.Exporter)})},
  347. args: ["package", "aStream"],
  348. source: "exportPackageDefinitionOf: package on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: 'smalltalk.addPackage(';\x0a\x09\x09nextPutAll: '''', package name, ''');';\x0a\x09\x09lf",
  349. messageSends: ["nextPutAll:", ",", "name", "lf"],
  350. referencedClasses: []
  351. }),
  352. smalltalk.Exporter);
  353. smalltalk.addMethod(
  354. smalltalk.method({
  355. selector: "exportPackageEpilogueOn:",
  356. category: 'private',
  357. fn: function (aStream){
  358. var self=this;
  359. return smalltalk.withContext(function($ctx1) {
  360. var $1,$2;
  361. $1=aStream;
  362. _st($1)._nextPutAll_("});");
  363. $2=_st($1)._lf();
  364. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageEpilogueOn:",{aStream:aStream},smalltalk.Exporter)})},
  365. args: ["aStream"],
  366. source: "exportPackageEpilogueOn: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: '});';\x0a\x09\x09lf",
  367. messageSends: ["nextPutAll:", "lf"],
  368. referencedClasses: []
  369. }),
  370. smalltalk.Exporter);
  371. smalltalk.addMethod(
  372. smalltalk.method({
  373. selector: "exportPackageExtensionsOf:on:",
  374. category: 'private',
  375. fn: function (package_,aStream){
  376. var self=this;
  377. var name;
  378. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  379. function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
  380. return smalltalk.withContext(function($ctx1) {
  381. var $1;
  382. name=_st(package_)._name();
  383. _st(_st($Package())._sortedClasses_(_st(_st($Smalltalk())._current())._classes()))._do_((function(each){
  384. return smalltalk.withContext(function($ctx2) {
  385. return _st([each,_st(each)._class()])._do_((function(aClass){
  386. return smalltalk.withContext(function($ctx3) {
  387. return _st(_st(_st(_st(aClass)._methodDictionary())._values())._sorted_((function(a,b){
  388. return smalltalk.withContext(function($ctx4) {
  389. return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  390. }, function($ctx4) {$ctx4.fillBlock({a:a,b:b},$ctx3)})})))._do_((function(method){
  391. return smalltalk.withContext(function($ctx4) {
  392. $1=_st(_st(method)._category())._match_("^\x5c*".__comma(name));
  393. if(smalltalk.assert($1)){
  394. return self._exportMethod_of_on_(method,aClass,aStream);
  395. };
  396. }, function($ctx4) {$ctx4.fillBlock({method:method},$ctx3)})}));
  397. }, function($ctx3) {$ctx3.fillBlock({aClass:aClass},$ctx2)})}));
  398. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  399. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageExtensionsOf:on:",{package_:package_,aStream:aStream,name:name},smalltalk.Exporter)})},
  400. args: ["package", "aStream"],
  401. source: "exportPackageExtensionsOf: package on: aStream\x0a\x09\x22Issue #143: sort classes and methods alphabetically\x22\x0a\x0a\x09| name |\x0a\x09name := package name.\x0a\x09(Package sortedClasses: Smalltalk current classes) do: [:each |\x0a\x09\x09{each. each class} do: [:aClass |\x0a\x09\x09\x09((aClass methodDictionary values) sorted: [:a :b | a selector <= b selector]) do: [:method |\x0a\x09\x09\x09\x09(method category match: '^\x5c*', name) ifTrue: [\x0a\x09\x09\x09\x09\x09self exportMethod: method of: aClass on: aStream ]]]]",
  402. messageSends: ["name", "do:", "ifTrue:", "exportMethod:of:on:", "match:", ",", "category", "sorted:", "<=", "selector", "values", "methodDictionary", "class", "sortedClasses:", "classes", "current"],
  403. referencedClasses: ["Smalltalk", "Package"]
  404. }),
  405. smalltalk.Exporter);
  406. smalltalk.addMethod(
  407. smalltalk.method({
  408. selector: "exportPackagePrologueOf:on:",
  409. category: 'private',
  410. fn: function (aPackage,aStream){
  411. var self=this;
  412. return smalltalk.withContext(function($ctx1) {
  413. var $1,$2;
  414. $1=aStream;
  415. _st($1)._nextPutAll_("define(\x22amber/");
  416. _st($1)._nextPutAll_(_st(aPackage)._name());
  417. _st($1)._nextPutAll_("\x22, [\x22amber_vm/smalltalk\x22,\x22amber_vm/nil\x22,\x22amber_vm/_st\x22], function(smalltalk,nil,_st){");
  418. $2=_st($1)._lf();
  419. return self}, function($ctx1) {$ctx1.fill(self,"exportPackagePrologueOf:on:",{aPackage:aPackage,aStream:aStream},smalltalk.Exporter)})},
  420. args: ["aPackage", "aStream"],
  421. source: "exportPackagePrologueOf: aPackage on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: 'define(\x22amber/';\x0a\x09\x09nextPutAll: aPackage name;\x0a\x09\x09nextPutAll: '\x22, [\x22amber_vm/smalltalk\x22,\x22amber_vm/nil\x22,\x22amber_vm/_st\x22], function(smalltalk,nil,_st){';\x0a\x09\x09lf",
  422. messageSends: ["nextPutAll:", "name", "lf"],
  423. referencedClasses: []
  424. }),
  425. smalltalk.Exporter);
  426. smalltalk.addClass('ChunkExporter', smalltalk.Exporter, [], 'Importer-Exporter');
  427. 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.";
  428. smalltalk.addMethod(
  429. smalltalk.method({
  430. selector: "chunkEscape:",
  431. category: 'private',
  432. fn: function (aString){
  433. var self=this;
  434. return smalltalk.withContext(function($ctx1) {
  435. var $1;
  436. $1=_st(_st(aString)._replace_with_("!","!!"))._trimBoth();
  437. return $1;
  438. }, function($ctx1) {$ctx1.fill(self,"chunkEscape:",{aString:aString},smalltalk.ChunkExporter)})},
  439. args: ["aString"],
  440. source: "chunkEscape: aString\x0a\x09\x22Replace all occurrences of ! with !! and trim at both ends.\x22\x0a\x0a\x09^(aString replace: '!' with: '!!') trimBoth",
  441. messageSends: ["trimBoth", "replace:with:"],
  442. referencedClasses: []
  443. }),
  444. smalltalk.ChunkExporter);
  445. smalltalk.addMethod(
  446. smalltalk.method({
  447. selector: "classNameFor:",
  448. category: 'private',
  449. fn: function (aClass){
  450. var self=this;
  451. return smalltalk.withContext(function($ctx1) {
  452. var $2,$3,$1;
  453. $2=_st(aClass)._isMetaclass();
  454. if(smalltalk.assert($2)){
  455. $1=_st(_st(_st(aClass)._instanceClass())._name()).__comma(" class");
  456. } else {
  457. $3=_st(aClass)._isNil();
  458. if(smalltalk.assert($3)){
  459. $1="nil";
  460. } else {
  461. $1=_st(aClass)._name();
  462. };
  463. };
  464. return $1;
  465. }, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},smalltalk.ChunkExporter)})},
  466. args: ["aClass"],
  467. source: "classNameFor: aClass\x0a\x09^aClass isMetaclass\x0a\x09\x09ifTrue: [aClass instanceClass name, ' class']\x0a\x09\x09ifFalse: [\x0a\x09\x09aClass isNil\x0a\x09\x09\x09ifTrue: ['nil']\x0a\x09\x09\x09ifFalse: [aClass name]]",
  468. messageSends: ["ifTrue:ifFalse:", ",", "name", "instanceClass", "isNil", "isMetaclass"],
  469. referencedClasses: []
  470. }),
  471. smalltalk.ChunkExporter);
  472. smalltalk.addMethod(
  473. smalltalk.method({
  474. selector: "exportDefinitionOf:on:",
  475. category: 'private',
  476. fn: function (aClass,aStream){
  477. var self=this;
  478. return smalltalk.withContext(function($ctx1) {
  479. var $1,$2,$3,$4,$5,$6,$7;
  480. $1=aStream;
  481. _st($1)._nextPutAll_(self._classNameFor_(_st(aClass)._superclass()));
  482. _st($1)._nextPutAll_(" subclass: #".__comma(self._classNameFor_(aClass)));
  483. _st($1)._lf();
  484. _st($1)._tab();
  485. $2=_st($1)._nextPutAll_("instanceVariableNames: '");
  486. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  487. return smalltalk.withContext(function($ctx2) {
  488. return _st(aStream)._nextPutAll_(each);
  489. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  490. return smalltalk.withContext(function($ctx2) {
  491. return _st(aStream)._nextPutAll_(" ");
  492. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  493. $3=aStream;
  494. _st($3)._nextPutAll_("'");
  495. _st($3)._lf();
  496. _st($3)._tab();
  497. _st($3)._nextPutAll_(_st("package: '".__comma(_st(aClass)._category())).__comma("'!"));
  498. $4=_st($3)._lf();
  499. $5=_st(_st(aClass)._comment())._notEmpty();
  500. if(smalltalk.assert($5)){
  501. $6=aStream;
  502. _st($6)._nextPutAll_(_st("!".__comma(self._classNameFor_(aClass))).__comma(" commentStamp!"));
  503. _st($6)._lf();
  504. _st($6)._nextPutAll_(_st(self._chunkEscape_(_st(aClass)._comment())).__comma("!"));
  505. $7=_st($6)._lf();
  506. $7;
  507. };
  508. _st(aStream)._lf();
  509. return self}, function($ctx1) {$ctx1.fill(self,"exportDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
  510. args: ["aClass", "aStream"],
  511. 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",
  512. messageSends: ["nextPutAll:", "classNameFor:", "superclass", ",", "lf", "tab", "do:separatedBy:", "instanceVariableNames", "category", "ifTrue:", "chunkEscape:", "comment", "notEmpty"],
  513. referencedClasses: []
  514. }),
  515. smalltalk.ChunkExporter);
  516. smalltalk.addMethod(
  517. smalltalk.method({
  518. selector: "exportMetaDefinitionOf:on:",
  519. category: 'private',
  520. fn: function (aClass,aStream){
  521. var self=this;
  522. return smalltalk.withContext(function($ctx1) {
  523. var $1,$2,$3,$4,$5;
  524. $1=_st(_st(_st(aClass)._class())._instanceVariableNames())._isEmpty();
  525. if(! smalltalk.assert($1)){
  526. $2=aStream;
  527. _st($2)._nextPutAll_(self._classNameFor_(_st(aClass)._class()));
  528. $3=_st($2)._nextPutAll_(" instanceVariableNames: '");
  529. $3;
  530. _st(_st(_st(aClass)._class())._instanceVariableNames())._do_separatedBy_((function(each){
  531. return smalltalk.withContext(function($ctx2) {
  532. return _st(aStream)._nextPutAll_(each);
  533. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  534. return smalltalk.withContext(function($ctx2) {
  535. return _st(aStream)._nextPutAll_(" ");
  536. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  537. $4=aStream;
  538. _st($4)._nextPutAll_("'!");
  539. _st($4)._lf();
  540. $5=_st($4)._lf();
  541. $5;
  542. };
  543. return self}, function($ctx1) {$ctx1.fill(self,"exportMetaDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
  544. args: ["aClass", "aStream"],
  545. 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]",
  546. messageSends: ["ifFalse:", "nextPutAll:", "classNameFor:", "class", "do:separatedBy:", "instanceVariableNames", "lf", "isEmpty"],
  547. referencedClasses: []
  548. }),
  549. smalltalk.ChunkExporter);
  550. smalltalk.addMethod(
  551. smalltalk.method({
  552. selector: "exportMethod:of:on:",
  553. category: 'private',
  554. fn: function (aMethod,aClass,aStream){
  555. var self=this;
  556. return smalltalk.withContext(function($ctx1) {
  557. var $1,$2;
  558. $1=aStream;
  559. _st($1)._lf();
  560. _st($1)._lf();
  561. _st($1)._nextPutAll_(self._chunkEscape_(_st(aMethod)._source()));
  562. _st($1)._lf();
  563. $2=_st($1)._nextPutAll_("!");
  564. return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:of:on:",{aMethod:aMethod,aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
  565. args: ["aMethod", "aClass", "aStream"],
  566. source: "exportMethod: aMethod of: aClass on: aStream\x0a\x09aStream\x0a\x09\x09lf; lf; nextPutAll: (self chunkEscape: aMethod source); lf;\x0a\x09\x09nextPutAll: '!'",
  567. messageSends: ["lf", "nextPutAll:", "chunkEscape:", "source"],
  568. referencedClasses: []
  569. }),
  570. smalltalk.ChunkExporter);
  571. smalltalk.addMethod(
  572. smalltalk.method({
  573. selector: "exportMethods:category:of:on:",
  574. category: 'private',
  575. fn: function (methods,category,aClass,aStream){
  576. var self=this;
  577. return smalltalk.withContext(function($ctx1) {
  578. var $1,$2,$3,$4;
  579. $1=aStream;
  580. _st($1)._nextPutAll_("!".__comma(self._classNameFor_(aClass)));
  581. $2=_st($1)._nextPutAll_(_st(" methodsFor: '".__comma(category)).__comma("'!"));
  582. _st(_st(methods)._sorted_((function(a,b){
  583. return smalltalk.withContext(function($ctx2) {
  584. return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  585. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})})))._do_((function(each){
  586. return smalltalk.withContext(function($ctx2) {
  587. return self._exportMethod_of_on_(each,aClass,aStream);
  588. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  589. $3=aStream;
  590. _st($3)._nextPutAll_(" !");
  591. _st($3)._lf();
  592. $4=_st($3)._lf();
  593. return self}, function($ctx1) {$ctx1.fill(self,"exportMethods:category:of:on:",{methods:methods,category:category,aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
  594. args: ["methods", "category", "aClass", "aStream"],
  595. source: "exportMethods: methods category: category of: aClass on: aStream\x0a\x09\x22Issue #143: sort methods alphabetically\x22\x0a\x0a\x09aStream\x0a\x09\x09nextPutAll: '!', (self classNameFor: aClass);\x0a\x09\x09nextPutAll: ' methodsFor: ''', category, '''!'.\x0a\x09\x09(methods sorted: [:a :b | a selector <= b selector]) do: [:each |\x0a\x09\x09\x09\x09self exportMethod: each of: aClass on: aStream].\x0a\x09aStream nextPutAll: ' !'; lf; lf",
  596. messageSends: ["nextPutAll:", ",", "classNameFor:", "do:", "exportMethod:of:on:", "sorted:", "<=", "selector", "lf"],
  597. referencedClasses: []
  598. }),
  599. smalltalk.ChunkExporter);
  600. smalltalk.addMethod(
  601. smalltalk.method({
  602. selector: "exportMethodsOf:on:",
  603. category: 'private',
  604. fn: function (aClass,aStream){
  605. var self=this;
  606. var map;
  607. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  608. return smalltalk.withContext(function($ctx1) {
  609. var $1;
  610. map=_st($Dictionary())._new();
  611. _st(aClass)._protocolsDo_((function(category,methods){
  612. return smalltalk.withContext(function($ctx2) {
  613. $1=_st(category)._match_("^\x5c*");
  614. if(! smalltalk.assert($1)){
  615. return _st(map)._at_put_(category,methods);
  616. };
  617. }, function($ctx2) {$ctx2.fillBlock({category:category,methods:methods},$ctx1)})}));
  618. _st(_st(_st(map)._keys())._sorted_((function(a,b){
  619. return smalltalk.withContext(function($ctx2) {
  620. return _st(a).__lt_eq(b);
  621. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})})))._do_((function(category){
  622. var methods;
  623. return smalltalk.withContext(function($ctx2) {
  624. methods=_st(map)._at_(category);
  625. methods;
  626. return self._exportMethods_category_of_on_(methods,category,aClass,aStream);
  627. }, function($ctx2) {$ctx2.fillBlock({category:category,methods:methods},$ctx1)})}));
  628. return self}, function($ctx1) {$ctx1.fill(self,"exportMethodsOf:on:",{aClass:aClass,aStream:aStream,map:map},smalltalk.ChunkExporter)})},
  629. args: ["aClass", "aStream"],
  630. source: "exportMethodsOf: aClass on: aStream\x0a\x09\x22Issue #143: sort protocol alphabetically\x22\x0a\x0a\x09| map |\x0a\x09map := Dictionary new.\x0a\x09aClass protocolsDo: [:category :methods |\x0a\x09\x09(category match: '^\x5c*') ifFalse: [ map at: category put: methods ]].\x0a\x09(map keys sorted: [:a :b | a <= b ]) do: [:category | | methods |\x0a\x09\x09methods := map at: category.\x0a\x09\x09self\x0a\x09\x09\x09exportMethods: methods\x0a\x09\x09\x09category: category\x0a\x09\x09\x09of: aClass\x0a\x09\x09\x09on: aStream ]",
  631. messageSends: ["new", "protocolsDo:", "ifFalse:", "at:put:", "match:", "do:", "at:", "exportMethods:category:of:on:", "sorted:", "<=", "keys"],
  632. referencedClasses: ["Dictionary"]
  633. }),
  634. smalltalk.ChunkExporter);
  635. smalltalk.addMethod(
  636. smalltalk.method({
  637. selector: "exportPackageDefinitionOf:on:",
  638. category: 'private',
  639. fn: function (package_,aStream){
  640. var self=this;
  641. return smalltalk.withContext(function($ctx1) {
  642. var $1,$2;
  643. $1=aStream;
  644. _st($1)._nextPutAll_(_st("Smalltalk current createPackage: '".__comma(_st(package_)._name())).__comma("'!"));
  645. $2=_st($1)._lf();
  646. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageDefinitionOf:on:",{package_:package_,aStream:aStream},smalltalk.ChunkExporter)})},
  647. args: ["package", "aStream"],
  648. source: "exportPackageDefinitionOf: package on: aStream\x0a\x09\x22Chunk format.\x22\x0a\x0a\x09aStream\x0a\x09\x09nextPutAll: 'Smalltalk current createPackage: ''', package name, '''!';\x0a\x09\x09lf",
  649. messageSends: ["nextPutAll:", ",", "name", "lf"],
  650. referencedClasses: []
  651. }),
  652. smalltalk.ChunkExporter);
  653. smalltalk.addMethod(
  654. smalltalk.method({
  655. selector: "exportPackageEpilogueOn:",
  656. category: 'private',
  657. fn: function (aStream){
  658. var self=this;
  659. return smalltalk.withContext(function($ctx1) {
  660. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageEpilogueOn:",{aStream:aStream},smalltalk.ChunkExporter)})},
  661. args: ["aStream"],
  662. source: "exportPackageEpilogueOn: aStream",
  663. messageSends: [],
  664. referencedClasses: []
  665. }),
  666. smalltalk.ChunkExporter);
  667. smalltalk.addMethod(
  668. smalltalk.method({
  669. selector: "exportPackageExtensionsOf:on:",
  670. category: 'private',
  671. fn: function (package_,aStream){
  672. var self=this;
  673. var name,map;
  674. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  675. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  676. function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
  677. return smalltalk.withContext(function($ctx1) {
  678. var $1;
  679. name=_st(package_)._name();
  680. _st(_st($Package())._sortedClasses_(_st(_st($Smalltalk())._current())._classes()))._do_((function(each){
  681. return smalltalk.withContext(function($ctx2) {
  682. return _st([each,_st(each)._class()])._do_((function(aClass){
  683. return smalltalk.withContext(function($ctx3) {
  684. map=_st($Dictionary())._new();
  685. map;
  686. _st(aClass)._protocolsDo_((function(category,methods){
  687. return smalltalk.withContext(function($ctx4) {
  688. $1=_st(category)._match_("^\x5c*".__comma(name));
  689. if(smalltalk.assert($1)){
  690. return _st(map)._at_put_(category,methods);
  691. };
  692. }, function($ctx4) {$ctx4.fillBlock({category:category,methods:methods},$ctx3)})}));
  693. return _st(_st(_st(map)._keys())._sorted_((function(a,b){
  694. return smalltalk.withContext(function($ctx4) {
  695. return _st(a).__lt_eq(b);
  696. }, function($ctx4) {$ctx4.fillBlock({a:a,b:b},$ctx3)})})))._do_((function(category){
  697. var methods;
  698. return smalltalk.withContext(function($ctx4) {
  699. methods=_st(map)._at_(category);
  700. methods;
  701. return self._exportMethods_category_of_on_(methods,category,aClass,aStream);
  702. }, function($ctx4) {$ctx4.fillBlock({category:category,methods:methods},$ctx3)})}));
  703. }, function($ctx3) {$ctx3.fillBlock({aClass:aClass},$ctx2)})}));
  704. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  705. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageExtensionsOf:on:",{package_:package_,aStream:aStream,name:name,map:map},smalltalk.ChunkExporter)})},
  706. args: ["package", "aStream"],
  707. source: "exportPackageExtensionsOf: package on: aStream\x0a\x09\x22We need to override this one too since we need to group\x0a\x09all methods in a given protocol under a leading methodsFor: chunk\x0a\x09for that class.\x22\x0a\x0a\x09\x22Issue #143: sort protocol alphabetically\x22\x0a\x0a\x09| name map |\x0a\x09name := package name.\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\x09(category match: '^\x5c*', name) ifTrue: [ map at: category put: methods ]].\x0a\x09\x09\x09(map keys sorted: [:a :b | a <= b ]) do: [:category | | methods |\x0a\x09\x09\x09\x09methods := map at: category.\x0a\x09\x09\x09\x09self exportMethods: methods category: category of: aClass on: aStream ]]]",
  708. messageSends: ["name", "do:", "new", "protocolsDo:", "ifTrue:", "at:put:", "match:", ",", "at:", "exportMethods:category:of:on:", "sorted:", "<=", "keys", "class", "sortedClasses:", "classes", "current"],
  709. referencedClasses: ["Dictionary", "Smalltalk", "Package"]
  710. }),
  711. smalltalk.ChunkExporter);
  712. smalltalk.addMethod(
  713. smalltalk.method({
  714. selector: "exportPackagePrologueOn:",
  715. category: 'private',
  716. fn: function (aStream){
  717. var self=this;
  718. return smalltalk.withContext(function($ctx1) {
  719. return self}, function($ctx1) {$ctx1.fill(self,"exportPackagePrologueOn:",{aStream:aStream},smalltalk.ChunkExporter)})},
  720. args: ["aStream"],
  721. source: "exportPackagePrologueOn: aStream",
  722. messageSends: [],
  723. referencedClasses: []
  724. }),
  725. smalltalk.ChunkExporter);
  726. smalltalk.addClass('StrippedExporter', smalltalk.Exporter, [], 'Importer-Exporter');
  727. smalltalk.StrippedExporter.comment="I export Amber code into a JavaScript string, but without any optional associated data like the Amber source code.";
  728. smalltalk.addMethod(
  729. smalltalk.method({
  730. selector: "exportDefinitionOf:on:",
  731. category: 'private',
  732. fn: function (aClass,aStream){
  733. var self=this;
  734. return smalltalk.withContext(function($ctx1) {
  735. var $1,$2,$3,$4;
  736. $1=aStream;
  737. _st($1)._nextPutAll_("smalltalk.addClass(");
  738. _st($1)._nextPutAll_(_st("'".__comma(self._classNameFor_(aClass))).__comma("', "));
  739. _st($1)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aClass)._superclass())));
  740. $2=_st($1)._nextPutAll_(", [");
  741. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  742. return smalltalk.withContext(function($ctx2) {
  743. return _st(aStream)._nextPutAll_(_st("'".__comma(each)).__comma("'"));
  744. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  745. return smalltalk.withContext(function($ctx2) {
  746. return _st(aStream)._nextPutAll_(", ");
  747. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  748. $3=aStream;
  749. _st($3)._nextPutAll_("], '");
  750. _st($3)._nextPutAll_(_st(_st(aClass)._category()).__comma("'"));
  751. $4=_st($3)._nextPutAll_(");");
  752. _st(aStream)._lf();
  753. return self}, function($ctx1) {$ctx1.fill(self,"exportDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.StrippedExporter)})},
  754. args: ["aClass", "aStream"],
  755. source: "exportDefinitionOf: aClass on: aStream\x0a\x09aStream\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\x09aStream lf",
  756. messageSends: ["nextPutAll:", ",", "classNameFor:", "superclass", "do:separatedBy:", "instanceVariableNames", "category", "lf"],
  757. referencedClasses: []
  758. }),
  759. smalltalk.StrippedExporter);
  760. smalltalk.addMethod(
  761. smalltalk.method({
  762. selector: "exportMethod:of:on:",
  763. category: 'private',
  764. fn: function (aMethod,aClass,aStream){
  765. var self=this;
  766. return smalltalk.withContext(function($ctx1) {
  767. var $1,$2;
  768. $1=aStream;
  769. _st($1)._nextPutAll_("smalltalk.addMethod(");
  770. _st($1)._lf();
  771. _st($1)._nextPutAll_("smalltalk.method({");
  772. _st($1)._lf();
  773. _st($1)._nextPutAll_(_st("selector: ".__comma(_st(_st(aMethod)._selector())._asJavascript())).__comma(","));
  774. _st($1)._lf();
  775. _st($1)._nextPutAll_(_st("fn: ".__comma(_st(_st(aMethod)._fn())._compiledSource())).__comma(","));
  776. _st($1)._lf();
  777. _st($1)._nextPutAll_("messageSends: ".__comma(_st(_st(aMethod)._messageSends())._asJavascript()));
  778. _st($1)._nextPutAll_("}),");
  779. _st($1)._lf();
  780. _st($1)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(aClass)));
  781. _st($1)._nextPutAll_(");");
  782. _st($1)._lf();
  783. $2=_st($1)._lf();
  784. return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:of:on:",{aMethod:aMethod,aClass:aClass,aStream:aStream},smalltalk.StrippedExporter)})},
  785. args: ["aMethod", "aClass", "aStream"],
  786. source: "exportMethod: aMethod of: aClass 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: 'fn: ', aMethod fn compiledSource, ',';lf;\x0a\x09\x09nextPutAll: 'messageSends: ', aMethod messageSends asJavascript;\x0a\x09\x09nextPutAll: '}),';lf;\x0a\x09\x09nextPutAll: 'smalltalk.', (self classNameFor: aClass);\x0a\x09\x09nextPutAll: ');';lf;lf",
  787. messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "selector", "compiledSource", "fn", "messageSends", "classNameFor:"],
  788. referencedClasses: []
  789. }),
  790. smalltalk.StrippedExporter);
  791. smalltalk.addClass('Importer', smalltalk.Object, [], 'Importer-Exporter');
  792. smalltalk.Importer.comment="I can import Amber code from a string in the chunk format.\x0a\x0a## API\x0a\x0a Importer new import: aString";
  793. smalltalk.addMethod(
  794. smalltalk.method({
  795. selector: "import:",
  796. category: 'fileIn',
  797. fn: function (aStream){
  798. var self=this;
  799. var chunk,result,parser,lastEmpty;
  800. function $ChunkParser(){return smalltalk.ChunkParser||(typeof ChunkParser=="undefined"?nil:ChunkParser)}
  801. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  802. return smalltalk.withContext(function($ctx1) {
  803. var $1,$2;
  804. parser=_st($ChunkParser())._on_(aStream);
  805. lastEmpty=false;
  806. _st((function(){
  807. return smalltalk.withContext(function($ctx2) {
  808. chunk=_st(parser)._nextChunk();
  809. chunk;
  810. return _st(chunk)._isNil();
  811. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
  812. return smalltalk.withContext(function($ctx2) {
  813. $1=_st(chunk)._isEmpty();
  814. if(smalltalk.assert($1)){
  815. lastEmpty=true;
  816. return lastEmpty;
  817. } else {
  818. result=_st(_st($Compiler())._new())._evaluateExpression_(chunk);
  819. result;
  820. $2=lastEmpty;
  821. if(smalltalk.assert($2)){
  822. lastEmpty=false;
  823. lastEmpty;
  824. return _st(result)._scanFrom_(parser);
  825. };
  826. };
  827. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  828. return self}, function($ctx1) {$ctx1.fill(self,"import:",{aStream:aStream,chunk:chunk,result:result,parser:parser,lastEmpty:lastEmpty},smalltalk.Importer)})},
  829. args: ["aStream"],
  830. 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]]]",
  831. messageSends: ["on:", "whileFalse:", "ifTrue:ifFalse:", "evaluateExpression:", "new", "ifTrue:", "scanFrom:", "isEmpty", "nextChunk", "isNil"],
  832. referencedClasses: ["ChunkParser", "Compiler"]
  833. }),
  834. smalltalk.Importer);
  835. smalltalk.addClass('PackageHandler', smalltalk.Object, [], 'Importer-Exporter');
  836. 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.";
  837. smalltalk.addMethod(
  838. smalltalk.method({
  839. selector: "ajaxPutAt:data:",
  840. category: 'private',
  841. fn: function (aURL,aString){
  842. var self=this;
  843. return smalltalk.withContext(function($ctx1) {
  844. _st(jQuery)._ajax_options_(aURL,smalltalk.HashedCollection._from_(["type".__minus_gt("PUT"),"data".__minus_gt(aString),"contentType".__minus_gt("text/plain;charset=UTF-8"),"error".__minus_gt((function(xhr){
  845. return smalltalk.withContext(function($ctx2) {
  846. return self._error_(_st(_st(_st("Commiting ".__comma(aURL)).__comma(" failed with reason: \x22")).__comma(_st(xhr)._responseText())).__comma("\x22"));
  847. }, function($ctx2) {$ctx2.fillBlock({xhr:xhr},$ctx1)})}))]));
  848. return self}, function($ctx1) {$ctx1.fill(self,"ajaxPutAt:data:",{aURL:aURL,aString:aString},smalltalk.PackageHandler)})},
  849. args: ["aURL", "aString"],
  850. source: "ajaxPutAt: aURL data: aString\x0a\x09jQuery\x0a\x09\x09ajax: aURL \x0a\x09\x09options: #{ \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'] }",
  851. messageSends: ["ajax:options:", "->", "error:", ",", "responseText"],
  852. referencedClasses: []
  853. }),
  854. smalltalk.PackageHandler);
  855. smalltalk.addMethod(
  856. smalltalk.method({
  857. selector: "commit:",
  858. category: 'committing',
  859. fn: function (aPackage){
  860. var self=this;
  861. function $Exporter(){return smalltalk.Exporter||(typeof Exporter=="undefined"?nil:Exporter)}
  862. function $StrippedExporter(){return smalltalk.StrippedExporter||(typeof StrippedExporter=="undefined"?nil:StrippedExporter)}
  863. function $ChunkExporter(){return smalltalk.ChunkExporter||(typeof ChunkExporter=="undefined"?nil:ChunkExporter)}
  864. return smalltalk.withContext(function($ctx1) {
  865. _st([_st($Exporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathJs()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".js")),_st($StrippedExporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathJs()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".deploy.js")),_st($ChunkExporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathSt()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".st"))])._do_displayingProgress_((function(commitStrategy){
  866. var fileContents;
  867. return smalltalk.withContext(function($ctx2) {
  868. fileContents=_st(_st(_st(commitStrategy)._key())._new())._exportPackage_(_st(aPackage)._name());
  869. fileContents;
  870. return self._ajaxPutAt_data_(_st(commitStrategy)._value(),fileContents);
  871. }, function($ctx2) {$ctx2.fillBlock({commitStrategy:commitStrategy,fileContents:fileContents},$ctx1)})}),"Committing package ".__comma(_st(aPackage)._name()));
  872. return self}, function($ctx1) {$ctx1.fill(self,"commit:",{aPackage:aPackage},smalltalk.PackageHandler)})},
  873. args: ["aPackage"],
  874. source: "commit: aPackage\x0a\x09{ \x0a\x09\x09Exporter -> (aPackage commitPathJs, '/', aPackage name, '.js').\x0a\x09\x09StrippedExporter -> (aPackage commitPathJs, '/', aPackage name, '.deploy.js').\x0a\x09\x09ChunkExporter -> (aPackage commitPathSt, '/', aPackage name, '.st')\x0a\x09} \x0a\x09\x09do: [ :commitStrategy|| fileContents |\x0a\x09\x09\x09fileContents := (commitStrategy key new exportPackage: aPackage name).\x0a\x09\x09\x09self ajaxPutAt: commitStrategy value data: fileContents ]\x0a\x09\x09displayingProgress: 'Committing package ', aPackage name",
  875. messageSends: ["do:displayingProgress:", "exportPackage:", "name", "new", "key", "ajaxPutAt:data:", "value", ",", "->", "commitPathJs", "commitPathSt"],
  876. referencedClasses: ["Exporter", "StrippedExporter", "ChunkExporter"]
  877. }),
  878. smalltalk.PackageHandler);
  879. smalltalk.addMethod(
  880. smalltalk.method({
  881. selector: "loadPackage:prefix:",
  882. category: 'loading',
  883. fn: function (packageName,aString){
  884. var self=this;
  885. var url;
  886. return smalltalk.withContext(function($ctx1) {
  887. var $1;
  888. url=_st(_st(_st("/".__comma(aString)).__comma("/js/")).__comma(packageName)).__comma(".js");
  889. _st(jQuery)._ajax_options_(url,smalltalk.HashedCollection._from_(["type".__minus_gt("GET"),"dataType".__minus_gt("script"),"complete".__minus_gt((function(jqXHR,textStatus){
  890. return smalltalk.withContext(function($ctx2) {
  891. $1=_st(_st(jqXHR)._readyState()).__eq((4));
  892. if(smalltalk.assert($1)){
  893. return self._setupPackageNamed_prefix_(packageName,aString);
  894. };
  895. }, function($ctx2) {$ctx2.fillBlock({jqXHR:jqXHR,textStatus:textStatus},$ctx1)})})),"error".__minus_gt((function(){
  896. return smalltalk.withContext(function($ctx2) {
  897. return _st(window)._alert_("Could not load package at: ".__comma(url));
  898. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))]));
  899. return self}, function($ctx1) {$ctx1.fill(self,"loadPackage:prefix:",{packageName:packageName,aString:aString,url:url},smalltalk.PackageHandler)})},
  900. args: ["packageName", "aString"],
  901. source: "loadPackage: packageName prefix: aString\x0a\x09| url |\x0a\x09url := '/', aString, '/js/', packageName, '.js'.\x0a\x09jQuery\x0a\x09\x09ajax: url\x0a\x09\x09options: #{\x0a\x09\x09\x09'type' -> 'GET'.\x0a\x09\x09\x09'dataType' -> 'script'.\x0a\x09\x09\x09'complete' -> [ :jqXHR :textStatus |\x0a\x09\x09\x09\x09jqXHR readyState = 4\x0a\x09\x09\x09\x09\x09ifTrue: [ self setupPackageNamed: packageName prefix: aString ] ].\x0a\x09\x09\x09'error' -> [ window alert: 'Could not load package at: ', url ]\x0a\x09\x09}",
  902. messageSends: [",", "ajax:options:", "->", "ifTrue:", "setupPackageNamed:prefix:", "=", "readyState", "alert:"],
  903. referencedClasses: []
  904. }),
  905. smalltalk.PackageHandler);
  906. smalltalk.addMethod(
  907. smalltalk.method({
  908. selector: "loadPackages:prefix:",
  909. category: 'loading',
  910. fn: function (aCollection,aString){
  911. var self=this;
  912. return smalltalk.withContext(function($ctx1) {
  913. _st(aCollection)._do_((function(each){
  914. return smalltalk.withContext(function($ctx2) {
  915. return self._loadPackage_prefix_(each,aString);
  916. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  917. return self}, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.PackageHandler)})},
  918. args: ["aCollection", "aString"],
  919. source: "loadPackages: aCollection prefix: aString\x0a\x09aCollection do: [ :each |\x0a\x09\x09self loadPackage: each prefix: aString ]",
  920. messageSends: ["do:", "loadPackage:prefix:"],
  921. referencedClasses: []
  922. }),
  923. smalltalk.PackageHandler);
  924. smalltalk.addMethod(
  925. smalltalk.method({
  926. selector: "setupPackageNamed:prefix:",
  927. category: 'private',
  928. fn: function (packageName,aString){
  929. var self=this;
  930. function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
  931. return smalltalk.withContext(function($ctx1) {
  932. var $1,$2;
  933. $1=_st($Package())._named_(packageName);
  934. _st($1)._setupClasses();
  935. _st($1)._commitPathJs_(_st("/".__comma(aString)).__comma("/js"));
  936. $2=_st($1)._commitPathSt_(_st("/".__comma(aString)).__comma("/st"));
  937. return self}, function($ctx1) {$ctx1.fill(self,"setupPackageNamed:prefix:",{packageName:packageName,aString:aString},smalltalk.PackageHandler)})},
  938. args: ["packageName", "aString"],
  939. source: "setupPackageNamed: packageName prefix: aString\x0a\x0a\x09(Package named: packageName)\x0a\x09\x09setupClasses;\x0a\x09\x09commitPathJs: '/', aString, '/js';\x0a\x09\x09commitPathSt: '/', aString, '/st'",
  940. messageSends: ["setupClasses", "named:", "commitPathJs:", ",", "commitPathSt:"],
  941. referencedClasses: ["Package"]
  942. }),
  943. smalltalk.PackageHandler);
  944. smalltalk.addMethod(
  945. smalltalk.method({
  946. selector: "loadPackages:prefix:",
  947. category: 'loading',
  948. fn: function (aCollection,aString){
  949. var self=this;
  950. return smalltalk.withContext(function($ctx1) {
  951. var $1;
  952. $1=_st(self._new())._loadPackages_prefix_(aCollection,aString);
  953. return $1;
  954. }, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.PackageHandler.klass)})},
  955. args: ["aCollection", "aString"],
  956. source: "loadPackages: aCollection prefix: aString\x0a\x09^ self new loadPackages: aCollection prefix: aString",
  957. messageSends: ["loadPackages:prefix:", "new"],
  958. referencedClasses: []
  959. }),
  960. smalltalk.PackageHandler.klass);
  961. smalltalk.addMethod(
  962. smalltalk.method({
  963. selector: "commit",
  964. category: '*Importer-Exporter',
  965. fn: function (){
  966. var self=this;
  967. function $PackageHandler(){return smalltalk.PackageHandler||(typeof PackageHandler=="undefined"?nil:PackageHandler)}
  968. return smalltalk.withContext(function($ctx1) {
  969. var $1;
  970. $1=_st(_st($PackageHandler())._new())._commit_(self);
  971. return $1;
  972. }, function($ctx1) {$ctx1.fill(self,"commit",{},smalltalk.Package)})},
  973. args: [],
  974. source: "commit\x0a\x09^ PackageHandler new commit: self",
  975. messageSends: ["commit:", "new"],
  976. referencedClasses: ["PackageHandler"]
  977. }),
  978. smalltalk.Package);
  979. });