Importer-Exporter.deploy.js 31 KB

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