2
0

Kernel-Methods.js 58 KB

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