Importer-Exporter.deploy.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. smalltalk.addPackage('Importer-Exporter', {});
  2. smalltalk.addClass('ChunkParser', smalltalk.Object, ['stream'], 'Importer-Exporter');
  3. smalltalk.addMethod(
  4. "_nextChunk",
  5. smalltalk.method({
  6. selector: "nextChunk",
  7. fn: function (){
  8. var self=this;
  9. return smalltalk.withContext(function($ctx1) { var $1,$2,$3;
  10. var $early={};
  11. try {
  12. $ctx1.char=nil;
  13. $ctx1.result=nil;
  14. $ctx1.chunk=nil;
  15. $ctx1.locals.result=_st("")._writeStream();
  16. _st((function(){
  17. return smalltalk.withContext(function($ctx2) { $ctx1.locals.char=_st(self["@stream"])._next();
  18. $ctx1.locals.char;
  19. return _st($ctx1.locals.char)._notNil();
  20. })}))._whileTrue_((function(){
  21. return smalltalk.withContext(function($ctx2) { $1=_st($ctx1.locals.char).__eq("!");
  22. if(smalltalk.assert($1)){
  23. $2=_st(_st(self["@stream"])._peek()).__eq("!");
  24. if(smalltalk.assert($2)){
  25. _st(self["@stream"])._next();
  26. } else {
  27. $3=_st(_st($ctx1.locals.result)._contents())._trimBoth();
  28. throw $early=[$3];
  29. };
  30. };
  31. return _st($ctx1.locals.result)._nextPut_($ctx1.locals.char);
  32. })}));
  33. return nil;
  34. }
  35. catch(e) {if(e===$early)return e[0]; throw e}
  36. }, self, "nextChunk", [], smalltalk.ChunkParser)}
  37. }),
  38. smalltalk.ChunkParser);
  39. smalltalk.addMethod(
  40. "_stream_",
  41. smalltalk.method({
  42. selector: "stream:",
  43. fn: function (aStream){
  44. var self=this;
  45. return smalltalk.withContext(function($ctx1) { self["@stream"]=aStream;
  46. return self}, self, "stream:", [aStream], smalltalk.ChunkParser)}
  47. }),
  48. smalltalk.ChunkParser);
  49. smalltalk.addMethod(
  50. "_on_",
  51. smalltalk.method({
  52. selector: "on:",
  53. fn: function (aStream){
  54. var self=this;
  55. return smalltalk.withContext(function($ctx1) { var $1;
  56. $1=_st(_st(self)._new())._stream_(aStream);
  57. return $1;
  58. }, self, "on:", [aStream], smalltalk.ChunkParser.klass)}
  59. }),
  60. smalltalk.ChunkParser.klass);
  61. smalltalk.addClass('Exporter', smalltalk.Object, [], 'Importer-Exporter');
  62. smalltalk.addMethod(
  63. "_classNameFor_",
  64. smalltalk.method({
  65. selector: "classNameFor:",
  66. fn: function (aClass){
  67. var self=this;
  68. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  69. $2=_st(aClass)._isMetaclass();
  70. if(smalltalk.assert($2)){
  71. $1=_st(_st(_st(aClass)._instanceClass())._name()).__comma(".klass");
  72. } else {
  73. $3=_st(aClass)._isNil();
  74. if(smalltalk.assert($3)){
  75. $1="nil";
  76. } else {
  77. $1=_st(aClass)._name();
  78. };
  79. };
  80. return $1;
  81. }, self, "classNameFor:", [aClass], smalltalk.Exporter)}
  82. }),
  83. smalltalk.Exporter);
  84. smalltalk.addMethod(
  85. "_exportAll",
  86. smalltalk.method({
  87. selector: "exportAll",
  88. fn: function (){
  89. var self=this;
  90. return smalltalk.withContext(function($ctx1) { var $1;
  91. $1=_st((smalltalk.String || String))._streamContents_((function(stream){
  92. return smalltalk.withContext(function($ctx2) { return _st(_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._packages())._do_((function(pkg){
  93. return smalltalk.withContext(function($ctx3) { return _st(stream)._nextPutAll_(_st(self)._exportPackage_(_st(pkg)._name()));
  94. })}));
  95. })}));
  96. return $1;
  97. }, self, "exportAll", [], smalltalk.Exporter)}
  98. }),
  99. smalltalk.Exporter);
  100. smalltalk.addMethod(
  101. "_exportClass_",
  102. smalltalk.method({
  103. selector: "exportClass:",
  104. fn: function (aClass){
  105. var self=this;
  106. return smalltalk.withContext(function($ctx1) { var $1;
  107. $1=_st((smalltalk.String || String))._streamContents_((function(stream){
  108. return smalltalk.withContext(function($ctx2) { _st(self)._exportDefinitionOf_on_(aClass,stream);
  109. _st(self)._exportMethodsOf_on_(aClass,stream);
  110. _st(self)._exportMetaDefinitionOf_on_(aClass,stream);
  111. return _st(self)._exportMethodsOf_on_(_st(aClass)._class(),stream);
  112. })}));
  113. return $1;
  114. }, self, "exportClass:", [aClass], smalltalk.Exporter)}
  115. }),
  116. smalltalk.Exporter);
  117. smalltalk.addMethod(
  118. "_exportDefinitionOf_on_",
  119. smalltalk.method({
  120. selector: "exportDefinitionOf:on:",
  121. fn: function (aClass,aStream){
  122. var self=this;
  123. return smalltalk.withContext(function($ctx1) { var $1,$2,$3,$4;
  124. _st(aStream)._nextPutAll_("smalltalk.addClass(");
  125. _st(aStream)._nextPutAll_(_st(_st("'").__comma(_st(self)._classNameFor_(aClass))).__comma("', "));
  126. _st(aStream)._nextPutAll_(_st("smalltalk.").__comma(_st(self)._classNameFor_(_st(aClass)._superclass())));
  127. $1=_st(aStream)._nextPutAll_(", [");
  128. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  129. return smalltalk.withContext(function($ctx2) { return _st(aStream)._nextPutAll_(_st(_st("'").__comma(each)).__comma("'"));
  130. })}),(function(){
  131. return smalltalk.withContext(function($ctx2) { return _st(aStream)._nextPutAll_(", ");
  132. })}));
  133. _st(aStream)._nextPutAll_("], '");
  134. _st(aStream)._nextPutAll_(_st(_st(aClass)._category()).__comma("'"));
  135. $2=_st(aStream)._nextPutAll_(");");
  136. $3=_st(_st(aClass)._comment())._notEmpty();
  137. if(smalltalk.assert($3)){
  138. _st(aStream)._lf();
  139. _st(aStream)._nextPutAll_("smalltalk.");
  140. _st(aStream)._nextPutAll_(_st(self)._classNameFor_(aClass));
  141. _st(aStream)._nextPutAll_(".comment=");
  142. $4=_st(aStream)._nextPutAll_(_st(_st(aClass)._comment())._asJavascript());
  143. $4;
  144. };
  145. _st(aStream)._lf();
  146. return self}, self, "exportDefinitionOf:on:", [aClass,aStream], smalltalk.Exporter)}
  147. }),
  148. smalltalk.Exporter);
  149. smalltalk.addMethod(
  150. "_exportMetaDefinitionOf_on_",
  151. smalltalk.method({
  152. selector: "exportMetaDefinitionOf:on:",
  153. fn: function (aClass,aStream){
  154. var self=this;
  155. return smalltalk.withContext(function($ctx1) { var $1,$2;
  156. $1=_st(_st(_st(aClass)._class())._instanceVariableNames())._isEmpty();
  157. if(! smalltalk.assert($1)){
  158. _st(aStream)._nextPutAll_(_st("smalltalk.").__comma(_st(self)._classNameFor_(_st(aClass)._class())));
  159. $2=_st(aStream)._nextPutAll_(".iVarNames = [");
  160. $2;
  161. _st(_st(_st(aClass)._class())._instanceVariableNames())._do_separatedBy_((function(each){
  162. return smalltalk.withContext(function($ctx2) { return _st(aStream)._nextPutAll_(_st(_st("'").__comma(each)).__comma("'"));
  163. })}),(function(){
  164. return smalltalk.withContext(function($ctx2) { return _st(aStream)._nextPutAll_(",");
  165. })}));
  166. _st(aStream)._nextPutAll_(_st("];").__comma(_st((smalltalk.String || String))._lf()));
  167. };
  168. return self}, self, "exportMetaDefinitionOf:on:", [aClass,aStream], smalltalk.Exporter)}
  169. }),
  170. smalltalk.Exporter);
  171. smalltalk.addMethod(
  172. "_exportMethod_of_on_",
  173. smalltalk.method({
  174. selector: "exportMethod:of:on:",
  175. fn: function (aMethod,aClass,aStream){
  176. var self=this;
  177. return smalltalk.withContext(function($ctx1) { var $1,$2;
  178. _st(aStream)._nextPutAll_("smalltalk.addMethod(");
  179. _st(aStream)._lf();
  180. _st(aStream)._nextPutAll_(_st(_st(_st(_st(aMethod)._selector())._asSelector())._asJavascript()).__comma(","));
  181. _st(aStream)._lf();
  182. _st(aStream)._nextPutAll_("smalltalk.method({");
  183. _st(aStream)._lf();
  184. _st(aStream)._nextPutAll_(_st(_st("selector: ").__comma(_st(_st(aMethod)._selector())._asJavascript())).__comma(","));
  185. _st(aStream)._lf();
  186. _st(aStream)._nextPutAll_(_st(_st("category: '").__comma(_st(aMethod)._category())).__comma("',"));
  187. _st(aStream)._lf();
  188. _st(aStream)._nextPutAll_(_st(_st("fn: ").__comma(_st(_st(aMethod)._fn())._compiledSource())).__comma(","));
  189. _st(aStream)._lf();
  190. _st(aStream)._nextPutAll_(_st(_st("args: ").__comma(_st(_st(aMethod)._arguments())._asJavascript())).__comma(","));
  191. _st(aStream)._lf();
  192. _st(aStream)._nextPutAll_(_st(_st("source: ").__comma(_st(_st(aMethod)._source())._asJavascript())).__comma(","));
  193. _st(aStream)._lf();
  194. _st(aStream)._nextPutAll_(_st(_st("messageSends: ").__comma(_st(_st(aMethod)._messageSends())._asJavascript())).__comma(","));
  195. _st(aStream)._lf();
  196. $1=_st(aStream)._nextPutAll_(_st("referencedClasses: ").__comma(_st(_st(aMethod)._referencedClasses())._asJavascript()));
  197. _st(aStream)._lf();
  198. _st(aStream)._nextPutAll_("}),");
  199. _st(aStream)._lf();
  200. _st(aStream)._nextPutAll_(_st("smalltalk.").__comma(_st(self)._classNameFor_(aClass)));
  201. _st(aStream)._nextPutAll_(");");
  202. _st(aStream)._lf();
  203. $2=_st(aStream)._lf();
  204. return self}, self, "exportMethod:of:on:", [aMethod,aClass,aStream], smalltalk.Exporter)}
  205. }),
  206. smalltalk.Exporter);
  207. smalltalk.addMethod(
  208. "_exportMethodsOf_on_",
  209. smalltalk.method({
  210. selector: "exportMethodsOf:on:",
  211. fn: function (aClass,aStream){
  212. var self=this;
  213. return smalltalk.withContext(function($ctx1) { var $1;
  214. _st(_st(_st(_st(aClass)._methodDictionary())._values())._sorted_((function(a,b){
  215. return smalltalk.withContext(function($ctx2) { return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  216. })})))._do_((function(each){
  217. return smalltalk.withContext(function($ctx2) { $1=_st(_st(each)._category())._match_("^\x5c*");
  218. if(! smalltalk.assert($1)){
  219. return _st(self)._exportMethod_of_on_(each,aClass,aStream);
  220. };
  221. })}));
  222. _st(aStream)._lf();
  223. return self}, self, "exportMethodsOf:on:", [aClass,aStream], smalltalk.Exporter)}
  224. }),
  225. smalltalk.Exporter);
  226. smalltalk.addMethod(
  227. "_exportPackage_",
  228. smalltalk.method({
  229. selector: "exportPackage:",
  230. fn: function (packageName){
  231. var self=this;
  232. return smalltalk.withContext(function($ctx1) { var $1;
  233. $ctx1.package=nil;
  234. $1=_st((smalltalk.String || String))._streamContents_((function(stream){
  235. return smalltalk.withContext(function($ctx2) { $ctx1.locals.package_=_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._packageAt_(packageName);
  236. $ctx1.locals.package_;
  237. _st(self)._exportPackageDefinitionOf_on_($ctx1.locals.package_,stream);
  238. _st(_st(_st($ctx1.locals.package_)._sortedClasses())._asSet())._do_((function(each){
  239. return smalltalk.withContext(function($ctx3) { return _st(stream)._nextPutAll_(_st(self)._exportClass_(each));
  240. })}));
  241. return _st(self)._exportPackageExtensionsOf_on_($ctx1.locals.package_,stream);
  242. })}));
  243. return $1;
  244. }, self, "exportPackage:", [packageName], smalltalk.Exporter)}
  245. }),
  246. smalltalk.Exporter);
  247. smalltalk.addMethod(
  248. "_exportPackageDefinitionOf_on_",
  249. smalltalk.method({
  250. selector: "exportPackageDefinitionOf:on:",
  251. fn: function (package_,aStream){
  252. var self=this;
  253. return smalltalk.withContext(function($ctx1) { var $1;
  254. _st(aStream)._nextPutAll_("smalltalk.addPackage(");
  255. $1=_st(aStream)._nextPutAll_(_st(_st(_st(_st("'").__comma(_st(package_)._name())).__comma("', ")).__comma(_st(package_)._propertiesAsJSON())).__comma(");"));
  256. _st(aStream)._lf();
  257. return self}, self, "exportPackageDefinitionOf:on:", [package_,aStream], smalltalk.Exporter)}
  258. }),
  259. smalltalk.Exporter);
  260. smalltalk.addMethod(
  261. "_exportPackageExtensionsOf_on_",
  262. smalltalk.method({
  263. selector: "exportPackageExtensionsOf:on:",
  264. fn: function (package_,aStream){
  265. var self=this;
  266. return smalltalk.withContext(function($ctx1) { var $1;
  267. $ctx1.name=nil;
  268. $ctx1.locals.name=_st(package_)._name();
  269. _st(_st((smalltalk.Package || Package))._sortedClasses_(_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._classes()))._do_((function(each){
  270. return smalltalk.withContext(function($ctx2) { return _st([each,_st(each)._class()])._do_((function(aClass){
  271. return smalltalk.withContext(function($ctx3) { return _st(_st(_st(_st(aClass)._methodDictionary())._values())._sorted_((function(a,b){
  272. return smalltalk.withContext(function($ctx4) { return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  273. })})))._do_((function(method){
  274. return smalltalk.withContext(function($ctx4) { $1=_st(_st(method)._category())._match_(_st("^\x5c*").__comma($ctx1.locals.name));
  275. if(smalltalk.assert($1)){
  276. return _st(self)._exportMethod_of_on_(method,aClass,aStream);
  277. };
  278. })}));
  279. })}));
  280. })}));
  281. return self}, self, "exportPackageExtensionsOf:on:", [package_,aStream], smalltalk.Exporter)}
  282. }),
  283. smalltalk.Exporter);
  284. smalltalk.addClass('ChunkExporter', smalltalk.Exporter, [], 'Importer-Exporter');
  285. smalltalk.addMethod(
  286. "_chunkEscape_",
  287. smalltalk.method({
  288. selector: "chunkEscape:",
  289. fn: function (aString){
  290. var self=this;
  291. return smalltalk.withContext(function($ctx1) { var $1;
  292. $1=_st(_st(aString)._replace_with_("!","!!"))._trimBoth();
  293. return $1;
  294. }, self, "chunkEscape:", [aString], smalltalk.ChunkExporter)}
  295. }),
  296. smalltalk.ChunkExporter);
  297. smalltalk.addMethod(
  298. "_classNameFor_",
  299. smalltalk.method({
  300. selector: "classNameFor:",
  301. fn: function (aClass){
  302. var self=this;
  303. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  304. $2=_st(aClass)._isMetaclass();
  305. if(smalltalk.assert($2)){
  306. $1=_st(_st(_st(aClass)._instanceClass())._name()).__comma(" class");
  307. } else {
  308. $3=_st(aClass)._isNil();
  309. if(smalltalk.assert($3)){
  310. $1="nil";
  311. } else {
  312. $1=_st(aClass)._name();
  313. };
  314. };
  315. return $1;
  316. }, self, "classNameFor:", [aClass], smalltalk.ChunkExporter)}
  317. }),
  318. smalltalk.ChunkExporter);
  319. smalltalk.addMethod(
  320. "_exportDefinitionOf_on_",
  321. smalltalk.method({
  322. selector: "exportDefinitionOf:on:",
  323. fn: function (aClass,aStream){
  324. var self=this;
  325. return smalltalk.withContext(function($ctx1) { var $1,$2,$3,$4;
  326. _st(aStream)._nextPutAll_(_st(self)._classNameFor_(_st(aClass)._superclass()));
  327. _st(aStream)._nextPutAll_(_st(" subclass: #").__comma(_st(self)._classNameFor_(aClass)));
  328. _st(aStream)._lf();
  329. $1=_st(aStream)._nextPutAll_("\x09instanceVariableNames: '");
  330. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  331. return smalltalk.withContext(function($ctx2) { return _st(aStream)._nextPutAll_(each);
  332. })}),(function(){
  333. return smalltalk.withContext(function($ctx2) { return _st(aStream)._nextPutAll_(" ");
  334. })}));
  335. _st(aStream)._nextPutAll_("'");
  336. _st(aStream)._lf();
  337. _st(aStream)._nextPutAll_(_st(_st("\x09package: '").__comma(_st(aClass)._category())).__comma("'!"));
  338. $2=_st(aStream)._lf();
  339. $3=_st(_st(aClass)._comment())._notEmpty();
  340. if(smalltalk.assert($3)){
  341. _st(aStream)._nextPutAll_(_st(_st("!").__comma(_st(self)._classNameFor_(aClass))).__comma(" commentStamp!"));
  342. _st(aStream)._lf();
  343. _st(aStream)._nextPutAll_(_st(_st(self)._chunkEscape_(_st(aClass)._comment())).__comma("!"));
  344. $4=_st(aStream)._lf();
  345. $4;
  346. };
  347. _st(aStream)._lf();
  348. return self}, self, "exportDefinitionOf:on:", [aClass,aStream], smalltalk.ChunkExporter)}
  349. }),
  350. smalltalk.ChunkExporter);
  351. smalltalk.addMethod(
  352. "_exportMetaDefinitionOf_on_",
  353. smalltalk.method({
  354. selector: "exportMetaDefinitionOf:on:",
  355. fn: function (aClass,aStream){
  356. var self=this;
  357. return smalltalk.withContext(function($ctx1) { var $1,$2,$3;
  358. $1=_st(_st(_st(aClass)._class())._instanceVariableNames())._isEmpty();
  359. if(! smalltalk.assert($1)){
  360. _st(aStream)._nextPutAll_(_st(self)._classNameFor_(_st(aClass)._class()));
  361. $2=_st(aStream)._nextPutAll_(" instanceVariableNames: '");
  362. $2;
  363. _st(_st(_st(aClass)._class())._instanceVariableNames())._do_separatedBy_((function(each){
  364. return smalltalk.withContext(function($ctx2) { return _st(aStream)._nextPutAll_(each);
  365. })}),(function(){
  366. return smalltalk.withContext(function($ctx2) { return _st(aStream)._nextPutAll_(" ");
  367. })}));
  368. _st(aStream)._nextPutAll_("'!");
  369. _st(aStream)._lf();
  370. $3=_st(aStream)._lf();
  371. $3;
  372. };
  373. return self}, self, "exportMetaDefinitionOf:on:", [aClass,aStream], smalltalk.ChunkExporter)}
  374. }),
  375. smalltalk.ChunkExporter);
  376. smalltalk.addMethod(
  377. "_exportMethod_of_on_",
  378. smalltalk.method({
  379. selector: "exportMethod:of:on:",
  380. fn: function (aMethod,aClass,aStream){
  381. var self=this;
  382. return smalltalk.withContext(function($ctx1) { var $1;
  383. _st(aStream)._lf();
  384. _st(aStream)._lf();
  385. _st(aStream)._nextPutAll_(_st(self)._chunkEscape_(_st(aMethod)._source()));
  386. _st(aStream)._lf();
  387. $1=_st(aStream)._nextPutAll_("!");
  388. return self}, self, "exportMethod:of:on:", [aMethod,aClass,aStream], smalltalk.ChunkExporter)}
  389. }),
  390. smalltalk.ChunkExporter);
  391. smalltalk.addMethod(
  392. "_exportMethods_category_of_on_",
  393. smalltalk.method({
  394. selector: "exportMethods:category:of:on:",
  395. fn: function (methods,category,aClass,aStream){
  396. var self=this;
  397. return smalltalk.withContext(function($ctx1) { var $1,$2;
  398. _st(aStream)._nextPutAll_(_st("!").__comma(_st(self)._classNameFor_(aClass)));
  399. $1=_st(aStream)._nextPutAll_(_st(_st(" methodsFor: '").__comma(category)).__comma("'!"));
  400. _st(_st(methods)._sorted_((function(a,b){
  401. return smalltalk.withContext(function($ctx2) { return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  402. })})))._do_((function(each){
  403. return smalltalk.withContext(function($ctx2) { return _st(self)._exportMethod_of_on_(each,aClass,aStream);
  404. })}));
  405. _st(aStream)._nextPutAll_(" !");
  406. _st(aStream)._lf();
  407. $2=_st(aStream)._lf();
  408. return self}, self, "exportMethods:category:of:on:", [methods,category,aClass,aStream], smalltalk.ChunkExporter)}
  409. }),
  410. smalltalk.ChunkExporter);
  411. smalltalk.addMethod(
  412. "_exportMethodsOf_on_",
  413. smalltalk.method({
  414. selector: "exportMethodsOf:on:",
  415. fn: function (aClass,aStream){
  416. var self=this;
  417. return smalltalk.withContext(function($ctx1) { var $1;
  418. $ctx1.map=nil;
  419. $ctx1.locals.map=_st((smalltalk.Dictionary || Dictionary))._new();
  420. _st(aClass)._protocolsDo_((function(category,methods){
  421. return smalltalk.withContext(function($ctx2) { $1=_st(category)._match_("^\x5c*");
  422. if(! smalltalk.assert($1)){
  423. return _st($ctx1.locals.map)._at_put_(category,methods);
  424. };
  425. })}));
  426. _st(_st(_st($ctx1.locals.map)._keys())._sorted_((function(a,b){
  427. return smalltalk.withContext(function($ctx2) { return _st(a).__lt_eq(b);
  428. })})))._do_((function(category){
  429. return smalltalk.withContext(function($ctx2) { $ctx2.methods=nil;
  430. $ctx2.locals.methods=_st($ctx1.locals.map)._at_(category);
  431. $ctx2.locals.methods;
  432. return _st(self)._exportMethods_category_of_on_($ctx2.locals.methods,category,aClass,aStream);
  433. })}));
  434. return self}, self, "exportMethodsOf:on:", [aClass,aStream], smalltalk.ChunkExporter)}
  435. }),
  436. smalltalk.ChunkExporter);
  437. smalltalk.addMethod(
  438. "_exportPackageDefinitionOf_on_",
  439. smalltalk.method({
  440. selector: "exportPackageDefinitionOf:on:",
  441. fn: function (package_,aStream){
  442. var self=this;
  443. return smalltalk.withContext(function($ctx1) { var $1;
  444. _st(aStream)._nextPutAll_(_st(_st(_st(_st("Smalltalk current createPackage: '").__comma(_st(package_)._name())).__comma("' properties: ")).__comma(_st(_st(package_)._properties())._storeString())).__comma("!"));
  445. $1=_st(aStream)._lf();
  446. return self}, self, "exportPackageDefinitionOf:on:", [package_,aStream], smalltalk.ChunkExporter)}
  447. }),
  448. smalltalk.ChunkExporter);
  449. smalltalk.addMethod(
  450. "_exportPackageExtensionsOf_on_",
  451. smalltalk.method({
  452. selector: "exportPackageExtensionsOf:on:",
  453. fn: function (package_,aStream){
  454. var self=this;
  455. return smalltalk.withContext(function($ctx1) { var $1;
  456. $ctx1.name=nil;
  457. $ctx1.map=nil;
  458. $ctx1.locals.name=_st(package_)._name();
  459. _st(_st((smalltalk.Package || Package))._sortedClasses_(_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._classes()))._do_((function(each){
  460. return smalltalk.withContext(function($ctx2) { return _st([each,_st(each)._class()])._do_((function(aClass){
  461. return smalltalk.withContext(function($ctx3) { $ctx1.locals.map=_st((smalltalk.Dictionary || Dictionary))._new();
  462. $ctx1.locals.map;
  463. _st(aClass)._protocolsDo_((function(category,methods){
  464. return smalltalk.withContext(function($ctx4) { $1=_st(category)._match_(_st("^\x5c*").__comma($ctx1.locals.name));
  465. if(smalltalk.assert($1)){
  466. return _st($ctx1.locals.map)._at_put_(category,methods);
  467. };
  468. })}));
  469. return _st(_st(_st($ctx1.locals.map)._keys())._sorted_((function(a,b){
  470. return smalltalk.withContext(function($ctx4) { return _st(a).__lt_eq(b);
  471. })})))._do_((function(category){
  472. return smalltalk.withContext(function($ctx4) { $ctx4.methods=nil;
  473. $ctx4.locals.methods=_st($ctx1.locals.map)._at_(category);
  474. $ctx4.locals.methods;
  475. return _st(self)._exportMethods_category_of_on_($ctx4.locals.methods,category,aClass,aStream);
  476. })}));
  477. })}));
  478. })}));
  479. return self}, self, "exportPackageExtensionsOf:on:", [package_,aStream], smalltalk.ChunkExporter)}
  480. }),
  481. smalltalk.ChunkExporter);
  482. smalltalk.addClass('StrippedExporter', smalltalk.Exporter, [], 'Importer-Exporter');
  483. smalltalk.addMethod(
  484. "_exportDefinitionOf_on_",
  485. smalltalk.method({
  486. selector: "exportDefinitionOf:on:",
  487. fn: function (aClass,aStream){
  488. var self=this;
  489. return smalltalk.withContext(function($ctx1) { var $1,$2;
  490. _st(aStream)._nextPutAll_("smalltalk.addClass(");
  491. _st(aStream)._nextPutAll_(_st(_st("'").__comma(_st(self)._classNameFor_(aClass))).__comma("', "));
  492. _st(aStream)._nextPutAll_(_st("smalltalk.").__comma(_st(self)._classNameFor_(_st(aClass)._superclass())));
  493. $1=_st(aStream)._nextPutAll_(", [");
  494. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  495. return smalltalk.withContext(function($ctx2) { return _st(aStream)._nextPutAll_(_st(_st("'").__comma(each)).__comma("'"));
  496. })}),(function(){
  497. return smalltalk.withContext(function($ctx2) { return _st(aStream)._nextPutAll_(", ");
  498. })}));
  499. _st(aStream)._nextPutAll_("], '");
  500. _st(aStream)._nextPutAll_(_st(_st(aClass)._category()).__comma("'"));
  501. $2=_st(aStream)._nextPutAll_(");");
  502. _st(aStream)._lf();
  503. return self}, self, "exportDefinitionOf:on:", [aClass,aStream], smalltalk.StrippedExporter)}
  504. }),
  505. smalltalk.StrippedExporter);
  506. smalltalk.addMethod(
  507. "_exportMethod_of_on_",
  508. smalltalk.method({
  509. selector: "exportMethod:of:on:",
  510. fn: function (aMethod,aClass,aStream){
  511. var self=this;
  512. return smalltalk.withContext(function($ctx1) { var $1;
  513. _st(aStream)._nextPutAll_("smalltalk.addMethod(");
  514. _st(aStream)._lf();
  515. _st(aStream)._nextPutAll_(_st(_st(_st(_st(aMethod)._selector())._asSelector())._asJavascript()).__comma(","));
  516. _st(aStream)._lf();
  517. _st(aStream)._nextPutAll_("smalltalk.method({");
  518. _st(aStream)._lf();
  519. _st(aStream)._nextPutAll_(_st(_st("selector: ").__comma(_st(_st(aMethod)._selector())._asJavascript())).__comma(","));
  520. _st(aStream)._lf();
  521. _st(aStream)._nextPutAll_(_st("fn: ").__comma(_st(_st(aMethod)._fn())._compiledSource()));
  522. _st(aStream)._lf();
  523. _st(aStream)._nextPutAll_("}),");
  524. _st(aStream)._lf();
  525. _st(aStream)._nextPutAll_(_st("smalltalk.").__comma(_st(self)._classNameFor_(aClass)));
  526. _st(aStream)._nextPutAll_(");");
  527. _st(aStream)._lf();
  528. $1=_st(aStream)._lf();
  529. return self}, self, "exportMethod:of:on:", [aMethod,aClass,aStream], smalltalk.StrippedExporter)}
  530. }),
  531. smalltalk.StrippedExporter);
  532. smalltalk.addClass('Importer', smalltalk.Object, [], 'Importer-Exporter');
  533. smalltalk.addMethod(
  534. "_import_",
  535. smalltalk.method({
  536. selector: "import:",
  537. fn: function (aStream){
  538. var self=this;
  539. return smalltalk.withContext(function($ctx1) { var $1;
  540. $ctx1.chunk=nil;
  541. $ctx1.result=nil;
  542. $ctx1.parser=nil;
  543. $ctx1.lastEmpty=nil;
  544. $ctx1.locals.parser=_st((smalltalk.ChunkParser || ChunkParser))._on_(aStream);
  545. $ctx1.locals.lastEmpty=false;
  546. _st((function(){
  547. return smalltalk.withContext(function($ctx2) { $ctx1.locals.chunk=_st($ctx1.locals.parser)._nextChunk();
  548. $ctx1.locals.chunk;
  549. return _st($ctx1.locals.chunk)._isNil();
  550. })}))._whileFalse_((function(){
  551. return smalltalk.withContext(function($ctx2) { $1=_st($ctx1.locals.chunk)._isEmpty();
  552. if(smalltalk.assert($1)){
  553. $ctx1.locals.lastEmpty=true;
  554. return $ctx1.locals.lastEmpty;
  555. } else {
  556. $ctx1.locals.result=_st(_st((smalltalk.Compiler || Compiler))._new())._evaluateExpression_($ctx1.locals.chunk);
  557. $ctx1.locals.result;
  558. if(smalltalk.assert($ctx1.locals.lastEmpty)){
  559. $ctx1.locals.lastEmpty=false;
  560. $ctx1.locals.lastEmpty;
  561. return _st($ctx1.locals.result)._scanFrom_($ctx1.locals.parser);
  562. };
  563. };
  564. })}));
  565. return self}, self, "import:", [aStream], smalltalk.Importer)}
  566. }),
  567. smalltalk.Importer);
  568. smalltalk.addClass('PackageLoader', smalltalk.Object, [], 'Importer-Exporter');
  569. smalltalk.addMethod(
  570. "_initializePackageNamed_prefix_",
  571. smalltalk.method({
  572. selector: "initializePackageNamed:prefix:",
  573. fn: function (packageName,aString){
  574. var self=this;
  575. return smalltalk.withContext(function($ctx1) { var $1,$2;
  576. $1=_st((smalltalk.Package || Package))._named_(packageName);
  577. _st($1)._setupClasses();
  578. _st($1)._commitPathJs_(_st(_st("/").__comma(aString)).__comma("/js"));
  579. $2=_st($1)._commitPathSt_(_st(_st("/").__comma(aString)).__comma("/st"));
  580. return self}, self, "initializePackageNamed:prefix:", [packageName,aString], smalltalk.PackageLoader)}
  581. }),
  582. smalltalk.PackageLoader);
  583. smalltalk.addMethod(
  584. "_loadPackage_prefix_",
  585. smalltalk.method({
  586. selector: "loadPackage:prefix:",
  587. fn: function (packageName,aString){
  588. var self=this;
  589. return smalltalk.withContext(function($ctx1) { var $1;
  590. $ctx1.url=nil;
  591. $ctx1.locals.url=_st(_st(_st(_st("/").__comma(aString)).__comma("/js/")).__comma(packageName)).__comma(".js");
  592. _st(jQuery)._ajax_options_($ctx1.locals.url,smalltalk.HashedCollection._fromPairs_([_st("type").__minus_gt("GET"),_st("dataType").__minus_gt("script"),_st("complete").__minus_gt((function(jqXHR,textStatus){
  593. return smalltalk.withContext(function($ctx2) { $1=_st(_st(jqXHR)._readyState()).__eq((4));
  594. if(smalltalk.assert($1)){
  595. return _st(self)._initializePackageNamed_prefix_(packageName,aString);
  596. };
  597. })})),_st("error").__minus_gt((function(){
  598. return smalltalk.withContext(function($ctx2) { return _st(window)._alert_(_st("Could not load package at: ").__comma($ctx1.locals.url));
  599. })}))]));
  600. return self}, self, "loadPackage:prefix:", [packageName,aString], smalltalk.PackageLoader)}
  601. }),
  602. smalltalk.PackageLoader);
  603. smalltalk.addMethod(
  604. "_loadPackages_prefix_",
  605. smalltalk.method({
  606. selector: "loadPackages:prefix:",
  607. fn: function (aCollection,aString){
  608. var self=this;
  609. return smalltalk.withContext(function($ctx1) { _st(aCollection)._do_((function(each){
  610. return smalltalk.withContext(function($ctx2) { return _st(self)._loadPackage_prefix_(each,aString);
  611. })}));
  612. return self}, self, "loadPackages:prefix:", [aCollection,aString], smalltalk.PackageLoader)}
  613. }),
  614. smalltalk.PackageLoader);
  615. smalltalk.addMethod(
  616. "_loadPackages_prefix_",
  617. smalltalk.method({
  618. selector: "loadPackages:prefix:",
  619. fn: function (aCollection,aString){
  620. var self=this;
  621. return smalltalk.withContext(function($ctx1) { var $1;
  622. $1=_st(_st(self)._new())._loadPackages_prefix_(aCollection,aString);
  623. return $1;
  624. }, self, "loadPackages:prefix:", [aCollection,aString], smalltalk.PackageLoader.klass)}
  625. }),
  626. smalltalk.PackageLoader.klass);