Importer-Exporter.deploy.js 33 KB

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