1
0

Importer-Exporter.deploy.js 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168
  1. define("amber/Importer-Exporter", ["amber_vm/smalltalk","amber_vm/nil","amber_vm/_st"], function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Importer-Exporter');
  3. smalltalk.addClass('ChunkParser', smalltalk.Object, ['stream'], 'Importer-Exporter');
  4. smalltalk.addMethod(
  5. smalltalk.method({
  6. selector: "nextChunk",
  7. fn: function (){
  8. var self=this;
  9. var char,result,chunk;
  10. return smalltalk.withContext(function($ctx1) {
  11. var $1,$2,$3;
  12. var $early={};
  13. try {
  14. result=""._writeStream();
  15. _st((function(){
  16. return smalltalk.withContext(function($ctx2) {
  17. char=_st(self["@stream"])._next();
  18. char;
  19. return _st(char)._notNil();
  20. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileTrue_((function(){
  21. return smalltalk.withContext(function($ctx2) {
  22. $1=_st(char).__eq("!");
  23. if(smalltalk.assert($1)){
  24. $2=_st(_st(self["@stream"])._peek()).__eq("!");
  25. if(smalltalk.assert($2)){
  26. _st(self["@stream"])._next();
  27. } else {
  28. $3=_st(_st(result)._contents())._trimBoth();
  29. throw $early=[$3];
  30. };
  31. };
  32. return _st(result)._nextPut_(char);
  33. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  34. return nil;
  35. }
  36. catch(e) {if(e===$early)return e[0]; throw e}
  37. }, function($ctx1) {$ctx1.fill(self,"nextChunk",{char:char,result:result,chunk:chunk},smalltalk.ChunkParser)})},
  38. messageSends: ["writeStream", "whileTrue:", "ifTrue:", "ifTrue:ifFalse:", "next", "trimBoth", "contents", "=", "peek", "nextPut:", "notNil"]}),
  39. smalltalk.ChunkParser);
  40. smalltalk.addMethod(
  41. smalltalk.method({
  42. selector: "stream:",
  43. fn: function (aStream){
  44. var self=this;
  45. return smalltalk.withContext(function($ctx1) {
  46. self["@stream"]=aStream;
  47. return self}, function($ctx1) {$ctx1.fill(self,"stream:",{aStream:aStream},smalltalk.ChunkParser)})},
  48. messageSends: []}),
  49. smalltalk.ChunkParser);
  50. smalltalk.addMethod(
  51. smalltalk.method({
  52. selector: "on:",
  53. fn: function (aStream){
  54. var self=this;
  55. return smalltalk.withContext(function($ctx1) {
  56. var $1;
  57. $1=_st(self._new())._stream_(aStream);
  58. return $1;
  59. }, function($ctx1) {$ctx1.fill(self,"on:",{aStream:aStream},smalltalk.ChunkParser.klass)})},
  60. messageSends: ["stream:", "new"]}),
  61. smalltalk.ChunkParser.klass);
  62. smalltalk.addClass('Exporter', smalltalk.Object, [], 'Importer-Exporter');
  63. smalltalk.addMethod(
  64. smalltalk.method({
  65. selector: "classNameFor:",
  66. fn: function (aClass){
  67. var self=this;
  68. return smalltalk.withContext(function($ctx1) {
  69. var $2,$3,$1;
  70. $2=_st(aClass)._isMetaclass();
  71. if(smalltalk.assert($2)){
  72. $1=_st(_st(_st(aClass)._instanceClass())._name()).__comma(".klass");
  73. } else {
  74. $3=_st(aClass)._isNil();
  75. if(smalltalk.assert($3)){
  76. $1="nil";
  77. } else {
  78. $1=_st(aClass)._name();
  79. };
  80. };
  81. return $1;
  82. }, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},smalltalk.Exporter)})},
  83. messageSends: ["ifTrue:ifFalse:", ",", "name", "instanceClass", "isNil", "isMetaclass"]}),
  84. smalltalk.Exporter);
  85. smalltalk.addMethod(
  86. smalltalk.method({
  87. selector: "exportAll",
  88. fn: function (){
  89. var self=this;
  90. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  91. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  92. return smalltalk.withContext(function($ctx1) {
  93. var $1;
  94. $1=_st($String())._streamContents_((function(stream){
  95. return smalltalk.withContext(function($ctx2) {
  96. return _st(_st(_st($Smalltalk())._current())._packages())._do_((function(pkg){
  97. return smalltalk.withContext(function($ctx3) {
  98. return _st(stream)._nextPutAll_(self._exportPackage_(_st(pkg)._name()));
  99. }, function($ctx3) {$ctx3.fillBlock({pkg:pkg},$ctx2)})}));
  100. }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1)})}));
  101. return $1;
  102. }, function($ctx1) {$ctx1.fill(self,"exportAll",{},smalltalk.Exporter)})},
  103. messageSends: ["streamContents:", "do:", "nextPutAll:", "exportPackage:", "name", "packages", "current"]}),
  104. smalltalk.Exporter);
  105. smalltalk.addMethod(
  106. smalltalk.method({
  107. selector: "exportAmdPackageEpilogueOn:",
  108. fn: function (aStream){
  109. var self=this;
  110. return smalltalk.withContext(function($ctx1) {
  111. var $1,$2;
  112. $1=aStream;
  113. _st($1)._nextPutAll_("});");
  114. $2=_st($1)._lf();
  115. return self}, function($ctx1) {$ctx1.fill(self,"exportAmdPackageEpilogueOn:",{aStream:aStream},smalltalk.Exporter)})},
  116. messageSends: ["nextPutAll:", "lf"]}),
  117. smalltalk.Exporter);
  118. smalltalk.addMethod(
  119. smalltalk.method({
  120. selector: "exportAmdPackagePrologueOf:on:",
  121. fn: function (aPackage,aStream){
  122. var self=this;
  123. return smalltalk.withContext(function($ctx1) {
  124. var $1,$2;
  125. $1=aStream;
  126. _st($1)._nextPutAll_("define(\x22amber/");
  127. _st($1)._nextPutAll_(_st(aPackage)._name());
  128. _st($1)._nextPutAll_("\x22, [\x22amber_vm/smalltalk\x22,\x22amber_vm/nil\x22,\x22amber_vm/_st\x22], function(smalltalk,nil,_st){");
  129. $2=_st($1)._lf();
  130. return self}, function($ctx1) {$ctx1.fill(self,"exportAmdPackagePrologueOf:on:",{aPackage:aPackage,aStream:aStream},smalltalk.Exporter)})},
  131. messageSends: ["nextPutAll:", "name", "lf"]}),
  132. smalltalk.Exporter);
  133. smalltalk.addMethod(
  134. smalltalk.method({
  135. selector: "exportClass:",
  136. fn: function (aClass){
  137. var self=this;
  138. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  139. return smalltalk.withContext(function($ctx1) {
  140. var $1;
  141. $1=_st($String())._streamContents_((function(stream){
  142. return smalltalk.withContext(function($ctx2) {
  143. self._exportDefinitionOf_on_(aClass,stream);
  144. self._exportMethodsOf_on_(aClass,stream);
  145. self._exportMetaDefinitionOf_on_(aClass,stream);
  146. return self._exportMethodsOf_on_(_st(aClass)._class(),stream);
  147. }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1)})}));
  148. return $1;
  149. }, function($ctx1) {$ctx1.fill(self,"exportClass:",{aClass:aClass},smalltalk.Exporter)})},
  150. messageSends: ["streamContents:", "exportDefinitionOf:on:", "exportMethodsOf:on:", "exportMetaDefinitionOf:on:", "class"]}),
  151. smalltalk.Exporter);
  152. smalltalk.addMethod(
  153. smalltalk.method({
  154. selector: "exportDefinitionOf:on:",
  155. fn: function (aClass,aStream){
  156. var self=this;
  157. return smalltalk.withContext(function($ctx1) {
  158. var $1,$2,$3,$4,$5,$6,$7;
  159. $1=aStream;
  160. _st($1)._nextPutAll_("smalltalk.addClass(");
  161. _st($1)._nextPutAll_(_st("'".__comma(self._classNameFor_(aClass))).__comma("', "));
  162. _st($1)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aClass)._superclass())));
  163. $2=_st($1)._nextPutAll_(", [");
  164. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  165. return smalltalk.withContext(function($ctx2) {
  166. return _st(aStream)._nextPutAll_(_st("'".__comma(each)).__comma("'"));
  167. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  168. return smalltalk.withContext(function($ctx2) {
  169. return _st(aStream)._nextPutAll_(", ");
  170. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  171. $3=aStream;
  172. _st($3)._nextPutAll_("], '");
  173. _st($3)._nextPutAll_(_st(_st(aClass)._category()).__comma("'"));
  174. $4=_st($3)._nextPutAll_(");");
  175. $5=_st(_st(aClass)._comment())._notEmpty();
  176. if(smalltalk.assert($5)){
  177. $6=aStream;
  178. _st($6)._lf();
  179. _st($6)._nextPutAll_("smalltalk.");
  180. _st($6)._nextPutAll_(self._classNameFor_(aClass));
  181. _st($6)._nextPutAll_(".comment=");
  182. _st($6)._nextPutAll_(_st(_st(aClass)._comment())._asJavascript());
  183. $7=_st($6)._nextPutAll_(";");
  184. $7;
  185. };
  186. _st(aStream)._lf();
  187. return self}, function($ctx1) {$ctx1.fill(self,"exportDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.Exporter)})},
  188. messageSends: ["nextPutAll:", ",", "classNameFor:", "superclass", "do:separatedBy:", "instanceVariableNames", "category", "ifTrue:", "lf", "asJavascript", "comment", "notEmpty"]}),
  189. smalltalk.Exporter);
  190. smalltalk.addMethod(
  191. smalltalk.method({
  192. selector: "exportMetaDefinitionOf:on:",
  193. fn: function (aClass,aStream){
  194. var self=this;
  195. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  196. return smalltalk.withContext(function($ctx1) {
  197. var $1,$2,$3;
  198. $1=_st(_st(_st(aClass)._class())._instanceVariableNames())._isEmpty();
  199. if(! smalltalk.assert($1)){
  200. $2=aStream;
  201. _st($2)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aClass)._class())));
  202. $3=_st($2)._nextPutAll_(".iVarNames = [");
  203. $3;
  204. _st(_st(_st(aClass)._class())._instanceVariableNames())._do_separatedBy_((function(each){
  205. return smalltalk.withContext(function($ctx2) {
  206. return _st(aStream)._nextPutAll_(_st("'".__comma(each)).__comma("'"));
  207. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  208. return smalltalk.withContext(function($ctx2) {
  209. return _st(aStream)._nextPutAll_(",");
  210. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  211. _st(aStream)._nextPutAll_("];".__comma(_st($String())._lf()));
  212. };
  213. return self}, function($ctx1) {$ctx1.fill(self,"exportMetaDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.Exporter)})},
  214. messageSends: ["ifFalse:", "nextPutAll:", ",", "classNameFor:", "class", "do:separatedBy:", "instanceVariableNames", "lf", "isEmpty"]}),
  215. smalltalk.Exporter);
  216. smalltalk.addMethod(
  217. smalltalk.method({
  218. selector: "exportMethod:of:on:",
  219. fn: function (aMethod,aClass,aStream){
  220. var self=this;
  221. return smalltalk.withContext(function($ctx1) {
  222. var $1,$2,$3,$4;
  223. $1=aStream;
  224. _st($1)._nextPutAll_("smalltalk.addMethod(");
  225. _st($1)._lf();
  226. _st($1)._nextPutAll_("smalltalk.method({");
  227. _st($1)._lf();
  228. _st($1)._nextPutAll_(_st("selector: ".__comma(_st(_st(aMethod)._selector())._asJavascript())).__comma(","));
  229. _st($1)._lf();
  230. _st($1)._nextPutAll_(_st("category: '".__comma(_st(aMethod)._category())).__comma("',"));
  231. _st($1)._lf();
  232. _st($1)._nextPutAll_(_st("fn: ".__comma(_st(_st(aMethod)._fn())._compiledSource())).__comma(","));
  233. _st($1)._lf();
  234. _st($1)._nextPutAll_(_st("args: ".__comma(_st(_st(aMethod)._arguments())._asJavascript())).__comma(","));
  235. _st($1)._lf();
  236. _st($1)._nextPutAll_(_st("source: ".__comma(_st(_st(aMethod)._source())._asJavascript())).__comma(","));
  237. _st($1)._lf();
  238. _st($1)._nextPutAll_(_st("messageSends: ".__comma(_st(_st(aMethod)._messageSends())._asJavascript())).__comma(","));
  239. _st($1)._lf();
  240. $2=_st($1)._nextPutAll_("referencedClasses: ".__comma(_st(_st(aMethod)._referencedClasses())._asJavascript()));
  241. $3=aStream;
  242. _st($3)._lf();
  243. _st($3)._nextPutAll_("}),");
  244. _st($3)._lf();
  245. _st($3)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(aClass)));
  246. _st($3)._nextPutAll_(");");
  247. _st($3)._lf();
  248. $4=_st($3)._lf();
  249. return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:of:on:",{aMethod:aMethod,aClass:aClass,aStream:aStream},smalltalk.Exporter)})},
  250. messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "selector", "category", "compiledSource", "fn", "arguments", "source", "messageSends", "referencedClasses", "classNameFor:"]}),
  251. smalltalk.Exporter);
  252. smalltalk.addMethod(
  253. smalltalk.method({
  254. selector: "exportMethodsOf:on:",
  255. fn: function (aClass,aStream){
  256. var self=this;
  257. return smalltalk.withContext(function($ctx1) {
  258. var $1;
  259. _st(_st(_st(_st(aClass)._methodDictionary())._values())._sorted_((function(a,b){
  260. return smalltalk.withContext(function($ctx2) {
  261. return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  262. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})})))._do_((function(each){
  263. return smalltalk.withContext(function($ctx2) {
  264. $1=_st(_st(each)._category())._match_("^\x5c*");
  265. if(! smalltalk.assert($1)){
  266. return self._exportMethod_of_on_(each,aClass,aStream);
  267. };
  268. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  269. _st(aStream)._lf();
  270. return self}, function($ctx1) {$ctx1.fill(self,"exportMethodsOf:on:",{aClass:aClass,aStream:aStream},smalltalk.Exporter)})},
  271. messageSends: ["do:", "ifFalse:", "exportMethod:of:on:", "match:", "category", "sorted:", "<=", "selector", "values", "methodDictionary", "lf"]}),
  272. smalltalk.Exporter);
  273. smalltalk.addMethod(
  274. smalltalk.method({
  275. selector: "exportPackage:",
  276. fn: function (packageName){
  277. var self=this;
  278. var package_;
  279. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  280. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  281. return smalltalk.withContext(function($ctx1) {
  282. var $1;
  283. $1=_st($String())._streamContents_((function(stream){
  284. return smalltalk.withContext(function($ctx2) {
  285. package_=_st(_st($Smalltalk())._current())._packageAt_(packageName);
  286. package_;
  287. self._exportAmdPackagePrologueOf_on_(package_,stream);
  288. return _st((function(){
  289. return smalltalk.withContext(function($ctx3) {
  290. self._exportPackageDefinitionOf_on_(package_,stream);
  291. _st(_st(_st(package_)._sortedClasses())._asSet())._do_((function(each){
  292. return smalltalk.withContext(function($ctx4) {
  293. return _st(stream)._nextPutAll_(self._exportClass_(each));
  294. }, function($ctx4) {$ctx4.fillBlock({each:each},$ctx3)})}));
  295. return self._exportPackageExtensionsOf_on_(package_,stream);
  296. }, function($ctx3) {$ctx3.fillBlock({},$ctx2)})}))._ensure_((function(){
  297. return smalltalk.withContext(function($ctx3) {
  298. return self._exportAmdPackageEpilogueOn_(stream);
  299. }, function($ctx3) {$ctx3.fillBlock({},$ctx2)})}));
  300. }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1)})}));
  301. return $1;
  302. }, function($ctx1) {$ctx1.fill(self,"exportPackage:",{packageName:packageName,package_:package_},smalltalk.Exporter)})},
  303. messageSends: ["streamContents:", "packageAt:", "current", "exportAmdPackagePrologueOf:on:", "ensure:", "exportAmdPackageEpilogueOn:", "exportPackageDefinitionOf:on:", "do:", "nextPutAll:", "exportClass:", "asSet", "sortedClasses", "exportPackageExtensionsOf:on:"]}),
  304. smalltalk.Exporter);
  305. smalltalk.addMethod(
  306. smalltalk.method({
  307. selector: "exportPackageDefinitionOf:on:",
  308. fn: function (package_,aStream){
  309. var self=this;
  310. return smalltalk.withContext(function($ctx1) {
  311. var $1,$2;
  312. $1=aStream;
  313. _st($1)._nextPutAll_("smalltalk.addPackage(");
  314. _st($1)._nextPutAll_(_st("'".__comma(_st(package_)._name())).__comma("');"));
  315. $2=_st($1)._lf();
  316. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageDefinitionOf:on:",{package_:package_,aStream:aStream},smalltalk.Exporter)})},
  317. messageSends: ["nextPutAll:", ",", "name", "lf"]}),
  318. smalltalk.Exporter);
  319. smalltalk.addMethod(
  320. smalltalk.method({
  321. selector: "exportPackageExtensionsOf:on:",
  322. fn: function (package_,aStream){
  323. var self=this;
  324. var name;
  325. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  326. function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
  327. return smalltalk.withContext(function($ctx1) {
  328. var $1;
  329. name=_st(package_)._name();
  330. _st(_st($Package())._sortedClasses_(_st(_st($Smalltalk())._current())._classes()))._do_((function(each){
  331. return smalltalk.withContext(function($ctx2) {
  332. return _st([each,_st(each)._class()])._do_((function(aClass){
  333. return smalltalk.withContext(function($ctx3) {
  334. return _st(_st(_st(_st(aClass)._methodDictionary())._values())._sorted_((function(a,b){
  335. return smalltalk.withContext(function($ctx4) {
  336. return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  337. }, function($ctx4) {$ctx4.fillBlock({a:a,b:b},$ctx3)})})))._do_((function(method){
  338. return smalltalk.withContext(function($ctx4) {
  339. $1=_st(_st(method)._category())._match_("^\x5c*".__comma(name));
  340. if(smalltalk.assert($1)){
  341. return self._exportMethod_of_on_(method,aClass,aStream);
  342. };
  343. }, function($ctx4) {$ctx4.fillBlock({method:method},$ctx3)})}));
  344. }, function($ctx3) {$ctx3.fillBlock({aClass:aClass},$ctx2)})}));
  345. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  346. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageExtensionsOf:on:",{package_:package_,aStream:aStream,name:name},smalltalk.Exporter)})},
  347. messageSends: ["name", "do:", "ifTrue:", "exportMethod:of:on:", "match:", ",", "category", "sorted:", "<=", "selector", "values", "methodDictionary", "class", "sortedClasses:", "classes", "current"]}),
  348. smalltalk.Exporter);
  349. smalltalk.addClass('ChunkExporter', smalltalk.Exporter, [], 'Importer-Exporter');
  350. smalltalk.addMethod(
  351. smalltalk.method({
  352. selector: "chunkEscape:",
  353. fn: function (aString){
  354. var self=this;
  355. return smalltalk.withContext(function($ctx1) {
  356. var $1;
  357. $1=_st(_st(aString)._replace_with_("!","!!"))._trimBoth();
  358. return $1;
  359. }, function($ctx1) {$ctx1.fill(self,"chunkEscape:",{aString:aString},smalltalk.ChunkExporter)})},
  360. messageSends: ["trimBoth", "replace:with:"]}),
  361. smalltalk.ChunkExporter);
  362. smalltalk.addMethod(
  363. smalltalk.method({
  364. selector: "classNameFor:",
  365. fn: function (aClass){
  366. var self=this;
  367. return smalltalk.withContext(function($ctx1) {
  368. var $2,$3,$1;
  369. $2=_st(aClass)._isMetaclass();
  370. if(smalltalk.assert($2)){
  371. $1=_st(_st(_st(aClass)._instanceClass())._name()).__comma(" class");
  372. } else {
  373. $3=_st(aClass)._isNil();
  374. if(smalltalk.assert($3)){
  375. $1="nil";
  376. } else {
  377. $1=_st(aClass)._name();
  378. };
  379. };
  380. return $1;
  381. }, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},smalltalk.ChunkExporter)})},
  382. messageSends: ["ifTrue:ifFalse:", ",", "name", "instanceClass", "isNil", "isMetaclass"]}),
  383. smalltalk.ChunkExporter);
  384. smalltalk.addMethod(
  385. smalltalk.method({
  386. selector: "exportAmdPackageEpilogueOn:",
  387. fn: function (aStream){
  388. var self=this;
  389. return smalltalk.withContext(function($ctx1) {
  390. return self}, function($ctx1) {$ctx1.fill(self,"exportAmdPackageEpilogueOn:",{aStream:aStream},smalltalk.ChunkExporter)})},
  391. messageSends: []}),
  392. smalltalk.ChunkExporter);
  393. smalltalk.addMethod(
  394. smalltalk.method({
  395. selector: "exportAmdPackagePrologueOf:on:",
  396. fn: function (aPackage,aStream){
  397. var self=this;
  398. return smalltalk.withContext(function($ctx1) {
  399. return self}, function($ctx1) {$ctx1.fill(self,"exportAmdPackagePrologueOf:on:",{aPackage:aPackage,aStream:aStream},smalltalk.ChunkExporter)})},
  400. messageSends: []}),
  401. smalltalk.ChunkExporter);
  402. smalltalk.addMethod(
  403. smalltalk.method({
  404. selector: "exportDefinitionOf:on:",
  405. fn: function (aClass,aStream){
  406. var self=this;
  407. return smalltalk.withContext(function($ctx1) {
  408. var $1,$2,$3,$4,$5,$6,$7;
  409. $1=aStream;
  410. _st($1)._nextPutAll_(self._classNameFor_(_st(aClass)._superclass()));
  411. _st($1)._nextPutAll_(" subclass: #".__comma(self._classNameFor_(aClass)));
  412. _st($1)._lf();
  413. _st($1)._tab();
  414. $2=_st($1)._nextPutAll_("instanceVariableNames: '");
  415. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  416. return smalltalk.withContext(function($ctx2) {
  417. return _st(aStream)._nextPutAll_(each);
  418. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  419. return smalltalk.withContext(function($ctx2) {
  420. return _st(aStream)._nextPutAll_(" ");
  421. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  422. $3=aStream;
  423. _st($3)._nextPutAll_("'");
  424. _st($3)._lf();
  425. _st($3)._tab();
  426. _st($3)._nextPutAll_(_st("package: '".__comma(_st(aClass)._category())).__comma("'!"));
  427. $4=_st($3)._lf();
  428. $5=_st(_st(aClass)._comment())._notEmpty();
  429. if(smalltalk.assert($5)){
  430. $6=aStream;
  431. _st($6)._nextPutAll_(_st("!".__comma(self._classNameFor_(aClass))).__comma(" commentStamp!"));
  432. _st($6)._lf();
  433. _st($6)._nextPutAll_(_st(self._chunkEscape_(_st(aClass)._comment())).__comma("!"));
  434. $7=_st($6)._lf();
  435. $7;
  436. };
  437. _st(aStream)._lf();
  438. return self}, function($ctx1) {$ctx1.fill(self,"exportDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
  439. messageSends: ["nextPutAll:", "classNameFor:", "superclass", ",", "lf", "tab", "do:separatedBy:", "instanceVariableNames", "category", "ifTrue:", "chunkEscape:", "comment", "notEmpty"]}),
  440. smalltalk.ChunkExporter);
  441. smalltalk.addMethod(
  442. smalltalk.method({
  443. selector: "exportMetaDefinitionOf:on:",
  444. fn: function (aClass,aStream){
  445. var self=this;
  446. return smalltalk.withContext(function($ctx1) {
  447. var $1,$2,$3,$4,$5;
  448. $1=_st(_st(_st(aClass)._class())._instanceVariableNames())._isEmpty();
  449. if(! smalltalk.assert($1)){
  450. $2=aStream;
  451. _st($2)._nextPutAll_(self._classNameFor_(_st(aClass)._class()));
  452. $3=_st($2)._nextPutAll_(" instanceVariableNames: '");
  453. $3;
  454. _st(_st(_st(aClass)._class())._instanceVariableNames())._do_separatedBy_((function(each){
  455. return smalltalk.withContext(function($ctx2) {
  456. return _st(aStream)._nextPutAll_(each);
  457. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  458. return smalltalk.withContext(function($ctx2) {
  459. return _st(aStream)._nextPutAll_(" ");
  460. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  461. $4=aStream;
  462. _st($4)._nextPutAll_("'!");
  463. _st($4)._lf();
  464. $5=_st($4)._lf();
  465. $5;
  466. };
  467. return self}, function($ctx1) {$ctx1.fill(self,"exportMetaDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
  468. messageSends: ["ifFalse:", "nextPutAll:", "classNameFor:", "class", "do:separatedBy:", "instanceVariableNames", "lf", "isEmpty"]}),
  469. smalltalk.ChunkExporter);
  470. smalltalk.addMethod(
  471. smalltalk.method({
  472. selector: "exportMethod:of:on:",
  473. fn: function (aMethod,aClass,aStream){
  474. var self=this;
  475. return smalltalk.withContext(function($ctx1) {
  476. var $1,$2;
  477. $1=aStream;
  478. _st($1)._lf();
  479. _st($1)._lf();
  480. _st($1)._nextPutAll_(self._chunkEscape_(_st(aMethod)._source()));
  481. _st($1)._lf();
  482. $2=_st($1)._nextPutAll_("!");
  483. return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:of:on:",{aMethod:aMethod,aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
  484. messageSends: ["lf", "nextPutAll:", "chunkEscape:", "source"]}),
  485. smalltalk.ChunkExporter);
  486. smalltalk.addMethod(
  487. smalltalk.method({
  488. selector: "exportMethods:category:of:on:",
  489. fn: function (methods,category,aClass,aStream){
  490. var self=this;
  491. return smalltalk.withContext(function($ctx1) {
  492. var $1,$2,$3,$4;
  493. $1=aStream;
  494. _st($1)._nextPutAll_("!".__comma(self._classNameFor_(aClass)));
  495. $2=_st($1)._nextPutAll_(_st(" methodsFor: '".__comma(category)).__comma("'!"));
  496. _st(_st(methods)._sorted_((function(a,b){
  497. return smalltalk.withContext(function($ctx2) {
  498. return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
  499. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})})))._do_((function(each){
  500. return smalltalk.withContext(function($ctx2) {
  501. return self._exportMethod_of_on_(each,aClass,aStream);
  502. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  503. $3=aStream;
  504. _st($3)._nextPutAll_(" !");
  505. _st($3)._lf();
  506. $4=_st($3)._lf();
  507. return self}, function($ctx1) {$ctx1.fill(self,"exportMethods:category:of:on:",{methods:methods,category:category,aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
  508. messageSends: ["nextPutAll:", ",", "classNameFor:", "do:", "exportMethod:of:on:", "sorted:", "<=", "selector", "lf"]}),
  509. smalltalk.ChunkExporter);
  510. smalltalk.addMethod(
  511. smalltalk.method({
  512. selector: "exportMethodsOf:on:",
  513. fn: function (aClass,aStream){
  514. var self=this;
  515. var map;
  516. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  517. return smalltalk.withContext(function($ctx1) {
  518. var $1;
  519. map=_st($Dictionary())._new();
  520. _st(aClass)._protocolsDo_((function(category,methods){
  521. return smalltalk.withContext(function($ctx2) {
  522. $1=_st(category)._match_("^\x5c*");
  523. if(! smalltalk.assert($1)){
  524. return _st(map)._at_put_(category,methods);
  525. };
  526. }, function($ctx2) {$ctx2.fillBlock({category:category,methods:methods},$ctx1)})}));
  527. _st(_st(_st(map)._keys())._sorted_((function(a,b){
  528. return smalltalk.withContext(function($ctx2) {
  529. return _st(a).__lt_eq(b);
  530. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})})))._do_((function(category){
  531. var methods;
  532. return smalltalk.withContext(function($ctx2) {
  533. methods=_st(map)._at_(category);
  534. methods;
  535. return self._exportMethods_category_of_on_(methods,category,aClass,aStream);
  536. }, function($ctx2) {$ctx2.fillBlock({category:category,methods:methods},$ctx1)})}));
  537. return self}, function($ctx1) {$ctx1.fill(self,"exportMethodsOf:on:",{aClass:aClass,aStream:aStream,map:map},smalltalk.ChunkExporter)})},
  538. messageSends: ["new", "protocolsDo:", "ifFalse:", "at:put:", "match:", "do:", "at:", "exportMethods:category:of:on:", "sorted:", "<=", "keys"]}),
  539. smalltalk.ChunkExporter);
  540. smalltalk.addMethod(
  541. smalltalk.method({
  542. selector: "exportPackageDefinitionOf:on:",
  543. fn: function (package_,aStream){
  544. var self=this;
  545. return smalltalk.withContext(function($ctx1) {
  546. var $1,$2;
  547. $1=aStream;
  548. _st($1)._nextPutAll_(_st("Smalltalk current createPackage: '".__comma(_st(package_)._name())).__comma("'!"));
  549. $2=_st($1)._lf();
  550. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageDefinitionOf:on:",{package_:package_,aStream:aStream},smalltalk.ChunkExporter)})},
  551. messageSends: ["nextPutAll:", ",", "name", "lf"]}),
  552. smalltalk.ChunkExporter);
  553. smalltalk.addMethod(
  554. smalltalk.method({
  555. selector: "exportPackageExtensionsOf:on:",
  556. fn: function (package_,aStream){
  557. var self=this;
  558. var name,map;
  559. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  560. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  561. function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
  562. return smalltalk.withContext(function($ctx1) {
  563. var $1;
  564. name=_st(package_)._name();
  565. _st(_st($Package())._sortedClasses_(_st(_st($Smalltalk())._current())._classes()))._do_((function(each){
  566. return smalltalk.withContext(function($ctx2) {
  567. return _st([each,_st(each)._class()])._do_((function(aClass){
  568. return smalltalk.withContext(function($ctx3) {
  569. map=_st($Dictionary())._new();
  570. map;
  571. _st(aClass)._protocolsDo_((function(category,methods){
  572. return smalltalk.withContext(function($ctx4) {
  573. $1=_st(category)._match_("^\x5c*".__comma(name));
  574. if(smalltalk.assert($1)){
  575. return _st(map)._at_put_(category,methods);
  576. };
  577. }, function($ctx4) {$ctx4.fillBlock({category:category,methods:methods},$ctx3)})}));
  578. return _st(_st(_st(map)._keys())._sorted_((function(a,b){
  579. return smalltalk.withContext(function($ctx4) {
  580. return _st(a).__lt_eq(b);
  581. }, function($ctx4) {$ctx4.fillBlock({a:a,b:b},$ctx3)})})))._do_((function(category){
  582. var methods;
  583. return smalltalk.withContext(function($ctx4) {
  584. methods=_st(map)._at_(category);
  585. methods;
  586. return self._exportMethods_category_of_on_(methods,category,aClass,aStream);
  587. }, function($ctx4) {$ctx4.fillBlock({category:category,methods:methods},$ctx3)})}));
  588. }, function($ctx3) {$ctx3.fillBlock({aClass:aClass},$ctx2)})}));
  589. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  590. return self}, function($ctx1) {$ctx1.fill(self,"exportPackageExtensionsOf:on:",{package_:package_,aStream:aStream,name:name,map:map},smalltalk.ChunkExporter)})},
  591. messageSends: ["name", "do:", "new", "protocolsDo:", "ifTrue:", "at:put:", "match:", ",", "at:", "exportMethods:category:of:on:", "sorted:", "<=", "keys", "class", "sortedClasses:", "classes", "current"]}),
  592. smalltalk.ChunkExporter);
  593. smalltalk.addClass('StrippedExporter', smalltalk.Exporter, [], 'Importer-Exporter');
  594. smalltalk.addMethod(
  595. smalltalk.method({
  596. selector: "exportDefinitionOf:on:",
  597. fn: function (aClass,aStream){
  598. var self=this;
  599. return smalltalk.withContext(function($ctx1) {
  600. var $1,$2,$3,$4;
  601. $1=aStream;
  602. _st($1)._nextPutAll_("smalltalk.addClass(");
  603. _st($1)._nextPutAll_(_st("'".__comma(self._classNameFor_(aClass))).__comma("', "));
  604. _st($1)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(_st(aClass)._superclass())));
  605. $2=_st($1)._nextPutAll_(", [");
  606. _st(_st(aClass)._instanceVariableNames())._do_separatedBy_((function(each){
  607. return smalltalk.withContext(function($ctx2) {
  608. return _st(aStream)._nextPutAll_(_st("'".__comma(each)).__comma("'"));
  609. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  610. return smalltalk.withContext(function($ctx2) {
  611. return _st(aStream)._nextPutAll_(", ");
  612. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  613. $3=aStream;
  614. _st($3)._nextPutAll_("], '");
  615. _st($3)._nextPutAll_(_st(_st(aClass)._category()).__comma("'"));
  616. $4=_st($3)._nextPutAll_(");");
  617. _st(aStream)._lf();
  618. return self}, function($ctx1) {$ctx1.fill(self,"exportDefinitionOf:on:",{aClass:aClass,aStream:aStream},smalltalk.StrippedExporter)})},
  619. messageSends: ["nextPutAll:", ",", "classNameFor:", "superclass", "do:separatedBy:", "instanceVariableNames", "category", "lf"]}),
  620. smalltalk.StrippedExporter);
  621. smalltalk.addMethod(
  622. smalltalk.method({
  623. selector: "exportMethod:of:on:",
  624. fn: function (aMethod,aClass,aStream){
  625. var self=this;
  626. return smalltalk.withContext(function($ctx1) {
  627. var $1,$2;
  628. $1=aStream;
  629. _st($1)._nextPutAll_("smalltalk.addMethod(");
  630. _st($1)._lf();
  631. _st($1)._nextPutAll_("smalltalk.method({");
  632. _st($1)._lf();
  633. _st($1)._nextPutAll_(_st("selector: ".__comma(_st(_st(aMethod)._selector())._asJavascript())).__comma(","));
  634. _st($1)._lf();
  635. _st($1)._nextPutAll_(_st("fn: ".__comma(_st(_st(aMethod)._fn())._compiledSource())).__comma(","));
  636. _st($1)._lf();
  637. _st($1)._nextPutAll_("messageSends: ".__comma(_st(_st(aMethod)._messageSends())._asJavascript()));
  638. _st($1)._nextPutAll_("}),");
  639. _st($1)._lf();
  640. _st($1)._nextPutAll_("smalltalk.".__comma(self._classNameFor_(aClass)));
  641. _st($1)._nextPutAll_(");");
  642. _st($1)._lf();
  643. $2=_st($1)._lf();
  644. return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:of:on:",{aMethod:aMethod,aClass:aClass,aStream:aStream},smalltalk.StrippedExporter)})},
  645. messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "selector", "compiledSource", "fn", "messageSends", "classNameFor:"]}),
  646. smalltalk.StrippedExporter);
  647. smalltalk.addClass('Importer', smalltalk.Object, [], 'Importer-Exporter');
  648. smalltalk.addMethod(
  649. smalltalk.method({
  650. selector: "import:",
  651. fn: function (aStream){
  652. var self=this;
  653. var chunk,result,parser,lastEmpty;
  654. function $ChunkParser(){return smalltalk.ChunkParser||(typeof ChunkParser=="undefined"?nil:ChunkParser)}
  655. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  656. return smalltalk.withContext(function($ctx1) {
  657. var $1,$2;
  658. parser=_st($ChunkParser())._on_(aStream);
  659. lastEmpty=false;
  660. _st((function(){
  661. return smalltalk.withContext(function($ctx2) {
  662. chunk=_st(parser)._nextChunk();
  663. chunk;
  664. return _st(chunk)._isNil();
  665. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
  666. return smalltalk.withContext(function($ctx2) {
  667. $1=_st(chunk)._isEmpty();
  668. if(smalltalk.assert($1)){
  669. lastEmpty=true;
  670. return lastEmpty;
  671. } else {
  672. result=_st(_st($Compiler())._new())._evaluateExpression_(chunk);
  673. result;
  674. $2=lastEmpty;
  675. if(smalltalk.assert($2)){
  676. lastEmpty=false;
  677. lastEmpty;
  678. return _st(result)._scanFrom_(parser);
  679. };
  680. };
  681. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  682. return self}, function($ctx1) {$ctx1.fill(self,"import:",{aStream:aStream,chunk:chunk,result:result,parser:parser,lastEmpty:lastEmpty},smalltalk.Importer)})},
  683. messageSends: ["on:", "whileFalse:", "ifTrue:ifFalse:", "evaluateExpression:", "new", "ifTrue:", "scanFrom:", "isEmpty", "nextChunk", "isNil"]}),
  684. smalltalk.Importer);
  685. smalltalk.addClass('PackageHandler', smalltalk.Object, [], 'Importer-Exporter');
  686. smalltalk.addMethod(
  687. smalltalk.method({
  688. selector: "ajaxPutAt:data:",
  689. fn: function (aURL,aString){
  690. var self=this;
  691. return smalltalk.withContext(function($ctx1) {
  692. _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){
  693. return smalltalk.withContext(function($ctx2) {
  694. return self._error_(_st(_st(_st("Commiting ".__comma(aURL)).__comma(" failed with reason: \x22")).__comma(_st(xhr)._responseText())).__comma("\x22"));
  695. }, function($ctx2) {$ctx2.fillBlock({xhr:xhr},$ctx1)})}))]));
  696. return self}, function($ctx1) {$ctx1.fill(self,"ajaxPutAt:data:",{aURL:aURL,aString:aString},smalltalk.PackageHandler)})},
  697. messageSends: ["ajax:options:", "->", "error:", ",", "responseText"]}),
  698. smalltalk.PackageHandler);
  699. smalltalk.addMethod(
  700. smalltalk.method({
  701. selector: "commit:",
  702. fn: function (aPackage){
  703. var self=this;
  704. return smalltalk.withContext(function($ctx1) {
  705. _st(self._commitChannels())._do_displayingProgress_((function(commitStrategyFactory){
  706. var fileContents,commitStrategy;
  707. return smalltalk.withContext(function($ctx2) {
  708. commitStrategy=_st(commitStrategyFactory)._value_(aPackage);
  709. commitStrategy;
  710. fileContents=_st(_st(commitStrategy)._key())._exportPackage_(_st(aPackage)._name());
  711. fileContents;
  712. return self._ajaxPutAt_data_(_st(commitStrategy)._value(),fileContents);
  713. }, function($ctx2) {$ctx2.fillBlock({commitStrategyFactory:commitStrategyFactory,fileContents:fileContents,commitStrategy:commitStrategy},$ctx1)})}),"Committing package ".__comma(_st(aPackage)._name()));
  714. return self}, function($ctx1) {$ctx1.fill(self,"commit:",{aPackage:aPackage},smalltalk.PackageHandler)})},
  715. messageSends: ["do:displayingProgress:", "value:", "exportPackage:", "name", "key", "ajaxPutAt:data:", "value", ",", "commitChannels"]}),
  716. smalltalk.PackageHandler);
  717. smalltalk.PackageHandler.klass.iVarNames = ['registry'];
  718. smalltalk.addMethod(
  719. smalltalk.method({
  720. selector: "classRegisteredFor:",
  721. fn: function (aString){
  722. var self=this;
  723. return smalltalk.withContext(function($ctx1) {
  724. var $1;
  725. $1=_st(self["@registry"])._at_(aString);
  726. return $1;
  727. }, function($ctx1) {$ctx1.fill(self,"classRegisteredFor:",{aString:aString},smalltalk.PackageHandler.klass)})},
  728. messageSends: ["at:"]}),
  729. smalltalk.PackageHandler.klass);
  730. smalltalk.addMethod(
  731. smalltalk.method({
  732. selector: "for:",
  733. fn: function (aString){
  734. var self=this;
  735. return smalltalk.withContext(function($ctx1) {
  736. var $1;
  737. $1=_st(self._classRegisteredFor_(aString))._new();
  738. return $1;
  739. }, function($ctx1) {$ctx1.fill(self,"for:",{aString:aString},smalltalk.PackageHandler.klass)})},
  740. messageSends: ["new", "classRegisteredFor:"]}),
  741. smalltalk.PackageHandler.klass);
  742. smalltalk.addMethod(
  743. smalltalk.method({
  744. selector: "initialize",
  745. fn: function (){
  746. var self=this;
  747. return smalltalk.withContext(function($ctx1) {
  748. smalltalk.PackageHandler.klass.superclass.fn.prototype._initialize.apply(_st(self), []);
  749. self["@registry"]=smalltalk.HashedCollection._from_([]);
  750. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.PackageHandler.klass)})},
  751. messageSends: ["initialize"]}),
  752. smalltalk.PackageHandler.klass);
  753. smalltalk.addMethod(
  754. smalltalk.method({
  755. selector: "register:for:",
  756. fn: function (aClass,aString){
  757. var self=this;
  758. return smalltalk.withContext(function($ctx1) {
  759. _st(self["@registry"])._at_put_(aString,aClass);
  760. return self}, function($ctx1) {$ctx1.fill(self,"register:for:",{aClass:aClass,aString:aString},smalltalk.PackageHandler.klass)})},
  761. messageSends: ["at:put:"]}),
  762. smalltalk.PackageHandler.klass);
  763. smalltalk.addMethod(
  764. smalltalk.method({
  765. selector: "registerFor:",
  766. fn: function (aString){
  767. var self=this;
  768. function $PackageHandler(){return smalltalk.PackageHandler||(typeof PackageHandler=="undefined"?nil:PackageHandler)}
  769. return smalltalk.withContext(function($ctx1) {
  770. _st($PackageHandler())._register_for_(self,aString);
  771. return self}, function($ctx1) {$ctx1.fill(self,"registerFor:",{aString:aString},smalltalk.PackageHandler.klass)})},
  772. messageSends: ["register:for:"]}),
  773. smalltalk.PackageHandler.klass);
  774. smalltalk.addClass('LegacyPackageHandler', smalltalk.PackageHandler, [], 'Importer-Exporter');
  775. smalltalk.addMethod(
  776. smalltalk.method({
  777. selector: "commitChannels",
  778. fn: function (){
  779. var self=this;
  780. function $Exporter(){return smalltalk.Exporter||(typeof Exporter=="undefined"?nil:Exporter)}
  781. function $StrippedExporter(){return smalltalk.StrippedExporter||(typeof StrippedExporter=="undefined"?nil:StrippedExporter)}
  782. function $ChunkExporter(){return smalltalk.ChunkExporter||(typeof ChunkExporter=="undefined"?nil:ChunkExporter)}
  783. return smalltalk.withContext(function($ctx1) {
  784. var $1;
  785. $1=[(function(pkg){
  786. return smalltalk.withContext(function($ctx2) {
  787. return _st(_st($Exporter())._new()).__minus_gt(_st(_st(_st(_st(pkg)._commitPathJs()).__comma("/")).__comma(_st(pkg)._name())).__comma(".js"));
  788. }, function($ctx2) {$ctx2.fillBlock({pkg:pkg},$ctx1)})}),(function(pkg){
  789. return smalltalk.withContext(function($ctx2) {
  790. return _st(_st($StrippedExporter())._new()).__minus_gt(_st(_st(_st(_st(pkg)._commitPathJs()).__comma("/")).__comma(_st(pkg)._name())).__comma(".deploy.js"));
  791. }, function($ctx2) {$ctx2.fillBlock({pkg:pkg},$ctx1)})}),(function(pkg){
  792. return smalltalk.withContext(function($ctx2) {
  793. return _st(_st($ChunkExporter())._new()).__minus_gt(_st(_st(_st(_st(pkg)._commitPathSt()).__comma("/")).__comma(_st(pkg)._name())).__comma(".st"));
  794. }, function($ctx2) {$ctx2.fillBlock({pkg:pkg},$ctx1)})})];
  795. return $1;
  796. }, function($ctx1) {$ctx1.fill(self,"commitChannels",{},smalltalk.LegacyPackageHandler)})},
  797. messageSends: ["->", ",", "name", "commitPathJs", "new", "commitPathSt"]}),
  798. smalltalk.LegacyPackageHandler);
  799. smalltalk.addMethod(
  800. smalltalk.method({
  801. selector: "commitPathJsFor:",
  802. fn: function (aPackage){
  803. var self=this;
  804. return smalltalk.withContext(function($ctx1) {
  805. var $1;
  806. $1=_st(self._class())._defaultCommitPathJs();
  807. return $1;
  808. }, function($ctx1) {$ctx1.fill(self,"commitPathJsFor:",{aPackage:aPackage},smalltalk.LegacyPackageHandler)})},
  809. messageSends: ["defaultCommitPathJs", "class"]}),
  810. smalltalk.LegacyPackageHandler);
  811. smalltalk.addMethod(
  812. smalltalk.method({
  813. selector: "commitPathStFor:",
  814. fn: function (aPackage){
  815. var self=this;
  816. return smalltalk.withContext(function($ctx1) {
  817. var $1;
  818. $1=_st(self._class())._defaultCommitPathSt();
  819. return $1;
  820. }, function($ctx1) {$ctx1.fill(self,"commitPathStFor:",{aPackage:aPackage},smalltalk.LegacyPackageHandler)})},
  821. messageSends: ["defaultCommitPathSt", "class"]}),
  822. smalltalk.LegacyPackageHandler);
  823. smalltalk.addMethod(
  824. smalltalk.method({
  825. selector: "loadPackage:prefix:",
  826. fn: function (packageName,aString){
  827. var self=this;
  828. var url;
  829. return smalltalk.withContext(function($ctx1) {
  830. var $1;
  831. url=_st(_st(_st("/".__comma(aString)).__comma("/js/")).__comma(packageName)).__comma(".js");
  832. _st(jQuery)._ajax_options_(url,smalltalk.HashedCollection._from_(["type".__minus_gt("GET"),"dataType".__minus_gt("script"),"complete".__minus_gt((function(jqXHR,textStatus){
  833. return smalltalk.withContext(function($ctx2) {
  834. $1=_st(_st(jqXHR)._readyState()).__eq((4));
  835. if(smalltalk.assert($1)){
  836. return self._setupPackageNamed_prefix_(packageName,aString);
  837. };
  838. }, function($ctx2) {$ctx2.fillBlock({jqXHR:jqXHR,textStatus:textStatus},$ctx1)})})),"error".__minus_gt((function(){
  839. return smalltalk.withContext(function($ctx2) {
  840. return _st(window)._alert_("Could not load package at: ".__comma(url));
  841. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))]));
  842. return self}, function($ctx1) {$ctx1.fill(self,"loadPackage:prefix:",{packageName:packageName,aString:aString,url:url},smalltalk.LegacyPackageHandler)})},
  843. messageSends: [",", "ajax:options:", "->", "ifTrue:", "setupPackageNamed:prefix:", "=", "readyState", "alert:"]}),
  844. smalltalk.LegacyPackageHandler);
  845. smalltalk.addMethod(
  846. smalltalk.method({
  847. selector: "loadPackages:prefix:",
  848. fn: function (aCollection,aString){
  849. var self=this;
  850. return smalltalk.withContext(function($ctx1) {
  851. _st(aCollection)._do_((function(each){
  852. return smalltalk.withContext(function($ctx2) {
  853. return self._loadPackage_prefix_(each,aString);
  854. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  855. return self}, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.LegacyPackageHandler)})},
  856. messageSends: ["do:", "loadPackage:prefix:"]}),
  857. smalltalk.LegacyPackageHandler);
  858. smalltalk.addMethod(
  859. smalltalk.method({
  860. selector: "setupPackageNamed:prefix:",
  861. fn: function (packageName,aString){
  862. var self=this;
  863. function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
  864. return smalltalk.withContext(function($ctx1) {
  865. var $1,$2;
  866. $1=_st($Package())._named_(packageName);
  867. _st($1)._setupClasses();
  868. _st($1)._commitPathJs_(_st("/".__comma(aString)).__comma("/js"));
  869. $2=_st($1)._commitPathSt_(_st("/".__comma(aString)).__comma("/st"));
  870. return self}, function($ctx1) {$ctx1.fill(self,"setupPackageNamed:prefix:",{packageName:packageName,aString:aString},smalltalk.LegacyPackageHandler)})},
  871. messageSends: ["setupClasses", "named:", "commitPathJs:", ",", "commitPathSt:"]}),
  872. smalltalk.LegacyPackageHandler);
  873. smalltalk.LegacyPackageHandler.klass.iVarNames = ['defaultCommitPathJs','defaultCommitPathSt'];
  874. smalltalk.addMethod(
  875. smalltalk.method({
  876. selector: "commitPathsFromLoader",
  877. fn: function (){
  878. var self=this;
  879. return smalltalk.withContext(function($ctx1) {
  880. var commitPath = typeof amber !== 'undefined' && amber.commitPath;
  881. if (!commitPath) return;
  882. if (commitPath.js) self._defaultCommitPathJs_(commitPath.js);
  883. if (commitPath.st) self._defaultCommitPathSt_(commitPath.st);
  884. ;
  885. return self}, function($ctx1) {$ctx1.fill(self,"commitPathsFromLoader",{},smalltalk.LegacyPackageHandler.klass)})},
  886. messageSends: []}),
  887. smalltalk.LegacyPackageHandler.klass);
  888. smalltalk.addMethod(
  889. smalltalk.method({
  890. selector: "defaultCommitPathJs",
  891. fn: function (){
  892. var self=this;
  893. return smalltalk.withContext(function($ctx1) {
  894. var $2,$1;
  895. $2=self["@defaultCommitPathJs"];
  896. if(($receiver = $2) == nil || $receiver == undefined){
  897. self["@defaultCommitPathJs"]="js";
  898. $1=self["@defaultCommitPathJs"];
  899. } else {
  900. $1=$2;
  901. };
  902. return $1;
  903. }, function($ctx1) {$ctx1.fill(self,"defaultCommitPathJs",{},smalltalk.LegacyPackageHandler.klass)})},
  904. messageSends: ["ifNil:"]}),
  905. smalltalk.LegacyPackageHandler.klass);
  906. smalltalk.addMethod(
  907. smalltalk.method({
  908. selector: "defaultCommitPathJs:",
  909. fn: function (aString){
  910. var self=this;
  911. return smalltalk.withContext(function($ctx1) {
  912. self["@defaultCommitPathJs"]=aString;
  913. return self}, function($ctx1) {$ctx1.fill(self,"defaultCommitPathJs:",{aString:aString},smalltalk.LegacyPackageHandler.klass)})},
  914. messageSends: []}),
  915. smalltalk.LegacyPackageHandler.klass);
  916. smalltalk.addMethod(
  917. smalltalk.method({
  918. selector: "defaultCommitPathSt",
  919. fn: function (){
  920. var self=this;
  921. return smalltalk.withContext(function($ctx1) {
  922. var $2,$1;
  923. $2=self["@defaultCommitPathSt"];
  924. if(($receiver = $2) == nil || $receiver == undefined){
  925. self["@defaultCommitPathSt"]="st";
  926. $1=self["@defaultCommitPathSt"];
  927. } else {
  928. $1=$2;
  929. };
  930. return $1;
  931. }, function($ctx1) {$ctx1.fill(self,"defaultCommitPathSt",{},smalltalk.LegacyPackageHandler.klass)})},
  932. messageSends: ["ifNil:"]}),
  933. smalltalk.LegacyPackageHandler.klass);
  934. smalltalk.addMethod(
  935. smalltalk.method({
  936. selector: "defaultCommitPathSt:",
  937. fn: function (aString){
  938. var self=this;
  939. return smalltalk.withContext(function($ctx1) {
  940. self["@defaultCommitPathSt"]=aString;
  941. return self}, function($ctx1) {$ctx1.fill(self,"defaultCommitPathSt:",{aString:aString},smalltalk.LegacyPackageHandler.klass)})},
  942. messageSends: []}),
  943. smalltalk.LegacyPackageHandler.klass);
  944. smalltalk.addMethod(
  945. smalltalk.method({
  946. selector: "initialize",
  947. fn: function (){
  948. var self=this;
  949. return smalltalk.withContext(function($ctx1) {
  950. smalltalk.LegacyPackageHandler.klass.superclass.fn.prototype._initialize.apply(_st(self), []);
  951. self._registerFor_("unknown");
  952. self._commitPathsFromLoader();
  953. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.LegacyPackageHandler.klass)})},
  954. messageSends: ["initialize", "registerFor:", "commitPathsFromLoader"]}),
  955. smalltalk.LegacyPackageHandler.klass);
  956. smalltalk.addMethod(
  957. smalltalk.method({
  958. selector: "loadPackages:prefix:",
  959. fn: function (aCollection,aString){
  960. var self=this;
  961. return smalltalk.withContext(function($ctx1) {
  962. var $1;
  963. $1=_st(self._new())._loadPackages_prefix_(aCollection,aString);
  964. return $1;
  965. }, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.LegacyPackageHandler.klass)})},
  966. messageSends: ["loadPackages:prefix:", "new"]}),
  967. smalltalk.LegacyPackageHandler.klass);
  968. smalltalk.addMethod(
  969. smalltalk.method({
  970. selector: "resetCommitPaths",
  971. fn: function (){
  972. var self=this;
  973. return smalltalk.withContext(function($ctx1) {
  974. self["@defaultCommitPathJs"]=nil;
  975. self["@defaultCommitPathSt"]=nil;
  976. return self}, function($ctx1) {$ctx1.fill(self,"resetCommitPaths",{},smalltalk.LegacyPackageHandler.klass)})},
  977. messageSends: []}),
  978. smalltalk.LegacyPackageHandler.klass);
  979. smalltalk.addMethod(
  980. smalltalk.method({
  981. selector: "commit",
  982. fn: function (){
  983. var self=this;
  984. return smalltalk.withContext(function($ctx1) {
  985. var $1;
  986. $1=_st(self._transport())._commit_(self);
  987. return $1;
  988. }, function($ctx1) {$ctx1.fill(self,"commit",{},smalltalk.Package)})},
  989. messageSends: ["commit:", "transport"]}),
  990. smalltalk.Package);
  991. smalltalk.addMethod(
  992. smalltalk.method({
  993. selector: "commitPathJs",
  994. fn: function (){
  995. var self=this;
  996. return smalltalk.withContext(function($ctx1) {
  997. var $3,$2,$1;
  998. $3=self["@extension"];
  999. if(($receiver = $3) == nil || $receiver == undefined){
  1000. self["@extension"]=smalltalk.HashedCollection._from_([]);
  1001. $2=self["@extension"];
  1002. } else {
  1003. $2=$3;
  1004. };
  1005. $1=_st($2)._at_ifAbsentPut_("commitPathJs",(function(){
  1006. return smalltalk.withContext(function($ctx2) {
  1007. return _st(self._transport())._commitPathJsFor_(self);
  1008. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1009. return $1;
  1010. }, function($ctx1) {$ctx1.fill(self,"commitPathJs",{},smalltalk.Package)})},
  1011. messageSends: ["at:ifAbsentPut:", "commitPathJsFor:", "transport", "ifNil:"]}),
  1012. smalltalk.Package);
  1013. smalltalk.addMethod(
  1014. smalltalk.method({
  1015. selector: "commitPathJs:",
  1016. fn: function (aString){
  1017. var self=this;
  1018. return smalltalk.withContext(function($ctx1) {
  1019. var $3,$2,$1;
  1020. $3=self["@extension"];
  1021. if(($receiver = $3) == nil || $receiver == undefined){
  1022. self["@extension"]=smalltalk.HashedCollection._from_([]);
  1023. $2=self["@extension"];
  1024. } else {
  1025. $2=$3;
  1026. };
  1027. $1=_st($2)._at_put_("commitPathJs",aString);
  1028. return $1;
  1029. }, function($ctx1) {$ctx1.fill(self,"commitPathJs:",{aString:aString},smalltalk.Package)})},
  1030. messageSends: ["at:put:", "ifNil:"]}),
  1031. smalltalk.Package);
  1032. smalltalk.addMethod(
  1033. smalltalk.method({
  1034. selector: "commitPathSt",
  1035. fn: function (){
  1036. var self=this;
  1037. return smalltalk.withContext(function($ctx1) {
  1038. var $3,$2,$1;
  1039. $3=self["@extension"];
  1040. if(($receiver = $3) == nil || $receiver == undefined){
  1041. self["@extension"]=smalltalk.HashedCollection._from_([]);
  1042. $2=self["@extension"];
  1043. } else {
  1044. $2=$3;
  1045. };
  1046. $1=_st($2)._at_ifAbsentPut_("commitPathSt",(function(){
  1047. return smalltalk.withContext(function($ctx2) {
  1048. return _st(self._transport())._commitPathStFor_(self);
  1049. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1050. return $1;
  1051. }, function($ctx1) {$ctx1.fill(self,"commitPathSt",{},smalltalk.Package)})},
  1052. messageSends: ["at:ifAbsentPut:", "commitPathStFor:", "transport", "ifNil:"]}),
  1053. smalltalk.Package);
  1054. smalltalk.addMethod(
  1055. smalltalk.method({
  1056. selector: "commitPathSt:",
  1057. fn: function (aString){
  1058. var self=this;
  1059. return smalltalk.withContext(function($ctx1) {
  1060. var $3,$2,$1;
  1061. $3=self["@extension"];
  1062. if(($receiver = $3) == nil || $receiver == undefined){
  1063. self["@extension"]=smalltalk.HashedCollection._from_([]);
  1064. $2=self["@extension"];
  1065. } else {
  1066. $2=$3;
  1067. };
  1068. $1=_st($2)._at_put_("commitPathSt",aString);
  1069. return $1;
  1070. }, function($ctx1) {$ctx1.fill(self,"commitPathSt:",{aString:aString},smalltalk.Package)})},
  1071. messageSends: ["at:put:", "ifNil:"]}),
  1072. smalltalk.Package);
  1073. smalltalk.addMethod(
  1074. smalltalk.method({
  1075. selector: "transport",
  1076. fn: function (){
  1077. var self=this;
  1078. function $PackageHandler(){return smalltalk.PackageHandler||(typeof PackageHandler=="undefined"?nil:PackageHandler)}
  1079. return smalltalk.withContext(function($ctx1) {
  1080. var $1;
  1081. $1=_st($PackageHandler())._for_(self._transportType());
  1082. return $1;
  1083. }, function($ctx1) {$ctx1.fill(self,"transport",{},smalltalk.Package)})},
  1084. messageSends: ["for:", "transportType"]}),
  1085. smalltalk.Package);
  1086. smalltalk.addMethod(
  1087. smalltalk.method({
  1088. selector: "transportType",
  1089. fn: function (){
  1090. var self=this;
  1091. return smalltalk.withContext(function($ctx1) {
  1092. return (self.transport && self.transport.type) || 'unknown';;
  1093. return self}, function($ctx1) {$ctx1.fill(self,"transportType",{},smalltalk.Package)})},
  1094. messageSends: []}),
  1095. smalltalk.Package);
  1096. });