Importer-Exporter.js 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025
  1. define(["smalltalk","nil","_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. self._exportPackagePrologueOn_(stream);
  311. return _st((function(){
  312. return smalltalk.withContext(function($ctx3) {
  313. package_=_st(_st($Smalltalk())._current())._packageAt_(packageName);
  314. package_;
  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\x09self exportPackagePrologueOn: stream.\x0a\x09\x09[\x0a\x09\x09\x09package := Smalltalk current packageAt: packageName.\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:", "exportPackagePrologueOn:", "ensure:", "exportPackageEpilogueOn:", "packageAt:", "current", "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: "exportPackagePrologueOn:",
  409. category: 'private',
  410. fn: function (aStream){
  411. var self=this;
  412. return smalltalk.withContext(function($ctx1) {
  413. var $1,$2;
  414. $1=aStream;
  415. _st($1)._nextPutAll_("define([\x22smalltalk\x22,\x22nil\x22,\x22_st\x22], function(smalltalk,nil,_st){");
  416. $2=_st($1)._lf();
  417. return self}, function($ctx1) {$ctx1.fill(self,"exportPackagePrologueOn:",{aStream:aStream},smalltalk.Exporter)})},
  418. args: ["aStream"],
  419. source: "exportPackagePrologueOn: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: 'define([\x22smalltalk\x22,\x22nil\x22,\x22_st\x22], function(smalltalk,nil,_st){';\x0a\x09\x09lf",
  420. messageSends: ["nextPutAll:", "lf"],
  421. referencedClasses: []
  422. }),
  423. smalltalk.Exporter);
  424. smalltalk.addClass('ChunkExporter', smalltalk.Exporter, [], 'Importer-Exporter');
  425. 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.";
  426. smalltalk.addMethod(
  427. smalltalk.method({
  428. selector: "chunkEscape:",
  429. category: 'private',
  430. fn: function (aString){
  431. var self=this;
  432. return smalltalk.withContext(function($ctx1) {
  433. var $1;
  434. $1=_st(_st(aString)._replace_with_("!","!!"))._trimBoth();
  435. return $1;
  436. }, function($ctx1) {$ctx1.fill(self,"chunkEscape:",{aString:aString},smalltalk.ChunkExporter)})},
  437. args: ["aString"],
  438. source: "chunkEscape: aString\x0a\x09\x22Replace all occurrences of ! with !! and trim at both ends.\x22\x0a\x0a\x09^(aString replace: '!' with: '!!') trimBoth",
  439. messageSends: ["trimBoth", "replace:with:"],
  440. referencedClasses: []
  441. }),
  442. smalltalk.ChunkExporter);
  443. smalltalk.addMethod(
  444. smalltalk.method({
  445. selector: "classNameFor:",
  446. category: 'private',
  447. fn: function (aClass){
  448. var self=this;
  449. return smalltalk.withContext(function($ctx1) {
  450. var $2,$3,$1;
  451. $2=_st(aClass)._isMetaclass();
  452. if(smalltalk.assert($2)){
  453. $1=_st(_st(_st(aClass)._instanceClass())._name()).__comma(" class");
  454. } else {
  455. $3=_st(aClass)._isNil();
  456. if(smalltalk.assert($3)){
  457. $1="nil";
  458. } else {
  459. $1=_st(aClass)._name();
  460. };
  461. };
  462. return $1;
  463. }, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},smalltalk.ChunkExporter)})},
  464. args: ["aClass"],
  465. 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]]",
  466. messageSends: ["ifTrue:ifFalse:", ",", "name", "instanceClass", "isNil", "isMetaclass"],
  467. referencedClasses: []
  468. }),
  469. smalltalk.ChunkExporter);
  470. smalltalk.addMethod(
  471. smalltalk.method({
  472. selector: "exportDefinitionOf:on:",
  473. category: 'private',
  474. fn: function (aClass,aStream){
  475. var self=this;
  476. return smalltalk.withContext(function($ctx1) {
  477. var $1,$2,$3,$4,$5,$6,$7;
  478. $1=aStream;
  479. _st($1)._nextPutAll_(self._classNameFor_(_st(aClass)._superclass()));
  480. _st($1)._nextPutAll_(" subclass: #".__comma(self._classNameFor_(aClass)));
  481. _st($1)._lf();
  482. _st($1)._tab();
  483. $2=_st($1)._nextPutAll_("instanceVariableNames: '");
  484. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  485. return smalltalk.withContext(function($ctx2) {
  486. return _st(aStream)._nextPutAll_(each);
  487. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  488. return smalltalk.withContext(function($ctx2) {
  489. return _st(aStream)._nextPutAll_(" ");
  490. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  491. $3=aStream;
  492. _st($3)._nextPutAll_("'");
  493. _st($3)._lf();
  494. _st($3)._tab();
  495. _st($3)._nextPutAll_(_st("package: '".__comma(_st(aClass)._category())).__comma("'!"));
  496. $4=_st($3)._lf();
  497. $5=_st(_st(aClass)._comment())._notEmpty();
  498. if(smalltalk.assert($5)){
  499. $6=aStream;
  500. _st($6)._nextPutAll_(_st("!".__comma(self._classNameFor_(aClass))).__comma(" commentStamp!"));
  501. _st($6)._lf();
  502. _st($6)._nextPutAll_(_st(self._chunkEscape_(_st(aClass)._comment())).__comma("!"));
  503. $7=_st($6)._lf();
  504. $7;
  505. };
  506. _st(aStream)._lf();
  507. return self}, function($ctx1) {$ctx1.fill(self,"exportDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
  508. args: ["aClass", "aStream"],
  509. 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",
  510. messageSends: ["nextPutAll:", "classNameFor:", "superclass", ",", "lf", "tab", "do:separatedBy:", "instanceVariableNames", "category", "ifTrue:", "chunkEscape:", "comment", "notEmpty"],
  511. referencedClasses: []
  512. }),
  513. smalltalk.ChunkExporter);
  514. smalltalk.addMethod(
  515. smalltalk.method({
  516. selector: "exportMetaDefinitionOf:on:",
  517. category: 'private',
  518. fn: function (aClass,aStream){
  519. var self=this;
  520. return smalltalk.withContext(function($ctx1) {
  521. var $1,$2,$3,$4,$5;
  522. $1=_st(_st(_st(aClass)._class())._instanceVariableNames())._isEmpty();
  523. if(! smalltalk.assert($1)){
  524. $2=aStream;
  525. _st($2)._nextPutAll_(self._classNameFor_(_st(aClass)._class()));
  526. $3=_st($2)._nextPutAll_(" instanceVariableNames: '");
  527. $3;
  528. _st(_st(_st(aClass)._class())._instanceVariableNames())._do_separatedBy_((function(each){
  529. return smalltalk.withContext(function($ctx2) {
  530. return _st(aStream)._nextPutAll_(each);
  531. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  532. return smalltalk.withContext(function($ctx2) {
  533. return _st(aStream)._nextPutAll_(" ");
  534. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  535. $4=aStream;
  536. _st($4)._nextPutAll_("'!");
  537. _st($4)._lf();
  538. $5=_st($4)._lf();
  539. $5;
  540. };
  541. return self}, function($ctx1) {$ctx1.fill(self,"exportMetaDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
  542. args: ["aClass", "aStream"],
  543. 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]",
  544. messageSends: ["ifFalse:", "nextPutAll:", "classNameFor:", "class", "do:separatedBy:", "instanceVariableNames", "lf", "isEmpty"],
  545. referencedClasses: []
  546. }),
  547. smalltalk.ChunkExporter);
  548. smalltalk.addMethod(
  549. smalltalk.method({
  550. selector: "exportMethod:of:on:",
  551. category: 'private',
  552. fn: function (aMethod,aClass,aStream){
  553. var self=this;
  554. return smalltalk.withContext(function($ctx1) {
  555. var $1,$2;
  556. $1=aStream;
  557. _st($1)._lf();
  558. _st($1)._lf();
  559. _st($1)._nextPutAll_(self._chunkEscape_(_st(aMethod)._source()));
  560. _st($1)._lf();
  561. $2=_st($1)._nextPutAll_("!");
  562. return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:of:on:",{aMethod:aMethod,aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
  563. args: ["aMethod", "aClass", "aStream"],
  564. source: "exportMethod: aMethod of: aClass on: aStream\x0a\x09aStream\x0a\x09\x09lf; lf; nextPutAll: (self chunkEscape: aMethod source); lf;\x0a\x09\x09nextPutAll: '!'",
  565. messageSends: ["lf", "nextPutAll:", "chunkEscape:", "source"],
  566. referencedClasses: []
  567. }),
  568. smalltalk.ChunkExporter);
  569. smalltalk.addMethod(
  570. smalltalk.method({
  571. selector: "exportMethods:category:of:on:",
  572. category: 'private',
  573. fn: function (methods,category,aClass,aStream){
  574. var self=this;
  575. return smalltalk.withContext(function($ctx1) {
  576. var $1,$2,$3,$4;
  577. $1=aStream;
  578. _st($1)._nextPutAll_("!".__comma(self._classNameFor_(aClass)));
  579. $2=_st($1)._nextPutAll_(_st(" methodsFor: '".__comma(category)).__comma("'!"));
  580. _st(_st(methods)._sorted_((function(a,b){
  581. return smalltalk.withContext(function($ctx2) {
  582. return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  583. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})})))._do_((function(each){
  584. return smalltalk.withContext(function($ctx2) {
  585. return self._exportMethod_of_on_(each,aClass,aStream);
  586. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  587. $3=aStream;
  588. _st($3)._nextPutAll_(" !");
  589. _st($3)._lf();
  590. $4=_st($3)._lf();
  591. return self}, function($ctx1) {$ctx1.fill(self,"exportMethods:category:of:on:",{methods:methods,category:category,aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
  592. args: ["methods", "category", "aClass", "aStream"],
  593. 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",
  594. messageSends: ["nextPutAll:", ",", "classNameFor:", "do:", "exportMethod:of:on:", "sorted:", "<=", "selector", "lf"],
  595. referencedClasses: []
  596. }),
  597. smalltalk.ChunkExporter);
  598. smalltalk.addMethod(
  599. smalltalk.method({
  600. selector: "exportMethodsOf:on:",
  601. category: 'private',
  602. fn: function (aClass,aStream){
  603. var self=this;
  604. var map;
  605. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  606. return smalltalk.withContext(function($ctx1) {
  607. var $1;
  608. map=_st($Dictionary())._new();
  609. _st(aClass)._protocolsDo_((function(category,methods){
  610. return smalltalk.withContext(function($ctx2) {
  611. $1=_st(category)._match_("^\x5c*");
  612. if(! smalltalk.assert($1)){
  613. return _st(map)._at_put_(category,methods);
  614. };
  615. }, function($ctx2) {$ctx2.fillBlock({category:category,methods:methods},$ctx1)})}));
  616. _st(_st(_st(map)._keys())._sorted_((function(a,b){
  617. return smalltalk.withContext(function($ctx2) {
  618. return _st(a).__lt_eq(b);
  619. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})})))._do_((function(category){
  620. var methods;
  621. return smalltalk.withContext(function($ctx2) {
  622. methods=_st(map)._at_(category);
  623. methods;
  624. return self._exportMethods_category_of_on_(methods,category,aClass,aStream);
  625. }, function($ctx2) {$ctx2.fillBlock({category:category,methods:methods},$ctx1)})}));
  626. return self}, function($ctx1) {$ctx1.fill(self,"exportMethodsOf:on:",{aClass:aClass,aStream:aStream,map:map},smalltalk.ChunkExporter)})},
  627. args: ["aClass", "aStream"],
  628. 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 ]",
  629. messageSends: ["new", "protocolsDo:", "ifFalse:", "at:put:", "match:", "do:", "at:", "exportMethods:category:of:on:", "sorted:", "<=", "keys"],
  630. referencedClasses: ["Dictionary"]
  631. }),
  632. smalltalk.ChunkExporter);
  633. smalltalk.addMethod(
  634. smalltalk.method({
  635. selector: "exportPackageDefinitionOf:on:",
  636. category: 'private',
  637. fn: function (package_,aStream){
  638. var self=this;
  639. return smalltalk.withContext(function($ctx1) {
  640. var $1,$2;
  641. $1=aStream;
  642. _st($1)._nextPutAll_(_st("Smalltalk current createPackage: '".__comma(_st(package_)._name())).__comma("'!"));
  643. $2=_st($1)._lf();
  644. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageDefinitionOf:on:",{package_:package_,aStream:aStream},smalltalk.ChunkExporter)})},
  645. args: ["package", "aStream"],
  646. source: "exportPackageDefinitionOf: package on: aStream\x0a\x09\x22Chunk format.\x22\x0a\x0a\x09aStream\x0a\x09\x09nextPutAll: 'Smalltalk current createPackage: ''', package name, '''!';\x0a\x09\x09lf",
  647. messageSends: ["nextPutAll:", ",", "name", "lf"],
  648. referencedClasses: []
  649. }),
  650. smalltalk.ChunkExporter);
  651. smalltalk.addMethod(
  652. smalltalk.method({
  653. selector: "exportPackageEpilogueOn:",
  654. category: 'private',
  655. fn: function (aStream){
  656. var self=this;
  657. return smalltalk.withContext(function($ctx1) {
  658. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageEpilogueOn:",{aStream:aStream},smalltalk.ChunkExporter)})},
  659. args: ["aStream"],
  660. source: "exportPackageEpilogueOn: aStream",
  661. messageSends: [],
  662. referencedClasses: []
  663. }),
  664. smalltalk.ChunkExporter);
  665. smalltalk.addMethod(
  666. smalltalk.method({
  667. selector: "exportPackageExtensionsOf:on:",
  668. category: 'private',
  669. fn: function (package_,aStream){
  670. var self=this;
  671. var name,map;
  672. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  673. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  674. function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
  675. return smalltalk.withContext(function($ctx1) {
  676. var $1;
  677. name=_st(package_)._name();
  678. _st(_st($Package())._sortedClasses_(_st(_st($Smalltalk())._current())._classes()))._do_((function(each){
  679. return smalltalk.withContext(function($ctx2) {
  680. return _st([each,_st(each)._class()])._do_((function(aClass){
  681. return smalltalk.withContext(function($ctx3) {
  682. map=_st($Dictionary())._new();
  683. map;
  684. _st(aClass)._protocolsDo_((function(category,methods){
  685. return smalltalk.withContext(function($ctx4) {
  686. $1=_st(category)._match_("^\x5c*".__comma(name));
  687. if(smalltalk.assert($1)){
  688. return _st(map)._at_put_(category,methods);
  689. };
  690. }, function($ctx4) {$ctx4.fillBlock({category:category,methods:methods},$ctx3)})}));
  691. return _st(_st(_st(map)._keys())._sorted_((function(a,b){
  692. return smalltalk.withContext(function($ctx4) {
  693. return _st(a).__lt_eq(b);
  694. }, function($ctx4) {$ctx4.fillBlock({a:a,b:b},$ctx3)})})))._do_((function(category){
  695. var methods;
  696. return smalltalk.withContext(function($ctx4) {
  697. methods=_st(map)._at_(category);
  698. methods;
  699. return self._exportMethods_category_of_on_(methods,category,aClass,aStream);
  700. }, function($ctx4) {$ctx4.fillBlock({category:category,methods:methods},$ctx3)})}));
  701. }, function($ctx3) {$ctx3.fillBlock({aClass:aClass},$ctx2)})}));
  702. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  703. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageExtensionsOf:on:",{package_:package_,aStream:aStream,name:name,map:map},smalltalk.ChunkExporter)})},
  704. args: ["package", "aStream"],
  705. 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 ]]]",
  706. messageSends: ["name", "do:", "new", "protocolsDo:", "ifTrue:", "at:put:", "match:", ",", "at:", "exportMethods:category:of:on:", "sorted:", "<=", "keys", "class", "sortedClasses:", "classes", "current"],
  707. referencedClasses: ["Dictionary", "Smalltalk", "Package"]
  708. }),
  709. smalltalk.ChunkExporter);
  710. smalltalk.addMethod(
  711. smalltalk.method({
  712. selector: "exportPackagePrologueOn:",
  713. category: 'private',
  714. fn: function (aStream){
  715. var self=this;
  716. return smalltalk.withContext(function($ctx1) {
  717. return self}, function($ctx1) {$ctx1.fill(self,"exportPackagePrologueOn:",{aStream:aStream},smalltalk.ChunkExporter)})},
  718. args: ["aStream"],
  719. source: "exportPackagePrologueOn: aStream",
  720. messageSends: [],
  721. referencedClasses: []
  722. }),
  723. smalltalk.ChunkExporter);
  724. smalltalk.addClass('StrippedExporter', smalltalk.Exporter, [], 'Importer-Exporter');
  725. smalltalk.StrippedExporter.comment="I export Amber code into a JavaScript string, but without any optional associated data like the Amber source code.";
  726. smalltalk.addMethod(
  727. smalltalk.method({
  728. selector: "exportDefinitionOf:on:",
  729. category: 'private',
  730. fn: function (aClass,aStream){
  731. var self=this;
  732. return smalltalk.withContext(function($ctx1) {
  733. var $1,$2,$3,$4;
  734. $1=aStream;
  735. _st($1)._nextPutAll_("smalltalk.addClass(");
  736. _st($1)._nextPutAll_(_st("'".__comma(self._classNameFor_(aClass))).__comma("', "));
  737. _st($1)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aClass)._superclass())));
  738. $2=_st($1)._nextPutAll_(", [");
  739. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  740. return smalltalk.withContext(function($ctx2) {
  741. return _st(aStream)._nextPutAll_(_st("'".__comma(each)).__comma("'"));
  742. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  743. return smalltalk.withContext(function($ctx2) {
  744. return _st(aStream)._nextPutAll_(", ");
  745. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  746. $3=aStream;
  747. _st($3)._nextPutAll_("], '");
  748. _st($3)._nextPutAll_(_st(_st(aClass)._category()).__comma("'"));
  749. $4=_st($3)._nextPutAll_(");");
  750. _st(aStream)._lf();
  751. return self}, function($ctx1) {$ctx1.fill(self,"exportDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.StrippedExporter)})},
  752. args: ["aClass", "aStream"],
  753. 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",
  754. messageSends: ["nextPutAll:", ",", "classNameFor:", "superclass", "do:separatedBy:", "instanceVariableNames", "category", "lf"],
  755. referencedClasses: []
  756. }),
  757. smalltalk.StrippedExporter);
  758. smalltalk.addMethod(
  759. smalltalk.method({
  760. selector: "exportMethod:of:on:",
  761. category: 'private',
  762. fn: function (aMethod,aClass,aStream){
  763. var self=this;
  764. return smalltalk.withContext(function($ctx1) {
  765. var $1,$2;
  766. $1=aStream;
  767. _st($1)._nextPutAll_("smalltalk.addMethod(");
  768. _st($1)._lf();
  769. _st($1)._nextPutAll_("smalltalk.method({");
  770. _st($1)._lf();
  771. _st($1)._nextPutAll_(_st("selector: ".__comma(_st(_st(aMethod)._selector())._asJavascript())).__comma(","));
  772. _st($1)._lf();
  773. _st($1)._nextPutAll_(_st("fn: ".__comma(_st(_st(aMethod)._fn())._compiledSource())).__comma(","));
  774. _st($1)._lf();
  775. _st($1)._nextPutAll_("messageSends: ".__comma(_st(_st(aMethod)._messageSends())._asJavascript()));
  776. _st($1)._nextPutAll_("}),");
  777. _st($1)._lf();
  778. _st($1)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(aClass)));
  779. _st($1)._nextPutAll_(");");
  780. _st($1)._lf();
  781. $2=_st($1)._lf();
  782. return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:of:on:",{aMethod:aMethod,aClass:aClass,aStream:aStream},smalltalk.StrippedExporter)})},
  783. args: ["aMethod", "aClass", "aStream"],
  784. 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",
  785. messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "selector", "compiledSource", "fn", "messageSends", "classNameFor:"],
  786. referencedClasses: []
  787. }),
  788. smalltalk.StrippedExporter);
  789. smalltalk.addClass('Importer', smalltalk.Object, [], 'Importer-Exporter');
  790. smalltalk.Importer.comment="I can import Amber code from a string in the chunk format.\x0a\x0a## API\x0a\x0a Importer new import: aString";
  791. smalltalk.addMethod(
  792. smalltalk.method({
  793. selector: "import:",
  794. category: 'fileIn',
  795. fn: function (aStream){
  796. var self=this;
  797. var chunk,result,parser,lastEmpty;
  798. function $ChunkParser(){return smalltalk.ChunkParser||(typeof ChunkParser=="undefined"?nil:ChunkParser)}
  799. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  800. return smalltalk.withContext(function($ctx1) {
  801. var $1,$2;
  802. parser=_st($ChunkParser())._on_(aStream);
  803. lastEmpty=false;
  804. _st((function(){
  805. return smalltalk.withContext(function($ctx2) {
  806. chunk=_st(parser)._nextChunk();
  807. chunk;
  808. return _st(chunk)._isNil();
  809. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
  810. return smalltalk.withContext(function($ctx2) {
  811. $1=_st(chunk)._isEmpty();
  812. if(smalltalk.assert($1)){
  813. lastEmpty=true;
  814. return lastEmpty;
  815. } else {
  816. result=_st(_st($Compiler())._new())._evaluateExpression_(chunk);
  817. result;
  818. $2=lastEmpty;
  819. if(smalltalk.assert($2)){
  820. lastEmpty=false;
  821. lastEmpty;
  822. return _st(result)._scanFrom_(parser);
  823. };
  824. };
  825. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  826. return self}, function($ctx1) {$ctx1.fill(self,"import:",{aStream:aStream,chunk:chunk,result:result,parser:parser,lastEmpty:lastEmpty},smalltalk.Importer)})},
  827. args: ["aStream"],
  828. 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]]]",
  829. messageSends: ["on:", "whileFalse:", "ifTrue:ifFalse:", "evaluateExpression:", "new", "ifTrue:", "scanFrom:", "isEmpty", "nextChunk", "isNil"],
  830. referencedClasses: ["ChunkParser", "Compiler"]
  831. }),
  832. smalltalk.Importer);
  833. smalltalk.addClass('PackageHandler', smalltalk.Object, [], 'Importer-Exporter');
  834. 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.";
  835. smalltalk.addMethod(
  836. smalltalk.method({
  837. selector: "ajaxPutAt:data:",
  838. category: 'private',
  839. fn: function (aURL,aString){
  840. var self=this;
  841. return smalltalk.withContext(function($ctx1) {
  842. _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){
  843. return smalltalk.withContext(function($ctx2) {
  844. return self._error_(_st(_st(_st("Commiting ".__comma(aURL)).__comma(" failed with reason: \x22")).__comma(_st(xhr)._responseText())).__comma("\x22"));
  845. }, function($ctx2) {$ctx2.fillBlock({xhr:xhr},$ctx1)})}))]));
  846. return self}, function($ctx1) {$ctx1.fill(self,"ajaxPutAt:data:",{aURL:aURL,aString:aString},smalltalk.PackageHandler)})},
  847. args: ["aURL", "aString"],
  848. 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'] }",
  849. messageSends: ["ajax:options:", "->", "error:", ",", "responseText"],
  850. referencedClasses: []
  851. }),
  852. smalltalk.PackageHandler);
  853. smalltalk.addMethod(
  854. smalltalk.method({
  855. selector: "commit:",
  856. category: 'committing',
  857. fn: function (aPackage){
  858. var self=this;
  859. function $Exporter(){return smalltalk.Exporter||(typeof Exporter=="undefined"?nil:Exporter)}
  860. function $StrippedExporter(){return smalltalk.StrippedExporter||(typeof StrippedExporter=="undefined"?nil:StrippedExporter)}
  861. function $ChunkExporter(){return smalltalk.ChunkExporter||(typeof ChunkExporter=="undefined"?nil:ChunkExporter)}
  862. return smalltalk.withContext(function($ctx1) {
  863. _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){
  864. var fileContents;
  865. return smalltalk.withContext(function($ctx2) {
  866. fileContents=_st(_st(_st(commitStrategy)._key())._new())._exportPackage_(_st(aPackage)._name());
  867. fileContents;
  868. return self._ajaxPutAt_data_(_st(commitStrategy)._value(),fileContents);
  869. }, function($ctx2) {$ctx2.fillBlock({commitStrategy:commitStrategy,fileContents:fileContents},$ctx1)})}),"Committing package ".__comma(_st(aPackage)._name()));
  870. return self}, function($ctx1) {$ctx1.fill(self,"commit:",{aPackage:aPackage},smalltalk.PackageHandler)})},
  871. args: ["aPackage"],
  872. 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",
  873. messageSends: ["do:displayingProgress:", "exportPackage:", "name", "new", "key", "ajaxPutAt:data:", "value", ",", "->", "commitPathJs", "commitPathSt"],
  874. referencedClasses: ["Exporter", "StrippedExporter", "ChunkExporter"]
  875. }),
  876. smalltalk.PackageHandler);
  877. smalltalk.addMethod(
  878. smalltalk.method({
  879. selector: "loadPackage:prefix:",
  880. category: 'loading',
  881. fn: function (packageName,aString){
  882. var self=this;
  883. var url;
  884. return smalltalk.withContext(function($ctx1) {
  885. var $1;
  886. url=_st(_st(_st("/".__comma(aString)).__comma("/js/")).__comma(packageName)).__comma(".js");
  887. _st(jQuery)._ajax_options_(url,smalltalk.HashedCollection._from_(["type".__minus_gt("GET"),"dataType".__minus_gt("script"),"complete".__minus_gt((function(jqXHR,textStatus){
  888. return smalltalk.withContext(function($ctx2) {
  889. $1=_st(_st(jqXHR)._readyState()).__eq((4));
  890. if(smalltalk.assert($1)){
  891. return self._setupPackageNamed_prefix_(packageName,aString);
  892. };
  893. }, function($ctx2) {$ctx2.fillBlock({jqXHR:jqXHR,textStatus:textStatus},$ctx1)})})),"error".__minus_gt((function(){
  894. return smalltalk.withContext(function($ctx2) {
  895. return _st(window)._alert_("Could not load package at: ".__comma(url));
  896. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))]));
  897. return self}, function($ctx1) {$ctx1.fill(self,"loadPackage:prefix:",{packageName:packageName,aString:aString,url:url},smalltalk.PackageHandler)})},
  898. args: ["packageName", "aString"],
  899. 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}",
  900. messageSends: [",", "ajax:options:", "->", "ifTrue:", "setupPackageNamed:prefix:", "=", "readyState", "alert:"],
  901. referencedClasses: []
  902. }),
  903. smalltalk.PackageHandler);
  904. smalltalk.addMethod(
  905. smalltalk.method({
  906. selector: "loadPackages:prefix:",
  907. category: 'loading',
  908. fn: function (aCollection,aString){
  909. var self=this;
  910. return smalltalk.withContext(function($ctx1) {
  911. _st(aCollection)._do_((function(each){
  912. return smalltalk.withContext(function($ctx2) {
  913. return self._loadPackage_prefix_(each,aString);
  914. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  915. return self}, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.PackageHandler)})},
  916. args: ["aCollection", "aString"],
  917. source: "loadPackages: aCollection prefix: aString\x0a\x09aCollection do: [ :each |\x0a\x09\x09self loadPackage: each prefix: aString ]",
  918. messageSends: ["do:", "loadPackage:prefix:"],
  919. referencedClasses: []
  920. }),
  921. smalltalk.PackageHandler);
  922. smalltalk.addMethod(
  923. smalltalk.method({
  924. selector: "setupPackageNamed:prefix:",
  925. category: 'private',
  926. fn: function (packageName,aString){
  927. var self=this;
  928. function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
  929. return smalltalk.withContext(function($ctx1) {
  930. var $1,$2;
  931. $1=_st($Package())._named_(packageName);
  932. _st($1)._setupClasses();
  933. _st($1)._commitPathJs_(_st("/".__comma(aString)).__comma("/js"));
  934. $2=_st($1)._commitPathSt_(_st("/".__comma(aString)).__comma("/st"));
  935. return self}, function($ctx1) {$ctx1.fill(self,"setupPackageNamed:prefix:",{packageName:packageName,aString:aString},smalltalk.PackageHandler)})},
  936. args: ["packageName", "aString"],
  937. source: "setupPackageNamed: packageName prefix: aString\x0a\x0a\x09(Package named: packageName)\x0a\x09\x09setupClasses;\x0a\x09\x09commitPathJs: '/', aString, '/js';\x0a\x09\x09commitPathSt: '/', aString, '/st'",
  938. messageSends: ["setupClasses", "named:", "commitPathJs:", ",", "commitPathSt:"],
  939. referencedClasses: ["Package"]
  940. }),
  941. smalltalk.PackageHandler);
  942. smalltalk.addMethod(
  943. smalltalk.method({
  944. selector: "loadPackages:prefix:",
  945. category: 'loading',
  946. fn: function (aCollection,aString){
  947. var self=this;
  948. return smalltalk.withContext(function($ctx1) {
  949. var $1;
  950. $1=_st(self._new())._loadPackages_prefix_(aCollection,aString);
  951. return $1;
  952. }, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.PackageHandler.klass)})},
  953. args: ["aCollection", "aString"],
  954. source: "loadPackages: aCollection prefix: aString\x0a\x09^ self new loadPackages: aCollection prefix: aString",
  955. messageSends: ["loadPackages:prefix:", "new"],
  956. referencedClasses: []
  957. }),
  958. smalltalk.PackageHandler.klass);
  959. smalltalk.addMethod(
  960. smalltalk.method({
  961. selector: "commit",
  962. category: '*Importer-Exporter',
  963. fn: function (){
  964. var self=this;
  965. function $PackageHandler(){return smalltalk.PackageHandler||(typeof PackageHandler=="undefined"?nil:PackageHandler)}
  966. return smalltalk.withContext(function($ctx1) {
  967. var $1;
  968. $1=_st(_st($PackageHandler())._new())._commit_(self);
  969. return $1;
  970. }, function($ctx1) {$ctx1.fill(self,"commit",{},smalltalk.Package)})},
  971. args: [],
  972. source: "commit\x0a\x09^ PackageHandler new commit: self",
  973. messageSends: ["commit:", "new"],
  974. referencedClasses: ["PackageHandler"]
  975. }),
  976. smalltalk.Package);
  977. });