Importer-Exporter.deploy.js 33 KB

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