Importer-Exporter.js 52 KB

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