1
0

Importer-Exporter.deploy.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  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. _st($1)._tab();
  336. $2=_st($1)._nextPutAll_("instanceVariableNames: '");
  337. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  338. return smalltalk.withContext(function($ctx2) { return _st(aStream)._nextPutAll_(each);
  339. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  340. return smalltalk.withContext(function($ctx2) { return _st(aStream)._nextPutAll_(" ");
  341. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  342. $3=aStream;
  343. _st($3)._nextPutAll_("'");
  344. _st($3)._lf();
  345. _st($3)._tab();
  346. _st($3)._nextPutAll_(_st(_st("package: '").__comma(_st(aClass)._category())).__comma("'!"));
  347. $4=_st($3)._lf();
  348. $5=_st(_st(aClass)._comment())._notEmpty();
  349. if(smalltalk.assert($5)){
  350. $6=aStream;
  351. _st($6)._nextPutAll_(_st(_st("!").__comma(_st(self)._classNameFor_(aClass))).__comma(" commentStamp!"));
  352. _st($6)._lf();
  353. _st($6)._nextPutAll_(_st(_st(self)._chunkEscape_(_st(aClass)._comment())).__comma("!"));
  354. $7=_st($6)._lf();
  355. $7;
  356. };
  357. _st(aStream)._lf();
  358. return self}, function($ctx1) {$ctx1.fill(self,"exportDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
  359. messageSends: ["nextPutAll:", "classNameFor:", "superclass", ",", "lf", "tab", "do:separatedBy:", "instanceVariableNames", "category", "ifTrue:", "chunkEscape:", "comment", "notEmpty"]}),
  360. smalltalk.ChunkExporter);
  361. smalltalk.addMethod(
  362. "_exportMetaDefinitionOf_on_",
  363. smalltalk.method({
  364. selector: "exportMetaDefinitionOf:on:",
  365. fn: function (aClass,aStream){
  366. var self=this;
  367. return smalltalk.withContext(function($ctx1) { var $1,$2,$3,$4,$5;
  368. $1=_st(_st(_st(aClass)._class())._instanceVariableNames())._isEmpty();
  369. if(! smalltalk.assert($1)){
  370. $2=aStream;
  371. _st($2)._nextPutAll_(_st(self)._classNameFor_(_st(aClass)._class()));
  372. $3=_st($2)._nextPutAll_(" instanceVariableNames: '");
  373. $3;
  374. _st(_st(_st(aClass)._class())._instanceVariableNames())._do_separatedBy_((function(each){
  375. return smalltalk.withContext(function($ctx2) { return _st(aStream)._nextPutAll_(each);
  376. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  377. return smalltalk.withContext(function($ctx2) { return _st(aStream)._nextPutAll_(" ");
  378. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  379. $4=aStream;
  380. _st($4)._nextPutAll_("'!");
  381. _st($4)._lf();
  382. $5=_st($4)._lf();
  383. $5;
  384. };
  385. return self}, function($ctx1) {$ctx1.fill(self,"exportMetaDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
  386. messageSends: ["ifFalse:", "nextPutAll:", "classNameFor:", "class", "do:separatedBy:", "instanceVariableNames", "lf", "isEmpty"]}),
  387. smalltalk.ChunkExporter);
  388. smalltalk.addMethod(
  389. "_exportMethod_of_on_",
  390. smalltalk.method({
  391. selector: "exportMethod:of:on:",
  392. fn: function (aMethod,aClass,aStream){
  393. var self=this;
  394. return smalltalk.withContext(function($ctx1) { var $1,$2;
  395. $1=aStream;
  396. _st($1)._lf();
  397. _st($1)._lf();
  398. _st($1)._nextPutAll_(_st(self)._chunkEscape_(_st(aMethod)._source()));
  399. _st($1)._lf();
  400. $2=_st($1)._nextPutAll_("!");
  401. return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:of:on:",{aMethod:aMethod,aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
  402. messageSends: ["lf", "nextPutAll:", "chunkEscape:", "source"]}),
  403. smalltalk.ChunkExporter);
  404. smalltalk.addMethod(
  405. "_exportMethods_category_of_on_",
  406. smalltalk.method({
  407. selector: "exportMethods:category:of:on:",
  408. fn: function (methods,category,aClass,aStream){
  409. var self=this;
  410. return smalltalk.withContext(function($ctx1) { var $1,$2,$3,$4;
  411. $1=aStream;
  412. _st($1)._nextPutAll_(_st("!").__comma(_st(self)._classNameFor_(aClass)));
  413. $2=_st($1)._nextPutAll_(_st(_st(" methodsFor: '").__comma(category)).__comma("'!"));
  414. _st(_st(methods)._sorted_((function(a,b){
  415. return smalltalk.withContext(function($ctx2) { return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  416. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})})))._do_((function(each){
  417. return smalltalk.withContext(function($ctx2) { return _st(self)._exportMethod_of_on_(each,aClass,aStream);
  418. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  419. $3=aStream;
  420. _st($3)._nextPutAll_(" !");
  421. _st($3)._lf();
  422. $4=_st($3)._lf();
  423. return self}, function($ctx1) {$ctx1.fill(self,"exportMethods:category:of:on:",{methods:methods,category:category,aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
  424. messageSends: ["nextPutAll:", ",", "classNameFor:", "do:", "exportMethod:of:on:", "sorted:", "<=", "selector", "lf"]}),
  425. smalltalk.ChunkExporter);
  426. smalltalk.addMethod(
  427. "_exportMethodsOf_on_",
  428. smalltalk.method({
  429. selector: "exportMethodsOf:on:",
  430. fn: function (aClass,aStream){
  431. var self=this;
  432. var map;
  433. return smalltalk.withContext(function($ctx1) { var $1;
  434. map=_st((smalltalk.Dictionary || Dictionary))._new();
  435. _st(aClass)._protocolsDo_((function(category,methods){
  436. return smalltalk.withContext(function($ctx2) { $1=_st(category)._match_("^\x5c*");
  437. if(! smalltalk.assert($1)){
  438. return _st(map)._at_put_(category,methods);
  439. };
  440. }, function($ctx2) {$ctx2.fillBlock({category:category,methods:methods},$ctx1)})}));
  441. _st(_st(_st(map)._keys())._sorted_((function(a,b){
  442. return smalltalk.withContext(function($ctx2) { return _st(a).__lt_eq(b);
  443. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})})))._do_((function(category){
  444. var methods;
  445. return smalltalk.withContext(function($ctx2) { methods=_st(map)._at_(category);
  446. methods;
  447. return _st(self)._exportMethods_category_of_on_(methods,category,aClass,aStream);
  448. }, function($ctx2) {$ctx2.fillBlock({category:category,methods:methods},$ctx1)})}));
  449. return self}, function($ctx1) {$ctx1.fill(self,"exportMethodsOf:on:",{aClass:aClass,aStream:aStream,map:map},smalltalk.ChunkExporter)})},
  450. messageSends: ["new", "protocolsDo:", "ifFalse:", "at:put:", "match:", "do:", "at:", "exportMethods:category:of:on:", "sorted:", "<=", "keys"]}),
  451. smalltalk.ChunkExporter);
  452. smalltalk.addMethod(
  453. "_exportPackageDefinitionOf_on_",
  454. smalltalk.method({
  455. selector: "exportPackageDefinitionOf:on:",
  456. fn: function (package_,aStream){
  457. var self=this;
  458. return smalltalk.withContext(function($ctx1) { var $1,$2;
  459. $1=aStream;
  460. _st($1)._nextPutAll_(_st(_st("Smalltalk current createPackage: '").__comma(_st(package_)._name())).__comma("'!"));
  461. $2=_st($1)._lf();
  462. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageDefinitionOf:on:",{package_:package_,aStream:aStream},smalltalk.ChunkExporter)})},
  463. messageSends: ["nextPutAll:", ",", "name", "lf"]}),
  464. smalltalk.ChunkExporter);
  465. smalltalk.addMethod(
  466. "_exportPackageExtensionsOf_on_",
  467. smalltalk.method({
  468. selector: "exportPackageExtensionsOf:on:",
  469. fn: function (package_,aStream){
  470. var self=this;
  471. var name,map;
  472. return smalltalk.withContext(function($ctx1) { var $1;
  473. name=_st(package_)._name();
  474. _st(_st((smalltalk.Package || Package))._sortedClasses_(_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._classes()))._do_((function(each){
  475. return smalltalk.withContext(function($ctx2) { return _st([each,_st(each)._class()])._do_((function(aClass){
  476. return smalltalk.withContext(function($ctx3) { map=_st((smalltalk.Dictionary || Dictionary))._new();
  477. map;
  478. _st(aClass)._protocolsDo_((function(category,methods){
  479. return smalltalk.withContext(function($ctx4) { $1=_st(category)._match_(_st("^\x5c*").__comma(name));
  480. if(smalltalk.assert($1)){
  481. return _st(map)._at_put_(category,methods);
  482. };
  483. }, function($ctx4) {$ctx4.fillBlock({category:category,methods:methods},$ctx1)})}));
  484. return _st(_st(_st(map)._keys())._sorted_((function(a,b){
  485. return smalltalk.withContext(function($ctx4) { return _st(a).__lt_eq(b);
  486. }, function($ctx4) {$ctx4.fillBlock({a:a,b:b},$ctx1)})})))._do_((function(category){
  487. var methods;
  488. return smalltalk.withContext(function($ctx4) { methods=_st(map)._at_(category);
  489. methods;
  490. return _st(self)._exportMethods_category_of_on_(methods,category,aClass,aStream);
  491. }, function($ctx4) {$ctx4.fillBlock({category:category,methods:methods},$ctx1)})}));
  492. }, function($ctx3) {$ctx3.fillBlock({aClass:aClass},$ctx1)})}));
  493. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  494. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageExtensionsOf:on:",{package_:package_,aStream:aStream,name:name,map:map},smalltalk.ChunkExporter)})},
  495. messageSends: ["name", "do:", "new", "protocolsDo:", "ifTrue:", "at:put:", "match:", ",", "at:", "exportMethods:category:of:on:", "sorted:", "<=", "keys", "class", "sortedClasses:", "classes", "current"]}),
  496. smalltalk.ChunkExporter);
  497. smalltalk.addClass('StrippedExporter', smalltalk.Exporter, [], 'Importer-Exporter');
  498. smalltalk.addMethod(
  499. "_exportDefinitionOf_on_",
  500. smalltalk.method({
  501. selector: "exportDefinitionOf:on:",
  502. fn: function (aClass,aStream){
  503. var self=this;
  504. return smalltalk.withContext(function($ctx1) { var $1,$2,$3,$4;
  505. $1=aStream;
  506. _st($1)._nextPutAll_("smalltalk.addClass(");
  507. _st($1)._nextPutAll_(_st(_st("'").__comma(_st(self)._classNameFor_(aClass))).__comma("', "));
  508. _st($1)._nextPutAll_(_st("smalltalk.").__comma(_st(self)._classNameFor_(_st(aClass)._superclass())));
  509. $2=_st($1)._nextPutAll_(", [");
  510. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  511. return smalltalk.withContext(function($ctx2) { return _st(aStream)._nextPutAll_(_st(_st("'").__comma(each)).__comma("'"));
  512. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  513. return smalltalk.withContext(function($ctx2) { return _st(aStream)._nextPutAll_(", ");
  514. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  515. $3=aStream;
  516. _st($3)._nextPutAll_("], '");
  517. _st($3)._nextPutAll_(_st(_st(aClass)._category()).__comma("'"));
  518. $4=_st($3)._nextPutAll_(");");
  519. _st(aStream)._lf();
  520. return self}, function($ctx1) {$ctx1.fill(self,"exportDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.StrippedExporter)})},
  521. messageSends: ["nextPutAll:", ",", "classNameFor:", "superclass", "do:separatedBy:", "instanceVariableNames", "category", "lf"]}),
  522. smalltalk.StrippedExporter);
  523. smalltalk.addMethod(
  524. "_exportMethod_of_on_",
  525. smalltalk.method({
  526. selector: "exportMethod:of:on:",
  527. fn: function (aMethod,aClass,aStream){
  528. var self=this;
  529. return smalltalk.withContext(function($ctx1) { var $1,$2;
  530. $1=aStream;
  531. _st($1)._nextPutAll_("smalltalk.addMethod(");
  532. _st($1)._lf();
  533. _st($1)._nextPutAll_(_st(_st(_st(_st(aMethod)._selector())._asSelector())._asJavascript()).__comma(","));
  534. _st($1)._lf();
  535. _st($1)._nextPutAll_("smalltalk.method({");
  536. _st($1)._lf();
  537. _st($1)._nextPutAll_(_st(_st("selector: ").__comma(_st(_st(aMethod)._selector())._asJavascript())).__comma(","));
  538. _st($1)._lf();
  539. _st($1)._nextPutAll_(_st(_st("fn: ").__comma(_st(_st(aMethod)._fn())._compiledSource())).__comma(","));
  540. _st($1)._lf();
  541. _st($1)._nextPutAll_(_st("messageSends: ").__comma(_st(_st(aMethod)._messageSends())._asJavascript()));
  542. _st($1)._nextPutAll_("}),");
  543. _st($1)._lf();
  544. _st($1)._nextPutAll_(_st("smalltalk.").__comma(_st(self)._classNameFor_(aClass)));
  545. _st($1)._nextPutAll_(");");
  546. _st($1)._lf();
  547. $2=_st($1)._lf();
  548. return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:of:on:",{aMethod:aMethod,aClass:aClass,aStream:aStream},smalltalk.StrippedExporter)})},
  549. messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "asSelector", "selector", "compiledSource", "fn", "messageSends", "classNameFor:"]}),
  550. smalltalk.StrippedExporter);
  551. smalltalk.addClass('Importer', smalltalk.Object, [], 'Importer-Exporter');
  552. smalltalk.addMethod(
  553. "_import_",
  554. smalltalk.method({
  555. selector: "import:",
  556. fn: function (aStream){
  557. var self=this;
  558. var chunk,result,parser,lastEmpty;
  559. return smalltalk.withContext(function($ctx1) { var $1,$2;
  560. parser=_st((smalltalk.ChunkParser || ChunkParser))._on_(aStream);
  561. lastEmpty=false;
  562. _st((function(){
  563. return smalltalk.withContext(function($ctx2) { chunk=_st(parser)._nextChunk();
  564. chunk;
  565. return _st(chunk)._isNil();
  566. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
  567. return smalltalk.withContext(function($ctx2) { $1=_st(chunk)._isEmpty();
  568. if(smalltalk.assert($1)){
  569. lastEmpty=true;
  570. return lastEmpty;
  571. } else {
  572. result=_st(_st((smalltalk.Compiler || Compiler))._new())._evaluateExpression_(chunk);
  573. result;
  574. $2=lastEmpty;
  575. if(smalltalk.assert($2)){
  576. lastEmpty=false;
  577. lastEmpty;
  578. return _st(result)._scanFrom_(parser);
  579. };
  580. };
  581. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  582. return self}, function($ctx1) {$ctx1.fill(self,"import:",{aStream:aStream,chunk:chunk,result:result,parser:parser,lastEmpty:lastEmpty},smalltalk.Importer)})},
  583. messageSends: ["on:", "whileFalse:", "ifTrue:ifFalse:", "evaluateExpression:", "new", "ifTrue:", "scanFrom:", "isEmpty", "nextChunk", "isNil"]}),
  584. smalltalk.Importer);
  585. smalltalk.addClass('PackageLoader', smalltalk.Object, [], 'Importer-Exporter');
  586. smalltalk.addMethod(
  587. "_initializePackageNamed_prefix_",
  588. smalltalk.method({
  589. selector: "initializePackageNamed:prefix:",
  590. fn: function (packageName,aString){
  591. var self=this;
  592. return smalltalk.withContext(function($ctx1) { var $1,$2;
  593. $1=_st((smalltalk.Package || Package))._named_(packageName);
  594. _st($1)._setupClasses();
  595. _st($1)._commitPathJs_(_st(_st("/").__comma(aString)).__comma("/js"));
  596. $2=_st($1)._commitPathSt_(_st(_st("/").__comma(aString)).__comma("/st"));
  597. return self}, function($ctx1) {$ctx1.fill(self,"initializePackageNamed:prefix:",{packageName:packageName,aString:aString},smalltalk.PackageLoader)})},
  598. messageSends: ["setupClasses", "named:", "commitPathJs:", ",", "commitPathSt:"]}),
  599. smalltalk.PackageLoader);
  600. smalltalk.addMethod(
  601. "_loadPackage_prefix_",
  602. smalltalk.method({
  603. selector: "loadPackage:prefix:",
  604. fn: function (packageName,aString){
  605. var self=this;
  606. var url;
  607. return smalltalk.withContext(function($ctx1) { var $1;
  608. url=_st(_st(_st(_st("/").__comma(aString)).__comma("/js/")).__comma(packageName)).__comma(".js");
  609. _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){
  610. return smalltalk.withContext(function($ctx2) { $1=_st(_st(jqXHR)._readyState()).__eq((4));
  611. if(smalltalk.assert($1)){
  612. return _st(self)._initializePackageNamed_prefix_(packageName,aString);
  613. };
  614. }, function($ctx2) {$ctx2.fillBlock({jqXHR:jqXHR,textStatus:textStatus},$ctx1)})})),_st("error").__minus_gt((function(){
  615. return smalltalk.withContext(function($ctx2) { return _st(window)._alert_(_st("Could not load package at: ").__comma(url));
  616. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))]));
  617. return self}, function($ctx1) {$ctx1.fill(self,"loadPackage:prefix:",{packageName:packageName,aString:aString,url:url},smalltalk.PackageLoader)})},
  618. messageSends: [",", "ajax:options:", "->", "ifTrue:", "initializePackageNamed:prefix:", "=", "readyState", "alert:"]}),
  619. smalltalk.PackageLoader);
  620. smalltalk.addMethod(
  621. "_loadPackages_prefix_",
  622. smalltalk.method({
  623. selector: "loadPackages:prefix:",
  624. fn: function (aCollection,aString){
  625. var self=this;
  626. return smalltalk.withContext(function($ctx1) { _st(aCollection)._do_((function(each){
  627. return smalltalk.withContext(function($ctx2) { return _st(self)._loadPackage_prefix_(each,aString);
  628. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  629. return self}, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.PackageLoader)})},
  630. messageSends: ["do:", "loadPackage:prefix:"]}),
  631. smalltalk.PackageLoader);
  632. smalltalk.addMethod(
  633. "_loadPackages_prefix_",
  634. smalltalk.method({
  635. selector: "loadPackages:prefix:",
  636. fn: function (aCollection,aString){
  637. var self=this;
  638. return smalltalk.withContext(function($ctx1) { var $1;
  639. $1=_st(_st(self)._new())._loadPackages_prefix_(aCollection,aString);
  640. return $1;
  641. }, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.PackageLoader.klass)})},
  642. messageSends: ["loadPackages:prefix:", "new"]}),
  643. smalltalk.PackageLoader.klass);