1
0

Importer-Exporter.deploy.js 24 KB

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