Importer-Exporter.deploy.js 31 KB

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