Kernel-Methods.js 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926
  1. define("amber_core/Kernel-Methods", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st, globals){
  2. smalltalk.addPackage('Kernel-Methods');
  3. smalltalk.packages["Kernel-Methods"].transport = {"type":"amd","amdNamespace":"amber_core"};
  4. smalltalk.addClass('BlockClosure', globals.Object, [], 'Kernel-Methods');
  5. globals.BlockClosure.comment="I represent a lexical closure.\x0aI am is directly mapped to JavaScript Function.\x0a\x0a## API\x0a\x0a1. Evaluation\x0a\x0a My instances get evaluated with the `#value*` methods in the 'evaluating' protocol.\x0a\x0a Example: ` [ :x | x + 1 ] value: 3 \x22Answers 4\x22 `\x0a\x0a2. Control structures\x0a\x0a Blocks are used (together with `Boolean`) for control structures (methods in the `controlling` protocol).\x0a\x0a Example: `aBlock whileTrue: [ ... ]`\x0a\x0a3. Error handling\x0a\x0a I provide the `#on:do:` method for handling exceptions.\x0a\x0a Example: ` aBlock on: MessageNotUnderstood do: [ :ex | ... ] `";
  6. smalltalk.addMethod(
  7. smalltalk.method({
  8. selector: "applyTo:arguments:",
  9. protocol: 'evaluating',
  10. fn: function (anObject,aCollection){
  11. var self=this;
  12. return smalltalk.withContext(function($ctx1) {
  13. return self.apply(anObject, aCollection);
  14. return self}, function($ctx1) {$ctx1.fill(self,"applyTo:arguments:",{anObject:anObject,aCollection:aCollection},globals.BlockClosure)})},
  15. args: ["anObject", "aCollection"],
  16. source: "applyTo: anObject arguments: aCollection\x0a\x09<return self.apply(anObject, aCollection)>",
  17. messageSends: [],
  18. referencedClasses: []
  19. }),
  20. globals.BlockClosure);
  21. smalltalk.addMethod(
  22. smalltalk.method({
  23. selector: "asCompiledMethod:",
  24. protocol: 'converting',
  25. fn: function (aString){
  26. var self=this;
  27. return smalltalk.withContext(function($ctx1) {
  28. return smalltalk.method({selector:aString, fn:self});;
  29. return self}, function($ctx1) {$ctx1.fill(self,"asCompiledMethod:",{aString:aString},globals.BlockClosure)})},
  30. args: ["aString"],
  31. source: "asCompiledMethod: aString\x0a\x09<return smalltalk.method({selector:aString, fn:self});>",
  32. messageSends: [],
  33. referencedClasses: []
  34. }),
  35. globals.BlockClosure);
  36. smalltalk.addMethod(
  37. smalltalk.method({
  38. selector: "compiledSource",
  39. protocol: 'accessing',
  40. fn: function (){
  41. var self=this;
  42. return smalltalk.withContext(function($ctx1) {
  43. return self.toString();
  44. return self}, function($ctx1) {$ctx1.fill(self,"compiledSource",{},globals.BlockClosure)})},
  45. args: [],
  46. source: "compiledSource\x0a\x09<return self.toString()>",
  47. messageSends: [],
  48. referencedClasses: []
  49. }),
  50. globals.BlockClosure);
  51. smalltalk.addMethod(
  52. smalltalk.method({
  53. selector: "currySelf",
  54. protocol: 'converting',
  55. fn: function (){
  56. var self=this;
  57. return smalltalk.withContext(function($ctx1) {
  58. return function () {
  59. var args = [ this ];
  60. args.push.apply(args, arguments);
  61. return self.apply(null, args);
  62. }
  63. ;
  64. return self}, function($ctx1) {$ctx1.fill(self,"currySelf",{},globals.BlockClosure)})},
  65. args: [],
  66. source: "currySelf\x0a\x09\x22Transforms [ :selfarg :x :y | stcode ] block\x0a\x09which represents JS function (selfarg, x, y, ...) {jscode}\x0a\x09into function (x, y, ...) {jscode} that takes selfarg from 'this'.\x0a\x09IOW, it is usable as JS method and first arg takes the receiver.\x22\x0a\x09\x0a\x09<\x0a\x09\x09return function () {\x0a\x09\x09\x09var args = [ this ];\x0a\x09\x09\x09args.push.apply(args, arguments);\x0a\x09\x09\x09return self.apply(null, args);\x0a\x09\x09}\x0a\x09>",
  67. messageSends: [],
  68. referencedClasses: []
  69. }),
  70. globals.BlockClosure);
  71. smalltalk.addMethod(
  72. smalltalk.method({
  73. selector: "ensure:",
  74. protocol: 'evaluating',
  75. fn: function (aBlock){
  76. var self=this;
  77. return smalltalk.withContext(function($ctx1) {
  78. try{return self._value()}finally{aBlock._value()};
  79. return self}, function($ctx1) {$ctx1.fill(self,"ensure:",{aBlock:aBlock},globals.BlockClosure)})},
  80. args: ["aBlock"],
  81. source: "ensure: aBlock\x0a\x09<try{return self._value()}finally{aBlock._value()}>",
  82. messageSends: [],
  83. referencedClasses: []
  84. }),
  85. globals.BlockClosure);
  86. smalltalk.addMethod(
  87. smalltalk.method({
  88. selector: "fork",
  89. protocol: 'timeout/interval',
  90. fn: function (){
  91. var self=this;
  92. function $ForkPool(){return globals.ForkPool||(typeof ForkPool=="undefined"?nil:ForkPool)}
  93. return smalltalk.withContext(function($ctx1) {
  94. _st(_st($ForkPool())._default())._fork_(self);
  95. return self}, function($ctx1) {$ctx1.fill(self,"fork",{},globals.BlockClosure)})},
  96. args: [],
  97. source: "fork\x0a\x09ForkPool default fork: self",
  98. messageSends: ["fork:", "default"],
  99. referencedClasses: ["ForkPool"]
  100. }),
  101. globals.BlockClosure);
  102. smalltalk.addMethod(
  103. smalltalk.method({
  104. selector: "new",
  105. protocol: 'evaluating',
  106. fn: function (){
  107. var self=this;
  108. return smalltalk.withContext(function($ctx1) {
  109. return new self();
  110. return self}, function($ctx1) {$ctx1.fill(self,"new",{},globals.BlockClosure)})},
  111. args: [],
  112. source: "new\x0a\x09\x22Use the receiver as a JS constructor.\x0a\x09*Do not* use this method to instanciate Smalltalk objects!\x22\x0a\x09<return new self()>",
  113. messageSends: [],
  114. referencedClasses: []
  115. }),
  116. globals.BlockClosure);
  117. smalltalk.addMethod(
  118. smalltalk.method({
  119. selector: "newValue:",
  120. protocol: 'evaluating',
  121. fn: function (anObject){
  122. var self=this;
  123. return smalltalk.withContext(function($ctx1) {
  124. var $1;
  125. $1=self._newWithValues_([anObject]);
  126. return $1;
  127. }, function($ctx1) {$ctx1.fill(self,"newValue:",{anObject:anObject},globals.BlockClosure)})},
  128. args: ["anObject"],
  129. source: "newValue: anObject\x0a\x09^ self newWithValues: { anObject }",
  130. messageSends: ["newWithValues:"],
  131. referencedClasses: []
  132. }),
  133. globals.BlockClosure);
  134. smalltalk.addMethod(
  135. smalltalk.method({
  136. selector: "newValue:value:",
  137. protocol: 'evaluating',
  138. fn: function (anObject,anObject2){
  139. var self=this;
  140. return smalltalk.withContext(function($ctx1) {
  141. var $1;
  142. $1=self._newWithValues_([anObject,anObject2]);
  143. return $1;
  144. }, function($ctx1) {$ctx1.fill(self,"newValue:value:",{anObject:anObject,anObject2:anObject2},globals.BlockClosure)})},
  145. args: ["anObject", "anObject2"],
  146. source: "newValue: anObject value: anObject2\x0a\x09^ self newWithValues: { anObject. anObject2 }.",
  147. messageSends: ["newWithValues:"],
  148. referencedClasses: []
  149. }),
  150. globals.BlockClosure);
  151. smalltalk.addMethod(
  152. smalltalk.method({
  153. selector: "newValue:value:value:",
  154. protocol: 'evaluating',
  155. fn: function (anObject,anObject2,anObject3){
  156. var self=this;
  157. return smalltalk.withContext(function($ctx1) {
  158. var $1;
  159. $1=self._newWithValues_([anObject,anObject2,anObject3]);
  160. return $1;
  161. }, function($ctx1) {$ctx1.fill(self,"newValue:value:value:",{anObject:anObject,anObject2:anObject2,anObject3:anObject3},globals.BlockClosure)})},
  162. args: ["anObject", "anObject2", "anObject3"],
  163. source: "newValue: anObject value: anObject2 value: anObject3\x0a\x09^ self newWithValues: { anObject. anObject2. anObject3 }.",
  164. messageSends: ["newWithValues:"],
  165. referencedClasses: []
  166. }),
  167. globals.BlockClosure);
  168. smalltalk.addMethod(
  169. smalltalk.method({
  170. selector: "newWithValues:",
  171. protocol: 'evaluating',
  172. fn: function (aCollection){
  173. var self=this;
  174. return smalltalk.withContext(function($ctx1) {
  175. var object = Object.create(self.prototype);
  176. var result = self.apply(object, aCollection);
  177. return typeof result === "object" ? result : object;
  178. ;
  179. return self}, function($ctx1) {$ctx1.fill(self,"newWithValues:",{aCollection:aCollection},globals.BlockClosure)})},
  180. args: ["aCollection"],
  181. source: "newWithValues: aCollection\x0a\x09\x22Simulates JS new operator by combination of Object.create and .apply\x22\x0a\x09<\x0a\x09\x09var object = Object.create(self.prototype);\x0a\x09\x09var result = self.apply(object, aCollection);\x0a\x09\x09return typeof result === \x22object\x22 ? result : object;\x0a\x09>",
  182. messageSends: [],
  183. referencedClasses: []
  184. }),
  185. globals.BlockClosure);
  186. smalltalk.addMethod(
  187. smalltalk.method({
  188. selector: "numArgs",
  189. protocol: 'accessing',
  190. fn: function (){
  191. var self=this;
  192. return smalltalk.withContext(function($ctx1) {
  193. return self.length;
  194. return self}, function($ctx1) {$ctx1.fill(self,"numArgs",{},globals.BlockClosure)})},
  195. args: [],
  196. source: "numArgs\x0a\x09<return self.length>",
  197. messageSends: [],
  198. referencedClasses: []
  199. }),
  200. globals.BlockClosure);
  201. smalltalk.addMethod(
  202. smalltalk.method({
  203. selector: "on:do:",
  204. protocol: 'error handling',
  205. fn: function (anErrorClass,aBlock){
  206. var self=this;
  207. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  208. return smalltalk.withContext(function($ctx1) {
  209. var $2,$1;
  210. $1=self._try_catch_(self,(function(error){
  211. var smalltalkError;
  212. return smalltalk.withContext(function($ctx2) {
  213. smalltalkError=_st($Smalltalk())._asSmalltalkException_(error);
  214. smalltalkError;
  215. $2=_st(smalltalkError)._isKindOf_(anErrorClass);
  216. if(smalltalk.assert($2)){
  217. return _st(aBlock)._value_(smalltalkError);
  218. } else {
  219. return _st(smalltalkError)._resignal();
  220. };
  221. }, function($ctx2) {$ctx2.fillBlock({error:error,smalltalkError:smalltalkError},$ctx1,1)})}));
  222. return $1;
  223. }, function($ctx1) {$ctx1.fill(self,"on:do:",{anErrorClass:anErrorClass,aBlock:aBlock},globals.BlockClosure)})},
  224. args: ["anErrorClass", "aBlock"],
  225. source: "on: anErrorClass do: aBlock\x0a\x09\x22All exceptions thrown in the Smalltalk stack are cought.\x0a\x09Convert all JS exceptions to JavaScriptException instances.\x22\x0a\x09\x0a\x09^ self try: self catch: [ :error | | smalltalkError |\x0a\x09\x09smalltalkError := Smalltalk asSmalltalkException: error.\x0a\x09\x09(smalltalkError isKindOf: anErrorClass)\x0a\x09\x09ifTrue: [ aBlock value: smalltalkError ]\x0a\x09\x09ifFalse: [ smalltalkError resignal ] ]",
  226. messageSends: ["try:catch:", "asSmalltalkException:", "ifTrue:ifFalse:", "isKindOf:", "value:", "resignal"],
  227. referencedClasses: ["Smalltalk"]
  228. }),
  229. globals.BlockClosure);
  230. smalltalk.addMethod(
  231. smalltalk.method({
  232. selector: "receiver",
  233. protocol: 'accessing',
  234. fn: function (){
  235. var self=this;
  236. return nil;
  237. },
  238. args: [],
  239. source: "receiver\x0a\x09^ nil",
  240. messageSends: [],
  241. referencedClasses: []
  242. }),
  243. globals.BlockClosure);
  244. smalltalk.addMethod(
  245. smalltalk.method({
  246. selector: "timeToRun",
  247. protocol: 'evaluating',
  248. fn: function (){
  249. var self=this;
  250. function $Date(){return globals.Date||(typeof Date=="undefined"?nil:Date)}
  251. return smalltalk.withContext(function($ctx1) {
  252. var $1;
  253. $1=_st($Date())._millisecondsToRun_(self);
  254. return $1;
  255. }, function($ctx1) {$ctx1.fill(self,"timeToRun",{},globals.BlockClosure)})},
  256. args: [],
  257. source: "timeToRun\x0a\x09\x22Answer the number of milliseconds taken to execute this block.\x22\x0a\x0a\x09^ Date millisecondsToRun: self",
  258. messageSends: ["millisecondsToRun:"],
  259. referencedClasses: ["Date"]
  260. }),
  261. globals.BlockClosure);
  262. smalltalk.addMethod(
  263. smalltalk.method({
  264. selector: "value",
  265. protocol: 'evaluating',
  266. fn: function (){
  267. var self=this;
  268. return smalltalk.withContext(function($ctx1) {
  269. return self();;
  270. return self}, function($ctx1) {$ctx1.fill(self,"value",{},globals.BlockClosure)})},
  271. args: [],
  272. source: "value\x0a\x09<return self();>",
  273. messageSends: [],
  274. referencedClasses: []
  275. }),
  276. globals.BlockClosure);
  277. smalltalk.addMethod(
  278. smalltalk.method({
  279. selector: "value:",
  280. protocol: 'evaluating',
  281. fn: function (anArg){
  282. var self=this;
  283. return smalltalk.withContext(function($ctx1) {
  284. return self(anArg);;
  285. return self}, function($ctx1) {$ctx1.fill(self,"value:",{anArg:anArg},globals.BlockClosure)})},
  286. args: ["anArg"],
  287. source: "value: anArg\x0a\x09<return self(anArg);>",
  288. messageSends: [],
  289. referencedClasses: []
  290. }),
  291. globals.BlockClosure);
  292. smalltalk.addMethod(
  293. smalltalk.method({
  294. selector: "value:value:",
  295. protocol: 'evaluating',
  296. fn: function (firstArg,secondArg){
  297. var self=this;
  298. return smalltalk.withContext(function($ctx1) {
  299. return self(firstArg, secondArg);;
  300. return self}, function($ctx1) {$ctx1.fill(self,"value:value:",{firstArg:firstArg,secondArg:secondArg},globals.BlockClosure)})},
  301. args: ["firstArg", "secondArg"],
  302. source: "value: firstArg value: secondArg\x0a\x09<return self(firstArg, secondArg);>",
  303. messageSends: [],
  304. referencedClasses: []
  305. }),
  306. globals.BlockClosure);
  307. smalltalk.addMethod(
  308. smalltalk.method({
  309. selector: "value:value:value:",
  310. protocol: 'evaluating',
  311. fn: function (firstArg,secondArg,thirdArg){
  312. var self=this;
  313. return smalltalk.withContext(function($ctx1) {
  314. return self(firstArg, secondArg, thirdArg);;
  315. return self}, function($ctx1) {$ctx1.fill(self,"value:value:value:",{firstArg:firstArg,secondArg:secondArg,thirdArg:thirdArg},globals.BlockClosure)})},
  316. args: ["firstArg", "secondArg", "thirdArg"],
  317. source: "value: firstArg value: secondArg value: thirdArg\x0a\x09<return self(firstArg, secondArg, thirdArg);>",
  318. messageSends: [],
  319. referencedClasses: []
  320. }),
  321. globals.BlockClosure);
  322. smalltalk.addMethod(
  323. smalltalk.method({
  324. selector: "valueWithInterval:",
  325. protocol: 'timeout/interval',
  326. fn: function (aNumber){
  327. var self=this;
  328. return smalltalk.withContext(function($ctx1) {
  329. var interval = setInterval(self, aNumber);
  330. return globals.Timeout._on_(interval);
  331. ;
  332. return self}, function($ctx1) {$ctx1.fill(self,"valueWithInterval:",{aNumber:aNumber},globals.BlockClosure)})},
  333. args: ["aNumber"],
  334. source: "valueWithInterval: aNumber\x0a\x09<\x0a\x09\x09var interval = setInterval(self, aNumber);\x0a\x09\x09return globals.Timeout._on_(interval);\x0a\x09>",
  335. messageSends: [],
  336. referencedClasses: []
  337. }),
  338. globals.BlockClosure);
  339. smalltalk.addMethod(
  340. smalltalk.method({
  341. selector: "valueWithPossibleArguments:",
  342. protocol: 'evaluating',
  343. fn: function (aCollection){
  344. var self=this;
  345. return smalltalk.withContext(function($ctx1) {
  346. return self.apply(null, aCollection);;
  347. return self}, function($ctx1) {$ctx1.fill(self,"valueWithPossibleArguments:",{aCollection:aCollection},globals.BlockClosure)})},
  348. args: ["aCollection"],
  349. source: "valueWithPossibleArguments: aCollection\x0a\x09<return self.apply(null, aCollection);>",
  350. messageSends: [],
  351. referencedClasses: []
  352. }),
  353. globals.BlockClosure);
  354. smalltalk.addMethod(
  355. smalltalk.method({
  356. selector: "valueWithTimeout:",
  357. protocol: 'timeout/interval',
  358. fn: function (aNumber){
  359. var self=this;
  360. return smalltalk.withContext(function($ctx1) {
  361. var timeout = setTimeout(self, aNumber);
  362. return globals.Timeout._on_(timeout);
  363. ;
  364. return self}, function($ctx1) {$ctx1.fill(self,"valueWithTimeout:",{aNumber:aNumber},globals.BlockClosure)})},
  365. args: ["aNumber"],
  366. source: "valueWithTimeout: aNumber\x0a\x09<\x0a\x09\x09var timeout = setTimeout(self, aNumber);\x0a\x09\x09return globals.Timeout._on_(timeout);\x0a\x09>",
  367. messageSends: [],
  368. referencedClasses: []
  369. }),
  370. globals.BlockClosure);
  371. smalltalk.addMethod(
  372. smalltalk.method({
  373. selector: "whileFalse",
  374. protocol: 'controlling',
  375. fn: function (){
  376. var self=this;
  377. return smalltalk.withContext(function($ctx1) {
  378. self._whileFalse_((function(){
  379. }));
  380. return self}, function($ctx1) {$ctx1.fill(self,"whileFalse",{},globals.BlockClosure)})},
  381. args: [],
  382. source: "whileFalse\x0a\x09self whileFalse: []",
  383. messageSends: ["whileFalse:"],
  384. referencedClasses: []
  385. }),
  386. globals.BlockClosure);
  387. smalltalk.addMethod(
  388. smalltalk.method({
  389. selector: "whileFalse:",
  390. protocol: 'controlling',
  391. fn: function (aBlock){
  392. var self=this;
  393. return smalltalk.withContext(function($ctx1) {
  394. while(!smalltalk.assert(self._value())) {aBlock._value()};
  395. return self}, function($ctx1) {$ctx1.fill(self,"whileFalse:",{aBlock:aBlock},globals.BlockClosure)})},
  396. args: ["aBlock"],
  397. source: "whileFalse: aBlock\x0a\x09<while(!smalltalk.assert(self._value())) {aBlock._value()}>",
  398. messageSends: [],
  399. referencedClasses: []
  400. }),
  401. globals.BlockClosure);
  402. smalltalk.addMethod(
  403. smalltalk.method({
  404. selector: "whileTrue",
  405. protocol: 'controlling',
  406. fn: function (){
  407. var self=this;
  408. return smalltalk.withContext(function($ctx1) {
  409. self._whileTrue_((function(){
  410. }));
  411. return self}, function($ctx1) {$ctx1.fill(self,"whileTrue",{},globals.BlockClosure)})},
  412. args: [],
  413. source: "whileTrue\x0a\x09self whileTrue: []",
  414. messageSends: ["whileTrue:"],
  415. referencedClasses: []
  416. }),
  417. globals.BlockClosure);
  418. smalltalk.addMethod(
  419. smalltalk.method({
  420. selector: "whileTrue:",
  421. protocol: 'controlling',
  422. fn: function (aBlock){
  423. var self=this;
  424. return smalltalk.withContext(function($ctx1) {
  425. while(smalltalk.assert(self._value())) {aBlock._value()};
  426. return self}, function($ctx1) {$ctx1.fill(self,"whileTrue:",{aBlock:aBlock},globals.BlockClosure)})},
  427. args: ["aBlock"],
  428. source: "whileTrue: aBlock\x0a\x09<while(smalltalk.assert(self._value())) {aBlock._value()}>",
  429. messageSends: [],
  430. referencedClasses: []
  431. }),
  432. globals.BlockClosure);
  433. smalltalk.addClass('CompiledMethod', globals.Object, [], 'Kernel-Methods');
  434. globals.CompiledMethod.comment="I represent a class method of the system. I hold the source and compiled code of a class method.\x0a\x0a## API\x0aMy instances can be accessed using `Behavior >> #methodAt:`\x0a\x0a Object methodAt: 'asString'\x0a\x0aSource code access:\x0a\x0a\x09(String methodAt: 'lines') source\x0a\x0aReferenced classes:\x0a\x0a\x09(String methodAt: 'lines') referencedClasses\x0a\x0aMessages sent from an instance:\x0a\x09\x0a\x09(String methodAt: 'lines') messageSends";
  435. smalltalk.addMethod(
  436. smalltalk.method({
  437. selector: "arguments",
  438. protocol: 'accessing',
  439. fn: function (){
  440. var self=this;
  441. return smalltalk.withContext(function($ctx1) {
  442. return self.args || [];
  443. return self}, function($ctx1) {$ctx1.fill(self,"arguments",{},globals.CompiledMethod)})},
  444. args: [],
  445. source: "arguments\x0a\x09<return self.args || []>",
  446. messageSends: [],
  447. referencedClasses: []
  448. }),
  449. globals.CompiledMethod);
  450. smalltalk.addMethod(
  451. smalltalk.method({
  452. selector: "category",
  453. protocol: 'accessing',
  454. fn: function (){
  455. var self=this;
  456. return smalltalk.withContext(function($ctx1) {
  457. var $1;
  458. $1=self._protocol();
  459. return $1;
  460. }, function($ctx1) {$ctx1.fill(self,"category",{},globals.CompiledMethod)})},
  461. args: [],
  462. source: "category\x0a\x09^ self protocol",
  463. messageSends: ["protocol"],
  464. referencedClasses: []
  465. }),
  466. globals.CompiledMethod);
  467. smalltalk.addMethod(
  468. smalltalk.method({
  469. selector: "defaultProtocol",
  470. protocol: 'defaults',
  471. fn: function (){
  472. var self=this;
  473. return "as yet unclassified";
  474. },
  475. args: [],
  476. source: "defaultProtocol\x0a\x09^ 'as yet unclassified'",
  477. messageSends: [],
  478. referencedClasses: []
  479. }),
  480. globals.CompiledMethod);
  481. smalltalk.addMethod(
  482. smalltalk.method({
  483. selector: "fn",
  484. protocol: 'accessing',
  485. fn: function (){
  486. var self=this;
  487. return smalltalk.withContext(function($ctx1) {
  488. var $1;
  489. $1=self._basicAt_("fn");
  490. return $1;
  491. }, function($ctx1) {$ctx1.fill(self,"fn",{},globals.CompiledMethod)})},
  492. args: [],
  493. source: "fn\x0a\x09^ self basicAt: 'fn'",
  494. messageSends: ["basicAt:"],
  495. referencedClasses: []
  496. }),
  497. globals.CompiledMethod);
  498. smalltalk.addMethod(
  499. smalltalk.method({
  500. selector: "fn:",
  501. protocol: 'accessing',
  502. fn: function (aBlock){
  503. var self=this;
  504. return smalltalk.withContext(function($ctx1) {
  505. self._basicAt_put_("fn",aBlock);
  506. return self}, function($ctx1) {$ctx1.fill(self,"fn:",{aBlock:aBlock},globals.CompiledMethod)})},
  507. args: ["aBlock"],
  508. source: "fn: aBlock\x0a\x09self basicAt: 'fn' put: aBlock",
  509. messageSends: ["basicAt:put:"],
  510. referencedClasses: []
  511. }),
  512. globals.CompiledMethod);
  513. smalltalk.addMethod(
  514. smalltalk.method({
  515. selector: "isCompiledMethod",
  516. protocol: 'testing',
  517. fn: function (){
  518. var self=this;
  519. return true;
  520. },
  521. args: [],
  522. source: "isCompiledMethod\x0a\x09^ true",
  523. messageSends: [],
  524. referencedClasses: []
  525. }),
  526. globals.CompiledMethod);
  527. smalltalk.addMethod(
  528. smalltalk.method({
  529. selector: "isOverridden",
  530. protocol: 'testing',
  531. fn: function (){
  532. var self=this;
  533. var selector;
  534. return smalltalk.withContext(function($ctx1) {
  535. var $1;
  536. var $early={};
  537. try {
  538. selector=self._selector();
  539. _st(self._methodClass())._allSubclassesDo_((function(each){
  540. return smalltalk.withContext(function($ctx2) {
  541. $1=_st(each)._includesSelector_(selector);
  542. if(smalltalk.assert($1)){
  543. throw $early=[true];
  544. };
  545. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  546. return false;
  547. }
  548. catch(e) {if(e===$early)return e[0]; throw e}
  549. }, function($ctx1) {$ctx1.fill(self,"isOverridden",{selector:selector},globals.CompiledMethod)})},
  550. args: [],
  551. source: "isOverridden\x0a\x09| selector |\x0a \x0a selector := self selector.\x0a self methodClass allSubclassesDo: [ :each |\x0a\x09 (each includesSelector: selector)\x0a \x09ifTrue: [ ^ true ] ].\x0a\x09^ false",
  552. messageSends: ["selector", "allSubclassesDo:", "methodClass", "ifTrue:", "includesSelector:"],
  553. referencedClasses: []
  554. }),
  555. globals.CompiledMethod);
  556. smalltalk.addMethod(
  557. smalltalk.method({
  558. selector: "isOverride",
  559. protocol: 'testing',
  560. fn: function (){
  561. var self=this;
  562. var superclass;
  563. return smalltalk.withContext(function($ctx1) {
  564. var $1,$2,$3;
  565. $1=self._methodClass();
  566. $ctx1.sendIdx["methodClass"]=1;
  567. superclass=_st($1)._superclass();
  568. $ctx1.sendIdx["superclass"]=1;
  569. $2=superclass;
  570. if(($receiver = $2) == nil || $receiver == null){
  571. return false;
  572. } else {
  573. $2;
  574. };
  575. $3=_st(_st(_st(self._methodClass())._superclass())._lookupSelector_(self._selector()))._notNil();
  576. return $3;
  577. }, function($ctx1) {$ctx1.fill(self,"isOverride",{superclass:superclass},globals.CompiledMethod)})},
  578. args: [],
  579. source: "isOverride\x0a\x09| superclass |\x0a \x0a superclass := self methodClass superclass.\x0a\x09superclass ifNil: [ ^ false ].\x0a\x09\x0a ^ (self methodClass superclass lookupSelector: self selector) notNil",
  580. messageSends: ["superclass", "methodClass", "ifNil:", "notNil", "lookupSelector:", "selector"],
  581. referencedClasses: []
  582. }),
  583. globals.CompiledMethod);
  584. smalltalk.addMethod(
  585. smalltalk.method({
  586. selector: "messageSends",
  587. protocol: 'accessing',
  588. fn: function (){
  589. var self=this;
  590. return smalltalk.withContext(function($ctx1) {
  591. var $1;
  592. $1=self._basicAt_("messageSends");
  593. return $1;
  594. }, function($ctx1) {$ctx1.fill(self,"messageSends",{},globals.CompiledMethod)})},
  595. args: [],
  596. source: "messageSends\x0a\x09^ self basicAt: 'messageSends'",
  597. messageSends: ["basicAt:"],
  598. referencedClasses: []
  599. }),
  600. globals.CompiledMethod);
  601. smalltalk.addMethod(
  602. smalltalk.method({
  603. selector: "methodClass",
  604. protocol: 'accessing',
  605. fn: function (){
  606. var self=this;
  607. return smalltalk.withContext(function($ctx1) {
  608. var $1;
  609. $1=self._basicAt_("methodClass");
  610. return $1;
  611. }, function($ctx1) {$ctx1.fill(self,"methodClass",{},globals.CompiledMethod)})},
  612. args: [],
  613. source: "methodClass\x0a\x09^ self basicAt: 'methodClass'",
  614. messageSends: ["basicAt:"],
  615. referencedClasses: []
  616. }),
  617. globals.CompiledMethod);
  618. smalltalk.addMethod(
  619. smalltalk.method({
  620. selector: "package",
  621. protocol: 'accessing',
  622. fn: function (){
  623. var self=this;
  624. function $Package(){return globals.Package||(typeof Package=="undefined"?nil:Package)}
  625. return smalltalk.withContext(function($ctx1) {
  626. var $2,$1,$4,$3,$5;
  627. $2=self._protocol();
  628. $ctx1.sendIdx["protocol"]=1;
  629. $1=_st($2)._beginsWith_("*");
  630. if(! smalltalk.assert($1)){
  631. $4=self._methodClass();
  632. $ctx1.sendIdx["methodClass"]=1;
  633. $3=_st($4)._package();
  634. $ctx1.sendIdx["package"]=1;
  635. return $3;
  636. };
  637. $5=_st($Package())._named_ifAbsent_(_st(self._protocol())._allButFirst(),(function(){
  638. return smalltalk.withContext(function($ctx2) {
  639. return _st(self._methodClass())._package();
  640. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  641. return $5;
  642. }, function($ctx1) {$ctx1.fill(self,"package",{},globals.CompiledMethod)})},
  643. args: [],
  644. source: "package\x0a\x09\x22Answer the package the receiver belongs to:\x0a\x09- if it is an extension method, answer the corresponding package\x0a\x09- else answer the `methodClass` package\x22\x0a\x09\x0a\x09(self protocol beginsWith: '*') ifFalse: [\x0a\x09\x09^ self methodClass package ].\x0a\x09\x09\x0a\x09^ Package \x0a\x09\x09named: self protocol allButFirst\x0a\x09\x09ifAbsent: [ self methodClass package ]",
  645. messageSends: ["ifFalse:", "beginsWith:", "protocol", "package", "methodClass", "named:ifAbsent:", "allButFirst"],
  646. referencedClasses: ["Package"]
  647. }),
  648. globals.CompiledMethod);
  649. smalltalk.addMethod(
  650. smalltalk.method({
  651. selector: "protocol",
  652. protocol: 'accessing',
  653. fn: function (){
  654. var self=this;
  655. return smalltalk.withContext(function($ctx1) {
  656. var $2,$1;
  657. $2=self._basicAt_("protocol");
  658. if(($receiver = $2) == nil || $receiver == null){
  659. $1=self._defaultProtocol();
  660. } else {
  661. $1=$2;
  662. };
  663. return $1;
  664. }, function($ctx1) {$ctx1.fill(self,"protocol",{},globals.CompiledMethod)})},
  665. args: [],
  666. source: "protocol\x0a\x09^ (self basicAt: 'protocol') ifNil: [ self defaultProtocol ]",
  667. messageSends: ["ifNil:", "basicAt:", "defaultProtocol"],
  668. referencedClasses: []
  669. }),
  670. globals.CompiledMethod);
  671. smalltalk.addMethod(
  672. smalltalk.method({
  673. selector: "protocol:",
  674. protocol: 'accessing',
  675. fn: function (aString){
  676. var self=this;
  677. var oldProtocol;
  678. function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
  679. function $MethodMoved(){return globals.MethodMoved||(typeof MethodMoved=="undefined"?nil:MethodMoved)}
  680. return smalltalk.withContext(function($ctx1) {
  681. var $1,$2,$3;
  682. oldProtocol=self._protocol();
  683. self._basicAt_put_("protocol",aString);
  684. $1=_st($MethodMoved())._new();
  685. _st($1)._method_(self);
  686. _st($1)._oldProtocol_(oldProtocol);
  687. $2=_st($1)._yourself();
  688. _st(_st($SystemAnnouncer())._current())._announce_($2);
  689. $3=self._methodClass();
  690. if(($receiver = $3) == nil || $receiver == null){
  691. $3;
  692. } else {
  693. var methodClass;
  694. methodClass=$receiver;
  695. _st(_st(methodClass)._organization())._addElement_(aString);
  696. _st(methodClass)._removeProtocolIfEmpty_(oldProtocol);
  697. };
  698. return self}, function($ctx1) {$ctx1.fill(self,"protocol:",{aString:aString,oldProtocol:oldProtocol},globals.CompiledMethod)})},
  699. args: ["aString"],
  700. source: "protocol: aString\x0a\x09| oldProtocol |\x0a\x09oldProtocol := self protocol.\x0a\x09self basicAt: 'protocol' put: aString.\x0a\x0a\x09SystemAnnouncer current announce: (MethodMoved new\x0a\x09\x09method: self;\x0a\x09\x09oldProtocol: oldProtocol;\x0a\x09\x09yourself).\x0a\x0a\x09self methodClass ifNotNil: [ :methodClass |\x0a\x09\x09methodClass organization addElement: aString.\x0a\x09\x09methodClass removeProtocolIfEmpty: oldProtocol ]",
  701. messageSends: ["protocol", "basicAt:put:", "announce:", "current", "method:", "new", "oldProtocol:", "yourself", "ifNotNil:", "methodClass", "addElement:", "organization", "removeProtocolIfEmpty:"],
  702. referencedClasses: ["SystemAnnouncer", "MethodMoved"]
  703. }),
  704. globals.CompiledMethod);
  705. smalltalk.addMethod(
  706. smalltalk.method({
  707. selector: "referencedClasses",
  708. protocol: 'accessing',
  709. fn: function (){
  710. var self=this;
  711. return smalltalk.withContext(function($ctx1) {
  712. var $1;
  713. $1=self._basicAt_("referencedClasses");
  714. return $1;
  715. }, function($ctx1) {$ctx1.fill(self,"referencedClasses",{},globals.CompiledMethod)})},
  716. args: [],
  717. source: "referencedClasses\x0a\x09^ self basicAt: 'referencedClasses'",
  718. messageSends: ["basicAt:"],
  719. referencedClasses: []
  720. }),
  721. globals.CompiledMethod);
  722. smalltalk.addMethod(
  723. smalltalk.method({
  724. selector: "selector",
  725. protocol: 'accessing',
  726. fn: function (){
  727. var self=this;
  728. return smalltalk.withContext(function($ctx1) {
  729. var $1;
  730. $1=self._basicAt_("selector");
  731. return $1;
  732. }, function($ctx1) {$ctx1.fill(self,"selector",{},globals.CompiledMethod)})},
  733. args: [],
  734. source: "selector\x0a\x09^ self basicAt: 'selector'",
  735. messageSends: ["basicAt:"],
  736. referencedClasses: []
  737. }),
  738. globals.CompiledMethod);
  739. smalltalk.addMethod(
  740. smalltalk.method({
  741. selector: "selector:",
  742. protocol: 'accessing',
  743. fn: function (aString){
  744. var self=this;
  745. return smalltalk.withContext(function($ctx1) {
  746. self._basicAt_put_("selector",aString);
  747. return self}, function($ctx1) {$ctx1.fill(self,"selector:",{aString:aString},globals.CompiledMethod)})},
  748. args: ["aString"],
  749. source: "selector: aString\x0a\x09self basicAt: 'selector' put: aString",
  750. messageSends: ["basicAt:put:"],
  751. referencedClasses: []
  752. }),
  753. globals.CompiledMethod);
  754. smalltalk.addMethod(
  755. smalltalk.method({
  756. selector: "sendTo:arguments:",
  757. protocol: 'evaluating',
  758. fn: function (anObject,aCollection){
  759. var self=this;
  760. return smalltalk.withContext(function($ctx1) {
  761. var $1;
  762. $1=_st(self._fn())._applyTo_arguments_(anObject,aCollection);
  763. return $1;
  764. }, function($ctx1) {$ctx1.fill(self,"sendTo:arguments:",{anObject:anObject,aCollection:aCollection},globals.CompiledMethod)})},
  765. args: ["anObject", "aCollection"],
  766. source: "sendTo: anObject arguments: aCollection\x0a\x09^ self fn applyTo: anObject arguments: aCollection",
  767. messageSends: ["applyTo:arguments:", "fn"],
  768. referencedClasses: []
  769. }),
  770. globals.CompiledMethod);
  771. smalltalk.addMethod(
  772. smalltalk.method({
  773. selector: "source",
  774. protocol: 'accessing',
  775. fn: function (){
  776. var self=this;
  777. return smalltalk.withContext(function($ctx1) {
  778. var $2,$1;
  779. $2=self._basicAt_("source");
  780. if(($receiver = $2) == nil || $receiver == null){
  781. $1="";
  782. } else {
  783. $1=$2;
  784. };
  785. return $1;
  786. }, function($ctx1) {$ctx1.fill(self,"source",{},globals.CompiledMethod)})},
  787. args: [],
  788. source: "source\x0a\x09^ (self basicAt: 'source') ifNil: [ '' ]",
  789. messageSends: ["ifNil:", "basicAt:"],
  790. referencedClasses: []
  791. }),
  792. globals.CompiledMethod);
  793. smalltalk.addMethod(
  794. smalltalk.method({
  795. selector: "source:",
  796. protocol: 'accessing',
  797. fn: function (aString){
  798. var self=this;
  799. return smalltalk.withContext(function($ctx1) {
  800. self._basicAt_put_("source",aString);
  801. return self}, function($ctx1) {$ctx1.fill(self,"source:",{aString:aString},globals.CompiledMethod)})},
  802. args: ["aString"],
  803. source: "source: aString\x0a\x09self basicAt: 'source' put: aString",
  804. messageSends: ["basicAt:put:"],
  805. referencedClasses: []
  806. }),
  807. globals.CompiledMethod);
  808. smalltalk.addClass('ForkPool', globals.Object, ['poolSize', 'maxPoolSize', 'queue', 'worker'], 'Kernel-Methods');
  809. globals.ForkPool.comment="I am responsible for handling forked blocks.\x0aThe pool size sets the maximum concurrent forked blocks.\x0a\x0a## API\x0a\x0aThe default instance is accessed with `#default`.\x0aThe maximum concurrent forked blocks can be set with `#maxPoolSize:`.\x0a\x0aForking is done via `BlockClosure >> #fork`";
  810. smalltalk.addMethod(
  811. smalltalk.method({
  812. selector: "addWorker",
  813. protocol: 'private',
  814. fn: function (){
  815. var self=this;
  816. return smalltalk.withContext(function($ctx1) {
  817. _st(self["@worker"])._valueWithTimeout_((0));
  818. self["@poolSize"]=_st(self["@poolSize"]).__plus((1));
  819. return self}, function($ctx1) {$ctx1.fill(self,"addWorker",{},globals.ForkPool)})},
  820. args: [],
  821. source: "addWorker\x0a\x09worker valueWithTimeout: 0.\x0a\x09poolSize := poolSize + 1",
  822. messageSends: ["valueWithTimeout:", "+"],
  823. referencedClasses: []
  824. }),
  825. globals.ForkPool);
  826. smalltalk.addMethod(
  827. smalltalk.method({
  828. selector: "defaultMaxPoolSize",
  829. protocol: 'defaults',
  830. fn: function (){
  831. var self=this;
  832. return smalltalk.withContext(function($ctx1) {
  833. var $1;
  834. $1=_st(self._class())._defaultMaxPoolSize();
  835. return $1;
  836. }, function($ctx1) {$ctx1.fill(self,"defaultMaxPoolSize",{},globals.ForkPool)})},
  837. args: [],
  838. source: "defaultMaxPoolSize\x0a\x09^ self class defaultMaxPoolSize",
  839. messageSends: ["defaultMaxPoolSize", "class"],
  840. referencedClasses: []
  841. }),
  842. globals.ForkPool);
  843. smalltalk.addMethod(
  844. smalltalk.method({
  845. selector: "fork:",
  846. protocol: 'actions',
  847. fn: function (aBlock){
  848. var self=this;
  849. return smalltalk.withContext(function($ctx1) {
  850. var $1;
  851. $1=_st(self["@poolSize"]).__lt(self._maxPoolSize());
  852. if(smalltalk.assert($1)){
  853. self._addWorker();
  854. };
  855. _st(self["@queue"])._nextPut_(aBlock);
  856. return self}, function($ctx1) {$ctx1.fill(self,"fork:",{aBlock:aBlock},globals.ForkPool)})},
  857. args: ["aBlock"],
  858. source: "fork: aBlock\x0a\x09poolSize < self maxPoolSize ifTrue: [ self addWorker ].\x0a\x09queue nextPut: aBlock",
  859. messageSends: ["ifTrue:", "<", "maxPoolSize", "addWorker", "nextPut:"],
  860. referencedClasses: []
  861. }),
  862. globals.ForkPool);
  863. smalltalk.addMethod(
  864. smalltalk.method({
  865. selector: "initialize",
  866. protocol: 'initialization',
  867. fn: function (){
  868. var self=this;
  869. function $Queue(){return globals.Queue||(typeof Queue=="undefined"?nil:Queue)}
  870. return smalltalk.withContext(function($ctx1) {
  871. globals.ForkPool.superclass.fn.prototype._initialize.apply(_st(self), []);
  872. self["@poolSize"]=(0);
  873. self["@queue"]=_st($Queue())._new();
  874. self["@worker"]=self._makeWorker();
  875. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.ForkPool)})},
  876. args: [],
  877. source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09poolSize := 0.\x0a\x09queue := Queue new.\x0a\x09worker := self makeWorker",
  878. messageSends: ["initialize", "new", "makeWorker"],
  879. referencedClasses: ["Queue"]
  880. }),
  881. globals.ForkPool);
  882. smalltalk.addMethod(
  883. smalltalk.method({
  884. selector: "makeWorker",
  885. protocol: 'initialization',
  886. fn: function (){
  887. var self=this;
  888. var sentinel;
  889. function $Object(){return globals.Object||(typeof Object=="undefined"?nil:Object)}
  890. return smalltalk.withContext(function($ctx1) {
  891. var $2,$1;
  892. sentinel=_st($Object())._new();
  893. $1=(function(){
  894. var block;
  895. return smalltalk.withContext(function($ctx2) {
  896. self["@poolSize"]=_st(self["@poolSize"]).__minus((1));
  897. self["@poolSize"];
  898. block=_st(self["@queue"])._nextIfAbsent_((function(){
  899. return sentinel;
  900. }));
  901. block;
  902. $2=_st(block).__eq_eq(sentinel);
  903. if(! smalltalk.assert($2)){
  904. return _st((function(){
  905. return smalltalk.withContext(function($ctx3) {
  906. return _st(block)._value();
  907. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,4)})}))._ensure_((function(){
  908. return smalltalk.withContext(function($ctx3) {
  909. return self._addWorker();
  910. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,5)})}));
  911. };
  912. }, function($ctx2) {$ctx2.fillBlock({block:block},$ctx1,1)})});
  913. return $1;
  914. }, function($ctx1) {$ctx1.fill(self,"makeWorker",{sentinel:sentinel},globals.ForkPool)})},
  915. args: [],
  916. source: "makeWorker\x0a\x09| sentinel |\x0a\x09sentinel := Object new.\x0a\x09^ [ | block |\x0a\x09\x09poolSize := poolSize - 1.\x0a\x09\x09block := queue nextIfAbsent: [ sentinel ].\x0a\x09\x09block == sentinel ifFalse: [\x0a\x09\x09\x09[ block value ] ensure: [ self addWorker ] ]]",
  917. messageSends: ["new", "-", "nextIfAbsent:", "ifFalse:", "==", "ensure:", "value", "addWorker"],
  918. referencedClasses: ["Object"]
  919. }),
  920. globals.ForkPool);
  921. smalltalk.addMethod(
  922. smalltalk.method({
  923. selector: "maxPoolSize",
  924. protocol: 'accessing',
  925. fn: function (){
  926. var self=this;
  927. return smalltalk.withContext(function($ctx1) {
  928. var $2,$1;
  929. $2=self["@maxPoolSize"];
  930. if(($receiver = $2) == nil || $receiver == null){
  931. $1=self._defaultMaxPoolSize();
  932. } else {
  933. $1=$2;
  934. };
  935. return $1;
  936. }, function($ctx1) {$ctx1.fill(self,"maxPoolSize",{},globals.ForkPool)})},
  937. args: [],
  938. source: "maxPoolSize\x0a\x09^ maxPoolSize ifNil: [ self defaultMaxPoolSize ]",
  939. messageSends: ["ifNil:", "defaultMaxPoolSize"],
  940. referencedClasses: []
  941. }),
  942. globals.ForkPool);
  943. smalltalk.addMethod(
  944. smalltalk.method({
  945. selector: "maxPoolSize:",
  946. protocol: 'accessing',
  947. fn: function (anInteger){
  948. var self=this;
  949. self["@maxPoolSize"]=anInteger;
  950. return self},
  951. args: ["anInteger"],
  952. source: "maxPoolSize: anInteger\x0a\x09maxPoolSize := anInteger",
  953. messageSends: [],
  954. referencedClasses: []
  955. }),
  956. globals.ForkPool);
  957. globals.ForkPool.klass.iVarNames = ['default'];
  958. smalltalk.addMethod(
  959. smalltalk.method({
  960. selector: "default",
  961. protocol: 'accessing',
  962. fn: function (){
  963. var self=this;
  964. return smalltalk.withContext(function($ctx1) {
  965. var $2,$1;
  966. $2=self["@default"];
  967. if(($receiver = $2) == nil || $receiver == null){
  968. self["@default"]=self._new();
  969. $1=self["@default"];
  970. } else {
  971. $1=$2;
  972. };
  973. return $1;
  974. }, function($ctx1) {$ctx1.fill(self,"default",{},globals.ForkPool.klass)})},
  975. args: [],
  976. source: "default\x0a\x09^ default ifNil: [ default := self new ]",
  977. messageSends: ["ifNil:", "new"],
  978. referencedClasses: []
  979. }),
  980. globals.ForkPool.klass);
  981. smalltalk.addMethod(
  982. smalltalk.method({
  983. selector: "defaultMaxPoolSize",
  984. protocol: 'accessing',
  985. fn: function (){
  986. var self=this;
  987. return (100);
  988. },
  989. args: [],
  990. source: "defaultMaxPoolSize\x0a\x09^ 100",
  991. messageSends: [],
  992. referencedClasses: []
  993. }),
  994. globals.ForkPool.klass);
  995. smalltalk.addMethod(
  996. smalltalk.method({
  997. selector: "resetDefault",
  998. protocol: 'accessing',
  999. fn: function (){
  1000. var self=this;
  1001. self["@default"]=nil;
  1002. return self},
  1003. args: [],
  1004. source: "resetDefault\x0a\x09default := nil",
  1005. messageSends: [],
  1006. referencedClasses: []
  1007. }),
  1008. globals.ForkPool.klass);
  1009. smalltalk.addClass('Message', globals.Object, ['selector', 'arguments'], 'Kernel-Methods');
  1010. globals.Message.comment="In general, the system does not use instances of me for efficiency reasons.\x0aHowever, when a message is not understood by its receiver, the interpreter will make up an instance of it in order to capture the information involved in an actual message transmission.\x0aThis instance is sent it as an argument with the message `#doesNotUnderstand:` to the receiver.\x0a\x0aSee boot.js, `messageNotUnderstood` and its counterpart `Object >> #doesNotUnderstand:`\x0a\x0a## API\x0a\x0aBesides accessing methods, `#sendTo:` provides a convenient way to send a message to an object.";
  1011. smalltalk.addMethod(
  1012. smalltalk.method({
  1013. selector: "arguments",
  1014. protocol: 'accessing',
  1015. fn: function (){
  1016. var self=this;
  1017. var $1;
  1018. $1=self["@arguments"];
  1019. return $1;
  1020. },
  1021. args: [],
  1022. source: "arguments\x0a\x09^ arguments",
  1023. messageSends: [],
  1024. referencedClasses: []
  1025. }),
  1026. globals.Message);
  1027. smalltalk.addMethod(
  1028. smalltalk.method({
  1029. selector: "arguments:",
  1030. protocol: 'accessing',
  1031. fn: function (anArray){
  1032. var self=this;
  1033. self["@arguments"]=anArray;
  1034. return self},
  1035. args: ["anArray"],
  1036. source: "arguments: anArray\x0a\x09arguments := anArray",
  1037. messageSends: [],
  1038. referencedClasses: []
  1039. }),
  1040. globals.Message);
  1041. smalltalk.addMethod(
  1042. smalltalk.method({
  1043. selector: "printOn:",
  1044. protocol: 'printing',
  1045. fn: function (aStream){
  1046. var self=this;
  1047. return smalltalk.withContext(function($ctx1) {
  1048. var $1;
  1049. globals.Message.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]);
  1050. _st(aStream)._nextPutAll_("(");
  1051. $ctx1.sendIdx["nextPutAll:"]=1;
  1052. _st(aStream)._nextPutAll_(self._selector());
  1053. $ctx1.sendIdx["nextPutAll:"]=2;
  1054. $1=_st(aStream)._nextPutAll_(")");
  1055. return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.Message)})},
  1056. args: ["aStream"],
  1057. source: "printOn: aStream\x0a\x09super printOn: aStream.\x0a\x09aStream\x0a\x09\x09nextPutAll: '(';\x0a\x09\x09nextPutAll: self selector;\x0a\x09\x09nextPutAll: ')'",
  1058. messageSends: ["printOn:", "nextPutAll:", "selector"],
  1059. referencedClasses: []
  1060. }),
  1061. globals.Message);
  1062. smalltalk.addMethod(
  1063. smalltalk.method({
  1064. selector: "selector",
  1065. protocol: 'accessing',
  1066. fn: function (){
  1067. var self=this;
  1068. var $1;
  1069. $1=self["@selector"];
  1070. return $1;
  1071. },
  1072. args: [],
  1073. source: "selector\x0a\x09^ selector",
  1074. messageSends: [],
  1075. referencedClasses: []
  1076. }),
  1077. globals.Message);
  1078. smalltalk.addMethod(
  1079. smalltalk.method({
  1080. selector: "selector:",
  1081. protocol: 'accessing',
  1082. fn: function (aString){
  1083. var self=this;
  1084. self["@selector"]=aString;
  1085. return self},
  1086. args: ["aString"],
  1087. source: "selector: aString\x0a\x09selector := aString",
  1088. messageSends: [],
  1089. referencedClasses: []
  1090. }),
  1091. globals.Message);
  1092. smalltalk.addMethod(
  1093. smalltalk.method({
  1094. selector: "sendTo:",
  1095. protocol: 'actions',
  1096. fn: function (anObject){
  1097. var self=this;
  1098. return smalltalk.withContext(function($ctx1) {
  1099. var $1;
  1100. $1=_st(anObject)._perform_withArguments_(self._selector(),self._arguments());
  1101. return $1;
  1102. }, function($ctx1) {$ctx1.fill(self,"sendTo:",{anObject:anObject},globals.Message)})},
  1103. args: ["anObject"],
  1104. source: "sendTo: anObject\x0a\x09^ anObject perform: self selector withArguments: self arguments",
  1105. messageSends: ["perform:withArguments:", "selector", "arguments"],
  1106. referencedClasses: []
  1107. }),
  1108. globals.Message);
  1109. smalltalk.addMethod(
  1110. smalltalk.method({
  1111. selector: "selector:arguments:",
  1112. protocol: 'instance creation',
  1113. fn: function (aString,anArray){
  1114. var self=this;
  1115. return smalltalk.withContext(function($ctx1) {
  1116. var $2,$3,$1;
  1117. $2=self._new();
  1118. _st($2)._selector_(aString);
  1119. _st($2)._arguments_(anArray);
  1120. $3=_st($2)._yourself();
  1121. $1=$3;
  1122. return $1;
  1123. }, function($ctx1) {$ctx1.fill(self,"selector:arguments:",{aString:aString,anArray:anArray},globals.Message.klass)})},
  1124. args: ["aString", "anArray"],
  1125. source: "selector: aString arguments: anArray\x0a\x09^ self new\x0a\x09\x09selector: aString;\x0a\x09\x09arguments: anArray;\x0a\x09\x09yourself",
  1126. messageSends: ["selector:", "new", "arguments:", "yourself"],
  1127. referencedClasses: []
  1128. }),
  1129. globals.Message.klass);
  1130. smalltalk.addClass('MessageSend', globals.Object, ['receiver', 'message'], 'Kernel-Methods');
  1131. globals.MessageSend.comment="I encapsulate message sends to objects. Arguments can be either predefined or supplied when the message send is performed. \x0a\x0a## API\x0a\x0aUse `#value` to perform a message send with its predefined arguments and `#value:*` if additonal arguments have to supplied.";
  1132. smalltalk.addMethod(
  1133. smalltalk.method({
  1134. selector: "arguments",
  1135. protocol: 'accessing',
  1136. fn: function (){
  1137. var self=this;
  1138. return smalltalk.withContext(function($ctx1) {
  1139. var $1;
  1140. $1=_st(self["@message"])._arguments();
  1141. return $1;
  1142. }, function($ctx1) {$ctx1.fill(self,"arguments",{},globals.MessageSend)})},
  1143. args: [],
  1144. source: "arguments\x0a\x09^ message arguments",
  1145. messageSends: ["arguments"],
  1146. referencedClasses: []
  1147. }),
  1148. globals.MessageSend);
  1149. smalltalk.addMethod(
  1150. smalltalk.method({
  1151. selector: "arguments:",
  1152. protocol: 'accessing',
  1153. fn: function (aCollection){
  1154. var self=this;
  1155. return smalltalk.withContext(function($ctx1) {
  1156. _st(self["@message"])._arguments_(aCollection);
  1157. return self}, function($ctx1) {$ctx1.fill(self,"arguments:",{aCollection:aCollection},globals.MessageSend)})},
  1158. args: ["aCollection"],
  1159. source: "arguments: aCollection\x0a\x09message arguments: aCollection",
  1160. messageSends: ["arguments:"],
  1161. referencedClasses: []
  1162. }),
  1163. globals.MessageSend);
  1164. smalltalk.addMethod(
  1165. smalltalk.method({
  1166. selector: "initialize",
  1167. protocol: 'initialization',
  1168. fn: function (){
  1169. var self=this;
  1170. function $Message(){return globals.Message||(typeof Message=="undefined"?nil:Message)}
  1171. return smalltalk.withContext(function($ctx1) {
  1172. globals.MessageSend.superclass.fn.prototype._initialize.apply(_st(self), []);
  1173. self["@message"]=_st($Message())._new();
  1174. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.MessageSend)})},
  1175. args: [],
  1176. source: "initialize\x0a\x09super initialize.\x0a\x09message := Message new",
  1177. messageSends: ["initialize", "new"],
  1178. referencedClasses: ["Message"]
  1179. }),
  1180. globals.MessageSend);
  1181. smalltalk.addMethod(
  1182. smalltalk.method({
  1183. selector: "printOn:",
  1184. protocol: 'printing',
  1185. fn: function (aStream){
  1186. var self=this;
  1187. return smalltalk.withContext(function($ctx1) {
  1188. var $1;
  1189. globals.MessageSend.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]);
  1190. _st(aStream)._nextPutAll_("(");
  1191. $ctx1.sendIdx["nextPutAll:"]=1;
  1192. _st(aStream)._nextPutAll_(self._receiver());
  1193. $ctx1.sendIdx["nextPutAll:"]=2;
  1194. _st(aStream)._nextPutAll_(" >> ");
  1195. $ctx1.sendIdx["nextPutAll:"]=3;
  1196. _st(aStream)._nextPutAll_(self._selector());
  1197. $ctx1.sendIdx["nextPutAll:"]=4;
  1198. $1=_st(aStream)._nextPutAll_(")");
  1199. return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.MessageSend)})},
  1200. args: ["aStream"],
  1201. source: "printOn: aStream\x0a\x09super printOn: aStream.\x0a\x09aStream\x0a\x09\x09nextPutAll: '(';\x0a\x09\x09nextPutAll: self receiver;\x0a\x09\x09nextPutAll: ' >> ';\x0a\x09\x09nextPutAll: self selector;\x0a\x09\x09nextPutAll: ')'",
  1202. messageSends: ["printOn:", "nextPutAll:", "receiver", "selector"],
  1203. referencedClasses: []
  1204. }),
  1205. globals.MessageSend);
  1206. smalltalk.addMethod(
  1207. smalltalk.method({
  1208. selector: "receiver",
  1209. protocol: 'accessing',
  1210. fn: function (){
  1211. var self=this;
  1212. var $1;
  1213. $1=self["@receiver"];
  1214. return $1;
  1215. },
  1216. args: [],
  1217. source: "receiver\x0a\x09^ receiver",
  1218. messageSends: [],
  1219. referencedClasses: []
  1220. }),
  1221. globals.MessageSend);
  1222. smalltalk.addMethod(
  1223. smalltalk.method({
  1224. selector: "receiver:",
  1225. protocol: 'accessing',
  1226. fn: function (anObject){
  1227. var self=this;
  1228. self["@receiver"]=anObject;
  1229. return self},
  1230. args: ["anObject"],
  1231. source: "receiver: anObject\x0a\x09receiver := anObject",
  1232. messageSends: [],
  1233. referencedClasses: []
  1234. }),
  1235. globals.MessageSend);
  1236. smalltalk.addMethod(
  1237. smalltalk.method({
  1238. selector: "selector",
  1239. protocol: 'accessing',
  1240. fn: function (){
  1241. var self=this;
  1242. return smalltalk.withContext(function($ctx1) {
  1243. var $1;
  1244. $1=_st(self["@message"])._selector();
  1245. return $1;
  1246. }, function($ctx1) {$ctx1.fill(self,"selector",{},globals.MessageSend)})},
  1247. args: [],
  1248. source: "selector\x0a\x09^ message selector",
  1249. messageSends: ["selector"],
  1250. referencedClasses: []
  1251. }),
  1252. globals.MessageSend);
  1253. smalltalk.addMethod(
  1254. smalltalk.method({
  1255. selector: "selector:",
  1256. protocol: 'accessing',
  1257. fn: function (aString){
  1258. var self=this;
  1259. return smalltalk.withContext(function($ctx1) {
  1260. _st(self["@message"])._selector_(aString);
  1261. return self}, function($ctx1) {$ctx1.fill(self,"selector:",{aString:aString},globals.MessageSend)})},
  1262. args: ["aString"],
  1263. source: "selector: aString\x0a\x09message selector: aString",
  1264. messageSends: ["selector:"],
  1265. referencedClasses: []
  1266. }),
  1267. globals.MessageSend);
  1268. smalltalk.addMethod(
  1269. smalltalk.method({
  1270. selector: "value",
  1271. protocol: 'evaluating',
  1272. fn: function (){
  1273. var self=this;
  1274. return smalltalk.withContext(function($ctx1) {
  1275. var $1;
  1276. $1=_st(self["@message"])._sendTo_(self._receiver());
  1277. return $1;
  1278. }, function($ctx1) {$ctx1.fill(self,"value",{},globals.MessageSend)})},
  1279. args: [],
  1280. source: "value\x0a\x09^ message sendTo: self receiver",
  1281. messageSends: ["sendTo:", "receiver"],
  1282. referencedClasses: []
  1283. }),
  1284. globals.MessageSend);
  1285. smalltalk.addMethod(
  1286. smalltalk.method({
  1287. selector: "value:",
  1288. protocol: 'evaluating',
  1289. fn: function (anObject){
  1290. var self=this;
  1291. return smalltalk.withContext(function($ctx1) {
  1292. var $2,$3,$1;
  1293. $2=self["@message"];
  1294. _st($2)._arguments_([anObject]);
  1295. $3=_st($2)._sendTo_(self._receiver());
  1296. $1=$3;
  1297. return $1;
  1298. }, function($ctx1) {$ctx1.fill(self,"value:",{anObject:anObject},globals.MessageSend)})},
  1299. args: ["anObject"],
  1300. source: "value: anObject\x0a\x09^ message \x0a\x09\x09arguments: { anObject };\x0a\x09\x09sendTo: self receiver",
  1301. messageSends: ["arguments:", "sendTo:", "receiver"],
  1302. referencedClasses: []
  1303. }),
  1304. globals.MessageSend);
  1305. smalltalk.addMethod(
  1306. smalltalk.method({
  1307. selector: "value:value:",
  1308. protocol: 'evaluating',
  1309. fn: function (firstArgument,secondArgument){
  1310. var self=this;
  1311. return smalltalk.withContext(function($ctx1) {
  1312. var $2,$3,$1;
  1313. $2=self["@message"];
  1314. _st($2)._arguments_([firstArgument,secondArgument]);
  1315. $3=_st($2)._sendTo_(self._receiver());
  1316. $1=$3;
  1317. return $1;
  1318. }, function($ctx1) {$ctx1.fill(self,"value:value:",{firstArgument:firstArgument,secondArgument:secondArgument},globals.MessageSend)})},
  1319. args: ["firstArgument", "secondArgument"],
  1320. source: "value: firstArgument value: secondArgument\x0a\x09^ message \x0a\x09\x09arguments: { firstArgument. secondArgument };\x0a\x09\x09sendTo: self receiver",
  1321. messageSends: ["arguments:", "sendTo:", "receiver"],
  1322. referencedClasses: []
  1323. }),
  1324. globals.MessageSend);
  1325. smalltalk.addMethod(
  1326. smalltalk.method({
  1327. selector: "value:value:value:",
  1328. protocol: 'evaluating',
  1329. fn: function (firstArgument,secondArgument,thirdArgument){
  1330. var self=this;
  1331. return smalltalk.withContext(function($ctx1) {
  1332. var $2,$3,$1;
  1333. $2=self["@message"];
  1334. _st($2)._arguments_([firstArgument,secondArgument,thirdArgument]);
  1335. $3=_st($2)._sendTo_(self._receiver());
  1336. $1=$3;
  1337. return $1;
  1338. }, function($ctx1) {$ctx1.fill(self,"value:value:value:",{firstArgument:firstArgument,secondArgument:secondArgument,thirdArgument:thirdArgument},globals.MessageSend)})},
  1339. args: ["firstArgument", "secondArgument", "thirdArgument"],
  1340. source: "value: firstArgument value: secondArgument value: thirdArgument\x0a\x09^ message \x0a\x09\x09arguments: { firstArgument. secondArgument. thirdArgument };\x0a\x09\x09sendTo: self receiver",
  1341. messageSends: ["arguments:", "sendTo:", "receiver"],
  1342. referencedClasses: []
  1343. }),
  1344. globals.MessageSend);
  1345. smalltalk.addMethod(
  1346. smalltalk.method({
  1347. selector: "valueWithPossibleArguments:",
  1348. protocol: 'evaluating',
  1349. fn: function (aCollection){
  1350. var self=this;
  1351. return smalltalk.withContext(function($ctx1) {
  1352. var $1;
  1353. self._arguments_(aCollection);
  1354. $1=self._value();
  1355. return $1;
  1356. }, function($ctx1) {$ctx1.fill(self,"valueWithPossibleArguments:",{aCollection:aCollection},globals.MessageSend)})},
  1357. args: ["aCollection"],
  1358. source: "valueWithPossibleArguments: aCollection\x0a\x09self arguments: aCollection.\x0a\x09^ self value",
  1359. messageSends: ["arguments:", "value"],
  1360. referencedClasses: []
  1361. }),
  1362. globals.MessageSend);
  1363. smalltalk.addClass('MethodContext', globals.Object, [], 'Kernel-Methods');
  1364. globals.MethodContext.comment="I hold all the dynamic state associated with the execution of either a method activation resulting from a message send. I am used to build the call stack while debugging.\x0a\x0aMy instances are JavaScript `SmalltalkMethodContext` objects defined in `boot.js`.";
  1365. smalltalk.addMethod(
  1366. smalltalk.method({
  1367. selector: "asString",
  1368. protocol: 'converting',
  1369. fn: function (){
  1370. var self=this;
  1371. return smalltalk.withContext(function($ctx1) {
  1372. var $2,$3,$1;
  1373. $2=self._isBlockContext();
  1374. if(smalltalk.assert($2)){
  1375. $3="a block (in ".__comma(_st(self._methodContext())._asString());
  1376. $ctx1.sendIdx[","]=2;
  1377. $1=_st($3).__comma(")");
  1378. $ctx1.sendIdx[","]=1;
  1379. } else {
  1380. $1=_st(_st(_st(_st(self._receiver())._class())._name()).__comma(" >> ")).__comma(self._selector());
  1381. $ctx1.sendIdx[","]=3;
  1382. };
  1383. return $1;
  1384. }, function($ctx1) {$ctx1.fill(self,"asString",{},globals.MethodContext)})},
  1385. args: [],
  1386. source: "asString\x0a\x09^ self isBlockContext\x0a\x09\x09ifTrue: [ 'a block (in ', self methodContext asString, ')' ]\x0a\x09\x09ifFalse: [ self receiver class name, ' >> ', self selector ]",
  1387. messageSends: ["ifTrue:ifFalse:", "isBlockContext", ",", "asString", "methodContext", "name", "class", "receiver", "selector"],
  1388. referencedClasses: []
  1389. }),
  1390. globals.MethodContext);
  1391. smalltalk.addMethod(
  1392. smalltalk.method({
  1393. selector: "evaluatedSelector",
  1394. protocol: 'accessing',
  1395. fn: function (){
  1396. var self=this;
  1397. return smalltalk.withContext(function($ctx1) {
  1398. return self.evaluatedSelector;
  1399. return self}, function($ctx1) {$ctx1.fill(self,"evaluatedSelector",{},globals.MethodContext)})},
  1400. args: [],
  1401. source: "evaluatedSelector\x0a\x09<return self.evaluatedSelector>",
  1402. messageSends: [],
  1403. referencedClasses: []
  1404. }),
  1405. globals.MethodContext);
  1406. smalltalk.addMethod(
  1407. smalltalk.method({
  1408. selector: "home",
  1409. protocol: 'accessing',
  1410. fn: function (){
  1411. var self=this;
  1412. return smalltalk.withContext(function($ctx1) {
  1413. return self.homeContext;
  1414. return self}, function($ctx1) {$ctx1.fill(self,"home",{},globals.MethodContext)})},
  1415. args: [],
  1416. source: "home\x0a\x09<return self.homeContext>",
  1417. messageSends: [],
  1418. referencedClasses: []
  1419. }),
  1420. globals.MethodContext);
  1421. smalltalk.addMethod(
  1422. smalltalk.method({
  1423. selector: "index",
  1424. protocol: 'accessing',
  1425. fn: function (){
  1426. var self=this;
  1427. return smalltalk.withContext(function($ctx1) {
  1428. return self.index || 0;
  1429. return self}, function($ctx1) {$ctx1.fill(self,"index",{},globals.MethodContext)})},
  1430. args: [],
  1431. source: "index\x0a\x09<return self.index || 0>",
  1432. messageSends: [],
  1433. referencedClasses: []
  1434. }),
  1435. globals.MethodContext);
  1436. smalltalk.addMethod(
  1437. smalltalk.method({
  1438. selector: "isBlockContext",
  1439. protocol: 'testing',
  1440. fn: function (){
  1441. var self=this;
  1442. return smalltalk.withContext(function($ctx1) {
  1443. var $1;
  1444. $1=_st(self._selector())._isNil();
  1445. return $1;
  1446. }, function($ctx1) {$ctx1.fill(self,"isBlockContext",{},globals.MethodContext)})},
  1447. args: [],
  1448. source: "isBlockContext\x0a\x09\x22Block context do not have selectors.\x22\x0a\x09\x0a\x09^ self selector isNil",
  1449. messageSends: ["isNil", "selector"],
  1450. referencedClasses: []
  1451. }),
  1452. globals.MethodContext);
  1453. smalltalk.addMethod(
  1454. smalltalk.method({
  1455. selector: "locals",
  1456. protocol: 'accessing',
  1457. fn: function (){
  1458. var self=this;
  1459. return smalltalk.withContext(function($ctx1) {
  1460. return self.locals || {};
  1461. return self}, function($ctx1) {$ctx1.fill(self,"locals",{},globals.MethodContext)})},
  1462. args: [],
  1463. source: "locals\x0a\x09<return self.locals || {}>",
  1464. messageSends: [],
  1465. referencedClasses: []
  1466. }),
  1467. globals.MethodContext);
  1468. smalltalk.addMethod(
  1469. smalltalk.method({
  1470. selector: "method",
  1471. protocol: 'accessing',
  1472. fn: function (){
  1473. var self=this;
  1474. return smalltalk.withContext(function($ctx1) {
  1475. var $2,$5,$4,$3,$1;
  1476. $2=self._methodContext();
  1477. $ctx1.sendIdx["methodContext"]=1;
  1478. if(($receiver = $2) == nil || $receiver == null){
  1479. $1=$2;
  1480. } else {
  1481. $5=self._methodContext();
  1482. $ctx1.sendIdx["methodContext"]=2;
  1483. $4=_st($5)._receiver();
  1484. $3=_st($4)._class();
  1485. $1=_st($3)._lookupSelector_(_st(self._methodContext())._selector());
  1486. };
  1487. return $1;
  1488. }, function($ctx1) {$ctx1.fill(self,"method",{},globals.MethodContext)})},
  1489. args: [],
  1490. source: "method\x0a\x09^ self methodContext ifNotNil: [\x0a\x09\x09self methodContext receiver class lookupSelector: self methodContext selector ]",
  1491. messageSends: ["ifNotNil:", "methodContext", "lookupSelector:", "class", "receiver", "selector"],
  1492. referencedClasses: []
  1493. }),
  1494. globals.MethodContext);
  1495. smalltalk.addMethod(
  1496. smalltalk.method({
  1497. selector: "methodContext",
  1498. protocol: 'accessing',
  1499. fn: function (){
  1500. var self=this;
  1501. return smalltalk.withContext(function($ctx1) {
  1502. var $1,$3,$2;
  1503. $1=self._isBlockContext();
  1504. if(! smalltalk.assert($1)){
  1505. return self;
  1506. };
  1507. $3=self._outerContext();
  1508. if(($receiver = $3) == nil || $receiver == null){
  1509. $2=$3;
  1510. } else {
  1511. var outer;
  1512. outer=$receiver;
  1513. $2=_st(outer)._methodContext();
  1514. };
  1515. return $2;
  1516. }, function($ctx1) {$ctx1.fill(self,"methodContext",{},globals.MethodContext)})},
  1517. args: [],
  1518. source: "methodContext\x0a\x09self isBlockContext ifFalse: [ ^ self ].\x0a\x09\x0a\x09^ self outerContext ifNotNil: [ :outer |\x0a\x09\x09outer methodContext ]",
  1519. messageSends: ["ifFalse:", "isBlockContext", "ifNotNil:", "outerContext", "methodContext"],
  1520. referencedClasses: []
  1521. }),
  1522. globals.MethodContext);
  1523. smalltalk.addMethod(
  1524. smalltalk.method({
  1525. selector: "outerContext",
  1526. protocol: 'accessing',
  1527. fn: function (){
  1528. var self=this;
  1529. return smalltalk.withContext(function($ctx1) {
  1530. return self.outerContext || self.homeContext;
  1531. return self}, function($ctx1) {$ctx1.fill(self,"outerContext",{},globals.MethodContext)})},
  1532. args: [],
  1533. source: "outerContext\x0a\x09<return self.outerContext || self.homeContext>",
  1534. messageSends: [],
  1535. referencedClasses: []
  1536. }),
  1537. globals.MethodContext);
  1538. smalltalk.addMethod(
  1539. smalltalk.method({
  1540. selector: "printOn:",
  1541. protocol: 'printing',
  1542. fn: function (aStream){
  1543. var self=this;
  1544. return smalltalk.withContext(function($ctx1) {
  1545. var $1;
  1546. globals.MethodContext.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]);
  1547. _st(aStream)._nextPutAll_("(");
  1548. $ctx1.sendIdx["nextPutAll:"]=1;
  1549. _st(aStream)._nextPutAll_(self._asString());
  1550. $ctx1.sendIdx["nextPutAll:"]=2;
  1551. $1=_st(aStream)._nextPutAll_(")");
  1552. return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.MethodContext)})},
  1553. args: ["aStream"],
  1554. source: "printOn: aStream\x0a\x09super printOn: aStream.\x0a\x09aStream \x0a\x09\x09nextPutAll: '(';\x0a\x09\x09nextPutAll: self asString;\x0a\x09\x09nextPutAll: ')'",
  1555. messageSends: ["printOn:", "nextPutAll:", "asString"],
  1556. referencedClasses: []
  1557. }),
  1558. globals.MethodContext);
  1559. smalltalk.addMethod(
  1560. smalltalk.method({
  1561. selector: "receiver",
  1562. protocol: 'accessing',
  1563. fn: function (){
  1564. var self=this;
  1565. return smalltalk.withContext(function($ctx1) {
  1566. return self.receiver;
  1567. return self}, function($ctx1) {$ctx1.fill(self,"receiver",{},globals.MethodContext)})},
  1568. args: [],
  1569. source: "receiver\x0a\x09<return self.receiver>",
  1570. messageSends: [],
  1571. referencedClasses: []
  1572. }),
  1573. globals.MethodContext);
  1574. smalltalk.addMethod(
  1575. smalltalk.method({
  1576. selector: "selector",
  1577. protocol: 'accessing',
  1578. fn: function (){
  1579. var self=this;
  1580. return smalltalk.withContext(function($ctx1) {
  1581. if(self.selector) {
  1582. return smalltalk.convertSelector(self.selector);
  1583. } else {
  1584. return nil;
  1585. }
  1586. ;
  1587. return self}, function($ctx1) {$ctx1.fill(self,"selector",{},globals.MethodContext)})},
  1588. args: [],
  1589. source: "selector\x0a\x09<\x0a\x09\x09if(self.selector) {\x0a\x09\x09\x09return smalltalk.convertSelector(self.selector);\x0a\x09\x09} else {\x0a\x09\x09\x09return nil;\x0a\x09\x09}\x0a\x09>",
  1590. messageSends: [],
  1591. referencedClasses: []
  1592. }),
  1593. globals.MethodContext);
  1594. smalltalk.addMethod(
  1595. smalltalk.method({
  1596. selector: "sendIndexAt:",
  1597. protocol: 'accessing',
  1598. fn: function (aSelector){
  1599. var self=this;
  1600. return smalltalk.withContext(function($ctx1) {
  1601. return self.sendIdx[aSelector] || 0;
  1602. return self}, function($ctx1) {$ctx1.fill(self,"sendIndexAt:",{aSelector:aSelector},globals.MethodContext)})},
  1603. args: ["aSelector"],
  1604. source: "sendIndexAt: aSelector\x0a\x09<return self.sendIdx[aSelector] || 0>",
  1605. messageSends: [],
  1606. referencedClasses: []
  1607. }),
  1608. globals.MethodContext);
  1609. smalltalk.addMethod(
  1610. smalltalk.method({
  1611. selector: "sendIndexes",
  1612. protocol: 'accessing',
  1613. fn: function (){
  1614. var self=this;
  1615. return smalltalk.withContext(function($ctx1) {
  1616. return self.sendIdx;
  1617. return self}, function($ctx1) {$ctx1.fill(self,"sendIndexes",{},globals.MethodContext)})},
  1618. args: [],
  1619. source: "sendIndexes\x0a\x09<return self.sendIdx>",
  1620. messageSends: [],
  1621. referencedClasses: []
  1622. }),
  1623. globals.MethodContext);
  1624. smalltalk.addMethod(
  1625. smalltalk.method({
  1626. selector: "temps",
  1627. protocol: 'accessing',
  1628. fn: function (){
  1629. var self=this;
  1630. return smalltalk.withContext(function($ctx1) {
  1631. var $1;
  1632. self._deprecatedAPI();
  1633. $1=self._locals();
  1634. return $1;
  1635. }, function($ctx1) {$ctx1.fill(self,"temps",{},globals.MethodContext)})},
  1636. args: [],
  1637. source: "temps\x0a\x09self deprecatedAPI.\x0a\x09\x0a\x09^ self locals",
  1638. messageSends: ["deprecatedAPI", "locals"],
  1639. referencedClasses: []
  1640. }),
  1641. globals.MethodContext);
  1642. smalltalk.addClass('NativeFunction', globals.Object, [], 'Kernel-Methods');
  1643. globals.NativeFunction.comment="I am a wrapper around native functions, such as `WebSocket`.\x0aFor 'normal' functions (whose constructor is the JavaScript `Function` object), use `BlockClosure`.\x0a\x0a## API\x0a\x0aSee the class-side `instance creation` methods for instance creation.\x0a\x0aCreated instances will most probably be instance of `JSObjectProxy`.\x0a\x0a## Usage example:\x0a\x0a\x09| ws |\x0a\x09ws := NativeFunction constructor: 'WebSocket' value: 'ws://localhost'.\x0a\x09ws at: 'onopen' put: [ ws send: 'hey there from Amber' ]";
  1644. smalltalk.addMethod(
  1645. smalltalk.method({
  1646. selector: "constructor:",
  1647. protocol: 'instance creation',
  1648. fn: function (aString){
  1649. var self=this;
  1650. return smalltalk.withContext(function($ctx1) {
  1651. var native=eval(aString);
  1652. return new native();
  1653. ;
  1654. return self}, function($ctx1) {$ctx1.fill(self,"constructor:",{aString:aString},globals.NativeFunction.klass)})},
  1655. args: ["aString"],
  1656. source: "constructor: aString\x0a\x09<\x0a\x09\x09var native=eval(aString);\x0a\x09\x09return new native();\x0a\x09>",
  1657. messageSends: [],
  1658. referencedClasses: []
  1659. }),
  1660. globals.NativeFunction.klass);
  1661. smalltalk.addMethod(
  1662. smalltalk.method({
  1663. selector: "constructor:value:",
  1664. protocol: 'instance creation',
  1665. fn: function (aString,anObject){
  1666. var self=this;
  1667. return smalltalk.withContext(function($ctx1) {
  1668. var native=eval(aString);
  1669. return new native(anObject);
  1670. ;
  1671. return self}, function($ctx1) {$ctx1.fill(self,"constructor:value:",{aString:aString,anObject:anObject},globals.NativeFunction.klass)})},
  1672. args: ["aString", "anObject"],
  1673. source: "constructor: aString value:anObject\x0a\x09<\x0a\x09\x09var native=eval(aString);\x0a\x09\x09return new native(anObject);\x0a\x09>",
  1674. messageSends: [],
  1675. referencedClasses: []
  1676. }),
  1677. globals.NativeFunction.klass);
  1678. smalltalk.addMethod(
  1679. smalltalk.method({
  1680. selector: "constructor:value:value:",
  1681. protocol: 'instance creation',
  1682. fn: function (aString,anObject,anObject2){
  1683. var self=this;
  1684. return smalltalk.withContext(function($ctx1) {
  1685. var native=eval(aString);
  1686. return new native(anObject,anObject2);
  1687. ;
  1688. return self}, function($ctx1) {$ctx1.fill(self,"constructor:value:value:",{aString:aString,anObject:anObject,anObject2:anObject2},globals.NativeFunction.klass)})},
  1689. args: ["aString", "anObject", "anObject2"],
  1690. source: "constructor: aString value:anObject value: anObject2\x0a\x09<\x0a\x09\x09var native=eval(aString);\x0a\x09\x09return new native(anObject,anObject2);\x0a\x09>",
  1691. messageSends: [],
  1692. referencedClasses: []
  1693. }),
  1694. globals.NativeFunction.klass);
  1695. smalltalk.addMethod(
  1696. smalltalk.method({
  1697. selector: "constructor:value:value:value:",
  1698. protocol: 'instance creation',
  1699. fn: function (aString,anObject,anObject2,anObject3){
  1700. var self=this;
  1701. return smalltalk.withContext(function($ctx1) {
  1702. var native=eval(aString);
  1703. return new native(anObject,anObject2, anObject3);
  1704. ;
  1705. return self}, function($ctx1) {$ctx1.fill(self,"constructor:value:value:value:",{aString:aString,anObject:anObject,anObject2:anObject2,anObject3:anObject3},globals.NativeFunction.klass)})},
  1706. args: ["aString", "anObject", "anObject2", "anObject3"],
  1707. source: "constructor: aString value:anObject value: anObject2 value:anObject3\x0a\x09<\x0a\x09\x09var native=eval(aString);\x0a\x09\x09return new native(anObject,anObject2, anObject3);\x0a\x09>",
  1708. messageSends: [],
  1709. referencedClasses: []
  1710. }),
  1711. globals.NativeFunction.klass);
  1712. smalltalk.addMethod(
  1713. smalltalk.method({
  1714. selector: "exists:",
  1715. protocol: 'testing',
  1716. fn: function (aString){
  1717. var self=this;
  1718. function $PlatformInterface(){return globals.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
  1719. return smalltalk.withContext(function($ctx1) {
  1720. var $1;
  1721. $1=_st($PlatformInterface())._existsGlobal_(aString);
  1722. return $1;
  1723. }, function($ctx1) {$ctx1.fill(self,"exists:",{aString:aString},globals.NativeFunction.klass)})},
  1724. args: ["aString"],
  1725. source: "exists: aString\x0a\x09^ PlatformInterface existsGlobal: aString",
  1726. messageSends: ["existsGlobal:"],
  1727. referencedClasses: ["PlatformInterface"]
  1728. }),
  1729. globals.NativeFunction.klass);
  1730. smalltalk.addClass('Timeout', globals.Object, ['rawTimeout'], 'Kernel-Methods');
  1731. globals.Timeout.comment="I am wrapping the returns from `set{Timeout,Interval}`.\x0a\x0a## Motivation\x0a\x0aNumber suffices in browsers, but node.js returns an object.";
  1732. smalltalk.addMethod(
  1733. smalltalk.method({
  1734. selector: "clearInterval",
  1735. protocol: 'timeout/interval',
  1736. fn: function (){
  1737. var self=this;
  1738. return smalltalk.withContext(function($ctx1) {
  1739. var interval = self["@rawTimeout"];
  1740. clearInterval(interval);
  1741. ;
  1742. return self}, function($ctx1) {$ctx1.fill(self,"clearInterval",{},globals.Timeout)})},
  1743. args: [],
  1744. source: "clearInterval\x0a\x09<\x0a\x09\x09var interval = self[\x22@rawTimeout\x22];\x0a\x09\x09clearInterval(interval);\x0a\x09>",
  1745. messageSends: [],
  1746. referencedClasses: []
  1747. }),
  1748. globals.Timeout);
  1749. smalltalk.addMethod(
  1750. smalltalk.method({
  1751. selector: "clearTimeout",
  1752. protocol: 'timeout/interval',
  1753. fn: function (){
  1754. var self=this;
  1755. return smalltalk.withContext(function($ctx1) {
  1756. var timeout = self["@rawTimeout"];
  1757. clearTimeout(timeout);
  1758. ;
  1759. return self}, function($ctx1) {$ctx1.fill(self,"clearTimeout",{},globals.Timeout)})},
  1760. args: [],
  1761. source: "clearTimeout\x0a\x09<\x0a\x09\x09var timeout = self[\x22@rawTimeout\x22];\x0a\x09\x09clearTimeout(timeout);\x0a\x09>",
  1762. messageSends: [],
  1763. referencedClasses: []
  1764. }),
  1765. globals.Timeout);
  1766. smalltalk.addMethod(
  1767. smalltalk.method({
  1768. selector: "rawTimeout:",
  1769. protocol: 'accessing',
  1770. fn: function (anObject){
  1771. var self=this;
  1772. self["@rawTimeout"]=anObject;
  1773. return self},
  1774. args: ["anObject"],
  1775. source: "rawTimeout: anObject\x0a\x09rawTimeout := anObject",
  1776. messageSends: [],
  1777. referencedClasses: []
  1778. }),
  1779. globals.Timeout);
  1780. smalltalk.addMethod(
  1781. smalltalk.method({
  1782. selector: "on:",
  1783. protocol: 'instance creation',
  1784. fn: function (anObject){
  1785. var self=this;
  1786. return smalltalk.withContext(function($ctx1) {
  1787. var $2,$3,$1;
  1788. $2=self._new();
  1789. _st($2)._rawTimeout_(anObject);
  1790. $3=_st($2)._yourself();
  1791. $1=$3;
  1792. return $1;
  1793. }, function($ctx1) {$ctx1.fill(self,"on:",{anObject:anObject},globals.Timeout.klass)})},
  1794. args: ["anObject"],
  1795. source: "on: anObject\x0a\x09^ self new rawTimeout: anObject; yourself",
  1796. messageSends: ["rawTimeout:", "new", "yourself"],
  1797. referencedClasses: []
  1798. }),
  1799. globals.Timeout.klass);
  1800. });