Importer-Exporter.deploy.js 33 KB

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