UNPKG

amber

Version:

An implementation of the Smalltalk language that runs on top of the JS runtime.

1,528 lines (1,452 loc) 118 kB
define(["amber/boot", "amber_core/Kernel-Objects"], function($boot){"use strict"; if(!("nilAsValue" in $boot))$boot.nilAsValue=$boot.nilAsReceiver; var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals; $core.addPackage("Kernel-Methods"); ($core.packageDescriptors||$core.packages)["Kernel-Methods"].innerEval = function (expr) { return eval(expr); }; ($core.packageDescriptors||$core.packages)["Kernel-Methods"].transport = {"type":"amd","amdNamespace":"amber_core"}; $core.addClass("BlockClosure", $globals.Object, [], "Kernel-Methods"); //>>excludeStart("ide", pragmas.excludeIdeData); $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 | ... ] `"; //>>excludeEnd("ide"); $core.addMethod( $core.method({ selector: "applyTo:arguments:", protocol: "evaluating", fn: function (anObject,aCollection){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return self.apply(anObject, aCollection); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"applyTo:arguments:",{anObject:anObject,aCollection:aCollection},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anObject", "aCollection"], source: "applyTo: anObject arguments: aCollection\x0a\x09<inlineJS: 'return self.apply(anObject, aCollection)'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "asCompiledMethod:", protocol: "converting", fn: function (aString){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $core.method({selector:aString, fn:self});; return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"asCompiledMethod:",{aString:aString},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aString"], source: "asCompiledMethod: aString\x0a\x09<inlineJS: 'return $core.method({selector:aString, fn:self});'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "compiledSource", protocol: "accessing", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return self.toString(); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"compiledSource",{},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "compiledSource\x0a\x09<inlineJS: 'return self.toString()'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "currySelf", protocol: "converting", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return function () { var args = [ this ]; args.push.apply(args, arguments); return self.apply(null, args); } ; return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"currySelf",{},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], 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<inlineJS: '\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'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "ensure:", protocol: "evaluating", fn: function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); try{return $self._value()}finally{aBlock._value()}; return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"ensure:",{aBlock:aBlock},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "ensure: aBlock\x0a\x09<inlineJS: 'try{return $self._value()}finally{aBlock._value()}'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "fork", protocol: "timeout/interval", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); $recv($recv($globals.ForkPool)._default())._fork_(self); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"fork",{},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "fork\x0a\x09ForkPool default fork: self", referencedClasses: ["ForkPool"], //>>excludeEnd("ide"); messageSends: ["fork:", "default"] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "new", protocol: "evaluating", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return new self(); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"new",{},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], 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<inlineJS: 'return new self()'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "newValue:", protocol: "evaluating", fn: function (anObject){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $self._newWithValues_([anObject]); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"newValue:",{anObject:anObject},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anObject"], source: "newValue: anObject\x0a\x09^ self newWithValues: { anObject }", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["newWithValues:"] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "newValue:value:", protocol: "evaluating", fn: function (anObject,anObject2){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $self._newWithValues_([anObject,anObject2]); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"newValue:value:",{anObject:anObject,anObject2:anObject2},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anObject", "anObject2"], source: "newValue: anObject value: anObject2\x0a\x09^ self newWithValues: { anObject. anObject2 }.", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["newWithValues:"] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "newValue:value:value:", protocol: "evaluating", fn: function (anObject,anObject2,anObject3){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $self._newWithValues_([anObject,anObject2,anObject3]); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"newValue:value:value:",{anObject:anObject,anObject2:anObject2,anObject3:anObject3},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anObject", "anObject2", "anObject3"], source: "newValue: anObject value: anObject2 value: anObject3\x0a\x09^ self newWithValues: { anObject. anObject2. anObject3 }.", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["newWithValues:"] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "newWithValues:", protocol: "evaluating", fn: function (aCollection){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var object = Object.create(self.prototype); var result = self.apply(object, aCollection); return typeof result === "object" ? result : object; ; return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"newWithValues:",{aCollection:aCollection},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aCollection"], source: "newWithValues: aCollection\x0a\x09\x22Simulates JS new operator by combination of Object.create and .apply\x22\x0a\x09<inlineJS: '\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'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "numArgs", protocol: "accessing", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return self.length; return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"numArgs",{},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "numArgs\x0a\x09<inlineJS: 'return self.length'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "on:do:", protocol: "error handling", fn: function (anErrorClass,aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1; return $self._tryCatch_((function(error){ var smalltalkError; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); smalltalkError=$recv($globals.Smalltalk)._asSmalltalkException_(error); $1=$recv(smalltalkError)._isKindOf_(anErrorClass); if($core.assert($1)){ return $recv(aBlock)._value_(smalltalkError); } else { return $recv(smalltalkError)._pass(); } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({error:error,smalltalkError:smalltalkError},$ctx1,1)}); //>>excludeEnd("ctx"); })); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"on:do:",{anErrorClass:anErrorClass,aBlock:aBlock},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anErrorClass", "aBlock"], 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 tryCatch: [ :error | | smalltalkError |\x0a\x09\x09smalltalkError := Smalltalk asSmalltalkException: error.\x0a\x09\x09(smalltalkError isKindOf: anErrorClass)\x0a\x09\x09ifTrue: [ aBlock value: smalltalkError ]\x0a\x09\x09ifFalse: [ smalltalkError pass ] ]", referencedClasses: ["Smalltalk"], //>>excludeEnd("ide"); messageSends: ["tryCatch:", "asSmalltalkException:", "ifTrue:ifFalse:", "isKindOf:", "value:", "pass"] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "provided", protocol: "converting", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $recv($globals.JSObjectProxy)._on_(self); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"provided",{},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "provided\x0a\x09\x22Returns JS proxy that allows to access 'static API', as in\x0a\x09 require provided resolve: ...\x0a\x09or\x0a\x09 XMLHttpRequest provided DONE\x22\x0a\x09\x0a\x09^ JSObjectProxy on: self", referencedClasses: ["JSObjectProxy"], //>>excludeEnd("ide"); messageSends: ["on:"] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "receiver", protocol: "accessing", fn: function (){ var self=this,$self=this; return nil; }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "receiver\x0a\x09^ nil", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "timeToRun", protocol: "evaluating", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $recv($globals.Date)._millisecondsToRun_(self); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"timeToRun",{},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "timeToRun\x0a\x09\x22Answer the number of milliseconds taken to execute this block.\x22\x0a\x0a\x09^ Date millisecondsToRun: self", referencedClasses: ["Date"], //>>excludeEnd("ide"); messageSends: ["millisecondsToRun:"] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "tryCatch:", protocol: "error handling", fn: function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); try { return $self._value(); } catch(error) { // pass non-local returns undetected if (Array.isArray(error) && error.length === 1) throw error; return aBlock._value_(error); } ; return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"tryCatch:",{aBlock:aBlock},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "tryCatch: aBlock\x0a\x09<inlineJS: '\x0a\x09\x09try {\x0a\x09\x09\x09return $self._value();\x0a\x09\x09} catch(error) {\x0a\x09\x09\x09// pass non-local returns undetected\x0a\x09\x09\x09if (Array.isArray(error) && error.length === 1) throw error;\x0a\x09\x09\x09return aBlock._value_(error);\x0a\x09\x09}\x0a\x09'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "value", protocol: "evaluating", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return self();; return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"value",{},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "value\x0a\x09<inlineJS: 'return self();'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "value:", protocol: "evaluating", fn: function (anArg){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return self(anArg);; return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"value:",{anArg:anArg},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anArg"], source: "value: anArg\x0a\x09<inlineJS: 'return self(anArg);'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "value:value:", protocol: "evaluating", fn: function (firstArg,secondArg){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return self(firstArg, secondArg);; return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"value:value:",{firstArg:firstArg,secondArg:secondArg},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["firstArg", "secondArg"], source: "value: firstArg value: secondArg\x0a\x09<inlineJS: 'return self(firstArg, secondArg);'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "value:value:value:", protocol: "evaluating", fn: function (firstArg,secondArg,thirdArg){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return self(firstArg, secondArg, thirdArg);; return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"value:value:value:",{firstArg:firstArg,secondArg:secondArg,thirdArg:thirdArg},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["firstArg", "secondArg", "thirdArg"], source: "value: firstArg value: secondArg value: thirdArg\x0a\x09<inlineJS: 'return self(firstArg, secondArg, thirdArg);'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "valueWithInterval:", protocol: "timeout/interval", fn: function (aNumber){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var interval = setInterval(self, aNumber); return $globals.Timeout._on_(interval); ; return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"valueWithInterval:",{aNumber:aNumber},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aNumber"], source: "valueWithInterval: aNumber\x0a\x09<inlineJS: '\x0a\x09\x09var interval = setInterval(self, aNumber);\x0a\x09\x09return $globals.Timeout._on_(interval);\x0a\x09'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "valueWithPossibleArguments:", protocol: "evaluating", fn: function (aCollection){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return self.apply(null, aCollection);; return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"valueWithPossibleArguments:",{aCollection:aCollection},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aCollection"], source: "valueWithPossibleArguments: aCollection\x0a\x09<inlineJS: 'return self.apply(null, aCollection);'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "valueWithTimeout:", protocol: "timeout/interval", fn: function (aNumber){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var timeout = setTimeout(self, aNumber); return $globals.Timeout._on_(timeout); ; return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"valueWithTimeout:",{aNumber:aNumber},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aNumber"], source: "valueWithTimeout: aNumber\x0a\x09<inlineJS: '\x0a\x09\x09var timeout = setTimeout(self, aNumber);\x0a\x09\x09return $globals.Timeout._on_(timeout);\x0a\x09'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "whileFalse", protocol: "controlling", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); $self._whileFalse_((function(){ })); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"whileFalse",{},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "whileFalse\x0a\x09self whileFalse: []", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["whileFalse:"] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "whileFalse:", protocol: "controlling", fn: function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); while(!$core.assert($self._value())) {aBlock._value()}; return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"whileFalse:",{aBlock:aBlock},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "whileFalse: aBlock\x0a\x09<inlineJS: 'while(!$core.assert($self._value())) {aBlock._value()}'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "whileTrue", protocol: "controlling", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); $self._whileTrue_((function(){ })); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"whileTrue",{},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "whileTrue\x0a\x09self whileTrue: []", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["whileTrue:"] }), $globals.BlockClosure); $core.addMethod( $core.method({ selector: "whileTrue:", protocol: "controlling", fn: function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); while($core.assert($self._value())) {aBlock._value()}; return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"whileTrue:",{aBlock:aBlock},$globals.BlockClosure)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "whileTrue: aBlock\x0a\x09<inlineJS: 'while($core.assert($self._value())) {aBlock._value()}'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BlockClosure); $core.addClass("CompiledMethod", $globals.Object, [], "Kernel-Methods"); //>>excludeStart("ide", pragmas.excludeIdeData); $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"; //>>excludeEnd("ide"); $core.addMethod( $core.method({ selector: "arguments", protocol: "accessing", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return self.args || []; return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"arguments",{},$globals.CompiledMethod)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "arguments\x0a\x09<inlineJS: 'return self.args || []'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.CompiledMethod); $core.addMethod( $core.method({ selector: "browse", protocol: "browsing", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); $recv($globals.Finder)._findMethod_(self); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"browse",{},$globals.CompiledMethod)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "browse\x0a\x09Finder findMethod: self", referencedClasses: ["Finder"], //>>excludeEnd("ide"); messageSends: ["findMethod:"] }), $globals.CompiledMethod); $core.addMethod( $core.method({ selector: "category", protocol: "accessing", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $self._protocol(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"category",{},$globals.CompiledMethod)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "category\x0a\x09^ self protocol", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["protocol"] }), $globals.CompiledMethod); $core.addMethod( $core.method({ selector: "defaultProtocol", protocol: "defaults", fn: function (){ var self=this,$self=this; return "as yet unclassified"; }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "defaultProtocol\x0a\x09^ 'as yet unclassified'", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.CompiledMethod); $core.addMethod( $core.method({ selector: "fn", protocol: "accessing", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $self._basicAt_("fn"); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"fn",{},$globals.CompiledMethod)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "fn\x0a\x09^ self basicAt: 'fn'", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["basicAt:"] }), $globals.CompiledMethod); $core.addMethod( $core.method({ selector: "fn:", protocol: "accessing", fn: function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); $self._basicAt_put_("fn",aBlock); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"fn:",{aBlock:aBlock},$globals.CompiledMethod)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "fn: aBlock\x0a\x09self basicAt: 'fn' put: aBlock", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["basicAt:put:"] }), $globals.CompiledMethod); $core.addMethod( $core.method({ selector: "isCompiledMethod", protocol: "testing", fn: function (){ var self=this,$self=this; return true; }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "isCompiledMethod\x0a\x09^ true", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.CompiledMethod); $core.addMethod( $core.method({ selector: "isOverridden", protocol: "testing", fn: function (){ var self=this,$self=this; var selector; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1; var $early={}; try { selector=$self._selector(); $recv($self._methodClass())._allSubclassesDo_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); $1=$recv(each)._includesSelector_(selector); if($core.assert($1)){ throw $early=[true]; } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)}); //>>excludeEnd("ctx"); })); return false; } catch(e) {if(e===$early)return e[0]; throw e} //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"isOverridden",{selector:selector},$globals.CompiledMethod)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], 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", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["selector", "allSubclassesDo:", "methodClass", "ifTrue:", "includesSelector:"] }), $globals.CompiledMethod); $core.addMethod( $core.method({ selector: "isOverride", protocol: "testing", fn: function (){ var self=this,$self=this; var superclass; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1,$2,$receiver; $1=$self._methodClass(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); $ctx1.sendIdx["methodClass"]=1; //>>excludeEnd("ctx"); superclass=$recv($1)._superclass(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); $ctx1.sendIdx["superclass"]=1; //>>excludeEnd("ctx"); $2=superclass; if(($receiver = $2) == null || $receiver.a$nil){ return false; } else { $2; } return $recv($recv($recv($self._methodClass())._superclass())._lookupSelector_($self._selector()))._notNil(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"isOverride",{superclass:superclass},$globals.CompiledMethod)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], 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", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["superclass", "methodClass", "ifNil:", "notNil", "lookupSelector:", "selector"] }), $globals.CompiledMethod); $core.addMethod( $core.method({ selector: "messageSends", protocol: "accessing", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $self._basicAt_("messageSends"); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"messageSends",{},$globals.CompiledMethod)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "messageSends\x0a\x09^ self basicAt: 'messageSends'", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["basicAt:"] }), $globals.CompiledMethod); $core.addMethod( $core.method({ selector: "methodClass", protocol: "accessing", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $self._basicAt_("owner"); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"methodClass",{},$globals.CompiledMethod)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "methodClass\x0a\x09^ self basicAt: 'owner'", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["basicAt:"] }), $globals.CompiledMethod); $core.addMethod( $core.method({ selector: "package", protocol: "accessing", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1,$receiver; $1=$self._methodClass(); if(($receiver = $1) == null || $receiver.a$nil){ return $1; } else { var class_; class_=$receiver; return $recv(class_)._packageOfProtocol_($self._protocol()); } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"package",{},$globals.CompiledMethod)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], 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 methodClass ifNotNil: [ :class | class packageOfProtocol: self protocol ]", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["ifNotNil:", "methodClass", "packageOfProtocol:", "protocol"] }), $globals.CompiledMethod); $core.addMethod( $core.method({ selector: "protocol", protocol: "accessing", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1,$receiver; $1=$self._basicAt_("protocol"); if(($receiver = $1) == null || $receiver.a$nil){ return $self._defaultProtocol(); } else { return $1; } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"protocol",{},$globals.CompiledMethod)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "protocol\x0a\x09^ (self basicAt: 'protocol') ifNil: [ self defaultProtocol ]", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["ifNil:", "basicAt:", "defaultProtocol"] }), $globals.CompiledMethod); $core.addMethod( $core.method({ selector: "protocol:", protocol: "accessing", fn: function (aString){ var self=this,$self=this; var oldProtocol; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1,$3,$2,$4,$receiver; oldProtocol=$self._protocol(); $self._basicAt_put_("protocol",aString); $1=$recv($globals.SystemAnnouncer)._current(); $3=$recv($globals.MethodMoved)._new(); $recv($3)._method_(self); $recv($3)._oldProtocol_(oldProtocol); $2=$recv($3)._yourself(); $recv($1)._announce_($2); $4=$self._methodClass(); if(($receiver = $4) == null || $receiver.a$nil){ $4; } else { var methodClass; methodClass=$receiver; $recv($recv(methodClass)._organization())._addElement_(aString); $recv(methodClass)._removeProtocolIfEmpty_(oldProtocol); } return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"protocol:",{aString:aString,oldProtocol:oldProtocol},$globals.CompiledMethod)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aString"], 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 ]", referencedClasses: ["SystemAnnouncer", "MethodMoved"], //>>excludeEnd("ide"); messageSends: ["protocol", "basicAt:put:", "announce:", "current", "method:", "new", "oldProtocol:", "yourself", "ifNotNil:", "methodClass", "addElement:", "organization", "removeProtocolIfEmpty:"] }), $globals.CompiledMethod); $core.addMethod( $core.method({ selector: "referencedClasses", protocol: "accessing", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $self._basicAt_("referencedClasses"); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"referencedClasses",{},$globals.CompiledMethod)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "referencedClasses\x0a\x09^ self basicAt: 'referencedClasses'", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["basicAt:"] }), $globals.CompiledMethod); $core.addMethod( $core.method({ selector: "selector", protocol: "accessing", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $self._basicAt_("selector"); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"selector",{},$globals.CompiledMethod)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "selector\x0a\x09^ self basicAt: 'selector'", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["basicAt:"] }), $globals.CompiledMethod); $core.addMethod( $core.method({ selector: "selector:", protocol: "accessing", fn: function (aString){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); $self._basicAt_put_("selector",aString); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"selector:",{aString:aString},$globals.CompiledMethod)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aString"], source: "selector: aString\x0a\x09self basicAt: 'selector' put: aString", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["basicAt:put:"] }), $globals.CompiledMethod); $core.addMethod( $core.method({ selector: "sendTo:arguments:", protocol: "evaluating", fn: function (anObject,aCollection){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $recv($self._fn())._applyTo_arguments_(anObject,aCollection); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"sendTo:arguments:",{anObject:anObject,aCollection:aCollection},$globals.CompiledMethod)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anObject", "aCollection"], source: "sendTo: anObject arguments: aCollection\x0a\x09^ self fn applyTo: anObject arguments: aCollection", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["applyTo:arguments:", "fn"] }), $globals.CompiledMethod); $core.addMethod( $core.method({ selector: "source", protocol: "accessing", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1,$receiver; $1=$self._basicAt_("source"); if(($receiver = $1) == null || $receiver.a$nil){ return ""; } else { return $1; } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"source",{},$globals.CompiledMethod)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "source\x0a\x09^ (self basicAt: 'source') ifNil: [ '' ]", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["ifNil:", "basicAt:"] }), $globals.CompiledMethod); $core.addMethod( $core.method({ selector: "source:", protocol: "accessing", fn: function (aString){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); $self._basicAt_put_("source",aString); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"source:",{aString:aString},$globals.CompiledMethod)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aString"], source: "source: aString\x0a\x09self basicAt: 'source' put: aString", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["basicAt:put:"] }), $globals.CompiledMethod); $core.addClass("ForkPool", $globals.Object, ["poolSize", "maxPoolSize", "queue", "worker"], "Kernel-Methods"); //>>excludeStart("ide", pragmas.excludeIdeData); $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`"; //>>excludeEnd("ide"); $core.addMethod( $core.method({ selector: "addWorker", protocol: "private", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); $recv($self["@worker"])._valueWithTimeout_((0)); $self["@poolSize"]=$recv($self["@poolSize"]).__plus((1)); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"addWorker",{},$globals.ForkPool)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "addWorker\x0a\x09worker valueWithTimeout: 0.\x0a\x09poolSize := poolSize + 1", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["valueWithTimeout:", "+"] }), $globals.ForkPool); $core.addMethod( $core.method({ selector: "defaultMaxPoolSize", protocol: "defaults", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $recv($self._class())._defaultMaxPoolSize(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"defaultMaxPoolSize",{},$globals.ForkPool)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "defaultMaxPoolSize\x0a\x09^ self class defaultMaxPoolSize", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["defaultMaxPoolSize", "class"] }), $globals.ForkPool); $core.addMethod( $core.method({ selector: "fork:", protocol: "actions", fn: function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1; $1=$recv($self["@poolSize"]).__lt($self._maxPoolSize()); if($core.assert($1)){ $self._addWorker(); } $recv($self["@queue"])._nextPut_(aBlock); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"fork:",{aBlock:aBlock},$globals.ForkPool)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "fork: aBlock\x0a\x09poolSize < self maxPoolSize ifTrue: [ self addWorker ].\x0a\x09queue nextPut: aBlock", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["ifTrue:", "<", "maxPoolSize", "addWorker", "nextPut:"] }), $globals.ForkPool); $core.addMethod( $core.method({ selector: "initialize", protocol: "initialization", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); ( //>>excludeStart("ctx", pragmas.excludeDebugContexts); $ctx1.supercall = true, //>>excludeEnd("ctx"); ($globals.ForkPool.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, [])); //>>excludeStart("ctx", pragmas.excludeDebugContexts); $ctx1.supercall = false; //>>excludeEnd("ctx");; $self["@poolSize"]=(0); $self["@queue"]=$recv($globals.Queue)._new(); $self["@worker"]=$self._makeWorker(); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.ForkPool)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09poolSize := 0.\x0a\x09queue := Queue new.\x0a\x09worker := self makeWorker", referencedClasses: ["Queue"], //>>excludeEnd("ide"); messageSends: ["initialize", "new", "makeWorker"] }), $globals.ForkPool); $core.addMethod( $core.method({ selector: "makeWorker", protocol: "initialization", fn: function (){ var self=this,$self=this; var sentinel; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1; sentinel=$recv($globals.Object)._new(); return (function(){ var block; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); $self["@poolSize"]=$recv($self["@poolSize"]).__minus((1)); block=$recv($self["@queue"])._nextIfAbsent_((function(){ return sentinel; })); $1=$recv(block).__eq_eq(sentinel); if(!$core.assert($1)){ return $recv((function(){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx3) { //>>excludeEnd("ctx"); return $recv(block)._value(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx3) {$ctx3.fillBlock({},$ctx2,4)}); //>>excludeEnd("ctx"); }))._ensure_((function(){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx3) { //>>excludeEnd("ctx"); return $self._addWorker(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx3) {$ctx3.fillBlock({},$ctx2,5)}); //>>excludeEnd("ctx"); })); } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({block:block},$ctx1,1)}); //>>excludeEnd("ctx"); }); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"makeWorker",{sentinel:sentinel},$globals.ForkPool)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], 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 ] ]]", referencedClasses: ["Object"], //>>excludeEnd("ide"); messageSends: ["new", "-", "nextIfAbsent:", "ifFalse:", "==", "ensure:", "value", "addWorker"] }), $globals.ForkPool); $core.addMethod( $core.method({ selector: "maxPoolSize", protocol: "accessing", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1,$receiver; $1=$self["@maxPoolSize"]; if(($receiver = $1) == null || $receiver.a$nil){ return $self._defaultMaxPoolSize(); } else { return $1; } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"maxPoolSize",{},$globals.ForkPool)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "maxPoolSize\x0a\x09^ maxPoolSize ifNil: [ self defaultMaxPoolSize ]", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["ifNil:", "defaultMaxPoolSize"] }), $globals.ForkPool); $core.addMethod( $core.method({ selector: "maxPoolSize:", protocol: "accessing", fn: function (anInteger){ var self=this,$self=this; $self["@maxPoolSize"]=anInteger; return self; }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anInteger"], source: "maxPoolSize: anInteger\x0a\x09maxPoolSize := anInteger", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.ForkPool); $globals.ForkPool.a$cls.iVarNames = ["default"]; $core.addMethod( $core.method({ selector: "default", protocol: "accessing", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1,$receiver; $1=$self["@default"]; if(($receiver = $1) == null || $receiver.a$nil){ $self["@default"]=$self._new(); return $self["@default"]; } else { return $1; } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"default",{},$globals.ForkPool.a$cls)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "default\x0a\x09^ default ifNil: [ default := self new ]", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["ifNil:", "new"] }), $globals.ForkPool.a$cls); $core.addMethod( $core.method({ selector: "defaultMaxPoolSize", protocol: "accessing", fn: function (){ var self=this,$self=this; return (100); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "defaultMaxPoolSize\x0a\x09^ 100", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.ForkPool.a$cls); $core.addMethod( $core.method({ selector: "resetDefault", protoc