1
0

Importer-Exporter.deploy.js 30 KB

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