2
0

Importer-Exporter.deploy.js 30 KB

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