Importer-Exporter.deploy.js 28 KB

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