123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926 |
- define("amber_core/Kernel-Methods", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st, globals){
- smalltalk.addPackage('Kernel-Methods');
- smalltalk.packages["Kernel-Methods"].transport = {"type":"amd","amdNamespace":"amber_core"};
- smalltalk.addClass('BlockClosure', globals.Object, [], 'Kernel-Methods');
- 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 | ... ] `";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "applyTo:arguments:",
- protocol: 'evaluating',
- fn: function (anObject,aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.apply(anObject, aCollection);
- return self}, function($ctx1) {$ctx1.fill(self,"applyTo:arguments:",{anObject:anObject,aCollection:aCollection},globals.BlockClosure)})},
- args: ["anObject", "aCollection"],
- source: "applyTo: anObject arguments: aCollection\x0a\x09<return self.apply(anObject, aCollection)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asCompiledMethod:",
- protocol: 'converting',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return smalltalk.method({selector:aString, fn:self});;
- return self}, function($ctx1) {$ctx1.fill(self,"asCompiledMethod:",{aString:aString},globals.BlockClosure)})},
- args: ["aString"],
- source: "asCompiledMethod: aString\x0a\x09<return smalltalk.method({selector:aString, fn:self});>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compiledSource",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.toString();
- return self}, function($ctx1) {$ctx1.fill(self,"compiledSource",{},globals.BlockClosure)})},
- args: [],
- source: "compiledSource\x0a\x09<return self.toString()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "currySelf",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return function () {
- var args = [ this ];
- args.push.apply(args, arguments);
- return self.apply(null, args);
- }
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"currySelf",{},globals.BlockClosure)})},
- 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<\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>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ensure:",
- protocol: 'evaluating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- try{return self._value()}finally{aBlock._value()};
- return self}, function($ctx1) {$ctx1.fill(self,"ensure:",{aBlock:aBlock},globals.BlockClosure)})},
- args: ["aBlock"],
- source: "ensure: aBlock\x0a\x09<try{return self._value()}finally{aBlock._value()}>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fork",
- protocol: 'timeout/interval',
- fn: function (){
- var self=this;
- function $ForkPool(){return globals.ForkPool||(typeof ForkPool=="undefined"?nil:ForkPool)}
- return smalltalk.withContext(function($ctx1) {
- _st(_st($ForkPool())._default())._fork_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"fork",{},globals.BlockClosure)})},
- args: [],
- source: "fork\x0a\x09ForkPool default fork: self",
- messageSends: ["fork:", "default"],
- referencedClasses: ["ForkPool"]
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "new",
- protocol: 'evaluating',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return new self();
- return self}, function($ctx1) {$ctx1.fill(self,"new",{},globals.BlockClosure)})},
- 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<return new self()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "newValue:",
- protocol: 'evaluating',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._newWithValues_([anObject]);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"newValue:",{anObject:anObject},globals.BlockClosure)})},
- args: ["anObject"],
- source: "newValue: anObject\x0a\x09^ self newWithValues: { anObject }",
- messageSends: ["newWithValues:"],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "newValue:value:",
- protocol: 'evaluating',
- fn: function (anObject,anObject2){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._newWithValues_([anObject,anObject2]);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"newValue:value:",{anObject:anObject,anObject2:anObject2},globals.BlockClosure)})},
- args: ["anObject", "anObject2"],
- source: "newValue: anObject value: anObject2\x0a\x09^ self newWithValues: { anObject. anObject2 }.",
- messageSends: ["newWithValues:"],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "newValue:value:value:",
- protocol: 'evaluating',
- fn: function (anObject,anObject2,anObject3){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._newWithValues_([anObject,anObject2,anObject3]);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"newValue:value:value:",{anObject:anObject,anObject2:anObject2,anObject3:anObject3},globals.BlockClosure)})},
- args: ["anObject", "anObject2", "anObject3"],
- source: "newValue: anObject value: anObject2 value: anObject3\x0a\x09^ self newWithValues: { anObject. anObject2. anObject3 }.",
- messageSends: ["newWithValues:"],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "newWithValues:",
- protocol: 'evaluating',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var object = Object.create(self.prototype);
- var result = self.apply(object, aCollection);
- return typeof result === "object" ? result : object;
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"newWithValues:",{aCollection:aCollection},globals.BlockClosure)})},
- args: ["aCollection"],
- source: "newWithValues: aCollection\x0a\x09\x22Simulates JS new operator by combination of Object.create and .apply\x22\x0a\x09<\x0a\x09\x09var object = Object.create(self.prototype);\x0a\x09\x09var result = self.apply(object, aCollection);\x0a\x09\x09return typeof result === \x22object\x22 ? result : object;\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "numArgs",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.length;
- return self}, function($ctx1) {$ctx1.fill(self,"numArgs",{},globals.BlockClosure)})},
- args: [],
- source: "numArgs\x0a\x09<return self.length>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "on:do:",
- protocol: 'error handling',
- fn: function (anErrorClass,aBlock){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $1=self._try_catch_(self,(function(error){
- var smalltalkError;
- return smalltalk.withContext(function($ctx2) {
- smalltalkError=_st($Smalltalk())._asSmalltalkException_(error);
- smalltalkError;
- $2=_st(smalltalkError)._isKindOf_(anErrorClass);
- if(smalltalk.assert($2)){
- return _st(aBlock)._value_(smalltalkError);
- } else {
- return _st(smalltalkError)._resignal();
- };
- }, function($ctx2) {$ctx2.fillBlock({error:error,smalltalkError:smalltalkError},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"on:do:",{anErrorClass:anErrorClass,aBlock:aBlock},globals.BlockClosure)})},
- 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 try: self catch: [ :error | | smalltalkError |\x0a\x09\x09smalltalkError := Smalltalk asSmalltalkException: error.\x0a\x09\x09(smalltalkError isKindOf: anErrorClass)\x0a\x09\x09ifTrue: [ aBlock value: smalltalkError ]\x0a\x09\x09ifFalse: [ smalltalkError resignal ] ]",
- messageSends: ["try:catch:", "asSmalltalkException:", "ifTrue:ifFalse:", "isKindOf:", "value:", "resignal"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "receiver",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return nil;
- },
- args: [],
- source: "receiver\x0a\x09^ nil",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "timeToRun",
- protocol: 'evaluating',
- fn: function (){
- var self=this;
- function $Date(){return globals.Date||(typeof Date=="undefined"?nil:Date)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($Date())._millisecondsToRun_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"timeToRun",{},globals.BlockClosure)})},
- args: [],
- source: "timeToRun\x0a\x09\x22Answer the number of milliseconds taken to execute this block.\x22\x0a\x0a\x09^ Date millisecondsToRun: self",
- messageSends: ["millisecondsToRun:"],
- referencedClasses: ["Date"]
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value",
- protocol: 'evaluating',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self();;
- return self}, function($ctx1) {$ctx1.fill(self,"value",{},globals.BlockClosure)})},
- args: [],
- source: "value\x0a\x09<return self();>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:",
- protocol: 'evaluating',
- fn: function (anArg){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self(anArg);;
- return self}, function($ctx1) {$ctx1.fill(self,"value:",{anArg:anArg},globals.BlockClosure)})},
- args: ["anArg"],
- source: "value: anArg\x0a\x09<return self(anArg);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:value:",
- protocol: 'evaluating',
- fn: function (firstArg,secondArg){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self(firstArg, secondArg);;
- return self}, function($ctx1) {$ctx1.fill(self,"value:value:",{firstArg:firstArg,secondArg:secondArg},globals.BlockClosure)})},
- args: ["firstArg", "secondArg"],
- source: "value: firstArg value: secondArg\x0a\x09<return self(firstArg, secondArg);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:value:value:",
- protocol: 'evaluating',
- fn: function (firstArg,secondArg,thirdArg){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self(firstArg, secondArg, thirdArg);;
- return self}, function($ctx1) {$ctx1.fill(self,"value:value:value:",{firstArg:firstArg,secondArg:secondArg,thirdArg:thirdArg},globals.BlockClosure)})},
- args: ["firstArg", "secondArg", "thirdArg"],
- source: "value: firstArg value: secondArg value: thirdArg\x0a\x09<return self(firstArg, secondArg, thirdArg);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "valueWithInterval:",
- protocol: 'timeout/interval',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var interval = setInterval(self, aNumber);
- return globals.Timeout._on_(interval);
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"valueWithInterval:",{aNumber:aNumber},globals.BlockClosure)})},
- args: ["aNumber"],
- source: "valueWithInterval: aNumber\x0a\x09<\x0a\x09\x09var interval = setInterval(self, aNumber);\x0a\x09\x09return globals.Timeout._on_(interval);\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "valueWithPossibleArguments:",
- protocol: 'evaluating',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.apply(null, aCollection);;
- return self}, function($ctx1) {$ctx1.fill(self,"valueWithPossibleArguments:",{aCollection:aCollection},globals.BlockClosure)})},
- args: ["aCollection"],
- source: "valueWithPossibleArguments: aCollection\x0a\x09<return self.apply(null, aCollection);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "valueWithTimeout:",
- protocol: 'timeout/interval',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var timeout = setTimeout(self, aNumber);
- return globals.Timeout._on_(timeout);
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"valueWithTimeout:",{aNumber:aNumber},globals.BlockClosure)})},
- args: ["aNumber"],
- source: "valueWithTimeout: aNumber\x0a\x09<\x0a\x09\x09var timeout = setTimeout(self, aNumber);\x0a\x09\x09return globals.Timeout._on_(timeout);\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "whileFalse",
- protocol: 'controlling',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._whileFalse_((function(){
- }));
- return self}, function($ctx1) {$ctx1.fill(self,"whileFalse",{},globals.BlockClosure)})},
- args: [],
- source: "whileFalse\x0a\x09self whileFalse: []",
- messageSends: ["whileFalse:"],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "whileFalse:",
- protocol: 'controlling',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- while(!smalltalk.assert(self._value())) {aBlock._value()};
- return self}, function($ctx1) {$ctx1.fill(self,"whileFalse:",{aBlock:aBlock},globals.BlockClosure)})},
- args: ["aBlock"],
- source: "whileFalse: aBlock\x0a\x09<while(!smalltalk.assert(self._value())) {aBlock._value()}>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "whileTrue",
- protocol: 'controlling',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._whileTrue_((function(){
- }));
- return self}, function($ctx1) {$ctx1.fill(self,"whileTrue",{},globals.BlockClosure)})},
- args: [],
- source: "whileTrue\x0a\x09self whileTrue: []",
- messageSends: ["whileTrue:"],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "whileTrue:",
- protocol: 'controlling',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- while(smalltalk.assert(self._value())) {aBlock._value()};
- return self}, function($ctx1) {$ctx1.fill(self,"whileTrue:",{aBlock:aBlock},globals.BlockClosure)})},
- args: ["aBlock"],
- source: "whileTrue: aBlock\x0a\x09<while(smalltalk.assert(self._value())) {aBlock._value()}>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addClass('CompiledMethod', globals.Object, [], 'Kernel-Methods');
- 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";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arguments",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.args || [];
- return self}, function($ctx1) {$ctx1.fill(self,"arguments",{},globals.CompiledMethod)})},
- args: [],
- source: "arguments\x0a\x09<return self.args || []>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "category",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._protocol();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"category",{},globals.CompiledMethod)})},
- args: [],
- source: "category\x0a\x09^ self protocol",
- messageSends: ["protocol"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "defaultProtocol",
- protocol: 'defaults',
- fn: function (){
- var self=this;
- return "as yet unclassified";
- },
- args: [],
- source: "defaultProtocol\x0a\x09^ 'as yet unclassified'",
- messageSends: [],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fn",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._basicAt_("fn");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"fn",{},globals.CompiledMethod)})},
- args: [],
- source: "fn\x0a\x09^ self basicAt: 'fn'",
- messageSends: ["basicAt:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fn:",
- protocol: 'accessing',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._basicAt_put_("fn",aBlock);
- return self}, function($ctx1) {$ctx1.fill(self,"fn:",{aBlock:aBlock},globals.CompiledMethod)})},
- args: ["aBlock"],
- source: "fn: aBlock\x0a\x09self basicAt: 'fn' put: aBlock",
- messageSends: ["basicAt:put:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isCompiledMethod",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isCompiledMethod\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isOverridden",
- protocol: 'testing',
- fn: function (){
- var self=this;
- var selector;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- var $early={};
- try {
- selector=self._selector();
- _st(self._methodClass())._allSubclassesDo_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(each)._includesSelector_(selector);
- if(smalltalk.assert($1)){
- throw $early=[true];
- };
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return false;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"isOverridden",{selector:selector},globals.CompiledMethod)})},
- 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",
- messageSends: ["selector", "allSubclassesDo:", "methodClass", "ifTrue:", "includesSelector:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isOverride",
- protocol: 'testing',
- fn: function (){
- var self=this;
- var superclass;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3;
- $1=self._methodClass();
- $ctx1.sendIdx["methodClass"]=1;
- superclass=_st($1)._superclass();
- $ctx1.sendIdx["superclass"]=1;
- $2=superclass;
- if(($receiver = $2) == nil || $receiver == null){
- return false;
- } else {
- $2;
- };
- $3=_st(_st(_st(self._methodClass())._superclass())._lookupSelector_(self._selector()))._notNil();
- return $3;
- }, function($ctx1) {$ctx1.fill(self,"isOverride",{superclass:superclass},globals.CompiledMethod)})},
- 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",
- messageSends: ["superclass", "methodClass", "ifNil:", "notNil", "lookupSelector:", "selector"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "messageSends",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._basicAt_("messageSends");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"messageSends",{},globals.CompiledMethod)})},
- args: [],
- source: "messageSends\x0a\x09^ self basicAt: 'messageSends'",
- messageSends: ["basicAt:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "methodClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._basicAt_("methodClass");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"methodClass",{},globals.CompiledMethod)})},
- args: [],
- source: "methodClass\x0a\x09^ self basicAt: 'methodClass'",
- messageSends: ["basicAt:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "package",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Package(){return globals.Package||(typeof Package=="undefined"?nil:Package)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$4,$3,$5;
- $2=self._protocol();
- $ctx1.sendIdx["protocol"]=1;
- $1=_st($2)._beginsWith_("*");
- if(! smalltalk.assert($1)){
- $4=self._methodClass();
- $ctx1.sendIdx["methodClass"]=1;
- $3=_st($4)._package();
- $ctx1.sendIdx["package"]=1;
- return $3;
- };
- $5=_st($Package())._named_ifAbsent_(_st(self._protocol())._allButFirst(),(function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._methodClass())._package();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- return $5;
- }, function($ctx1) {$ctx1.fill(self,"package",{},globals.CompiledMethod)})},
- 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 protocol beginsWith: '*') ifFalse: [\x0a\x09\x09^ self methodClass package ].\x0a\x09\x09\x0a\x09^ Package \x0a\x09\x09named: self protocol allButFirst\x0a\x09\x09ifAbsent: [ self methodClass package ]",
- messageSends: ["ifFalse:", "beginsWith:", "protocol", "package", "methodClass", "named:ifAbsent:", "allButFirst"],
- referencedClasses: ["Package"]
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "protocol",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._basicAt_("protocol");
- if(($receiver = $2) == nil || $receiver == null){
- $1=self._defaultProtocol();
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"protocol",{},globals.CompiledMethod)})},
- args: [],
- source: "protocol\x0a\x09^ (self basicAt: 'protocol') ifNil: [ self defaultProtocol ]",
- messageSends: ["ifNil:", "basicAt:", "defaultProtocol"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "protocol:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- var oldProtocol;
- function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
- function $MethodMoved(){return globals.MethodMoved||(typeof MethodMoved=="undefined"?nil:MethodMoved)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3;
- oldProtocol=self._protocol();
- self._basicAt_put_("protocol",aString);
- $1=_st($MethodMoved())._new();
- _st($1)._method_(self);
- _st($1)._oldProtocol_(oldProtocol);
- $2=_st($1)._yourself();
- _st(_st($SystemAnnouncer())._current())._announce_($2);
- $3=self._methodClass();
- if(($receiver = $3) == nil || $receiver == null){
- $3;
- } else {
- var methodClass;
- methodClass=$receiver;
- _st(_st(methodClass)._organization())._addElement_(aString);
- _st(methodClass)._removeProtocolIfEmpty_(oldProtocol);
- };
- return self}, function($ctx1) {$ctx1.fill(self,"protocol:",{aString:aString,oldProtocol:oldProtocol},globals.CompiledMethod)})},
- 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 ]",
- messageSends: ["protocol", "basicAt:put:", "announce:", "current", "method:", "new", "oldProtocol:", "yourself", "ifNotNil:", "methodClass", "addElement:", "organization", "removeProtocolIfEmpty:"],
- referencedClasses: ["SystemAnnouncer", "MethodMoved"]
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "referencedClasses",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._basicAt_("referencedClasses");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"referencedClasses",{},globals.CompiledMethod)})},
- args: [],
- source: "referencedClasses\x0a\x09^ self basicAt: 'referencedClasses'",
- messageSends: ["basicAt:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._basicAt_("selector");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"selector",{},globals.CompiledMethod)})},
- args: [],
- source: "selector\x0a\x09^ self basicAt: 'selector'",
- messageSends: ["basicAt:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._basicAt_put_("selector",aString);
- return self}, function($ctx1) {$ctx1.fill(self,"selector:",{aString:aString},globals.CompiledMethod)})},
- args: ["aString"],
- source: "selector: aString\x0a\x09self basicAt: 'selector' put: aString",
- messageSends: ["basicAt:put:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sendTo:arguments:",
- protocol: 'evaluating',
- fn: function (anObject,aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._fn())._applyTo_arguments_(anObject,aCollection);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"sendTo:arguments:",{anObject:anObject,aCollection:aCollection},globals.CompiledMethod)})},
- args: ["anObject", "aCollection"],
- source: "sendTo: anObject arguments: aCollection\x0a\x09^ self fn applyTo: anObject arguments: aCollection",
- messageSends: ["applyTo:arguments:", "fn"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "source",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._basicAt_("source");
- if(($receiver = $2) == nil || $receiver == null){
- $1="";
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"source",{},globals.CompiledMethod)})},
- args: [],
- source: "source\x0a\x09^ (self basicAt: 'source') ifNil: [ '' ]",
- messageSends: ["ifNil:", "basicAt:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "source:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._basicAt_put_("source",aString);
- return self}, function($ctx1) {$ctx1.fill(self,"source:",{aString:aString},globals.CompiledMethod)})},
- args: ["aString"],
- source: "source: aString\x0a\x09self basicAt: 'source' put: aString",
- messageSends: ["basicAt:put:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addClass('ForkPool', globals.Object, ['poolSize', 'maxPoolSize', 'queue', 'worker'], 'Kernel-Methods');
- 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`";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "addWorker",
- protocol: 'private',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self["@worker"])._valueWithTimeout_((0));
- self["@poolSize"]=_st(self["@poolSize"]).__plus((1));
- return self}, function($ctx1) {$ctx1.fill(self,"addWorker",{},globals.ForkPool)})},
- args: [],
- source: "addWorker\x0a\x09worker valueWithTimeout: 0.\x0a\x09poolSize := poolSize + 1",
- messageSends: ["valueWithTimeout:", "+"],
- referencedClasses: []
- }),
- globals.ForkPool);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "defaultMaxPoolSize",
- protocol: 'defaults',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._class())._defaultMaxPoolSize();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"defaultMaxPoolSize",{},globals.ForkPool)})},
- args: [],
- source: "defaultMaxPoolSize\x0a\x09^ self class defaultMaxPoolSize",
- messageSends: ["defaultMaxPoolSize", "class"],
- referencedClasses: []
- }),
- globals.ForkPool);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fork:",
- protocol: 'actions',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self["@poolSize"]).__lt(self._maxPoolSize());
- if(smalltalk.assert($1)){
- self._addWorker();
- };
- _st(self["@queue"])._nextPut_(aBlock);
- return self}, function($ctx1) {$ctx1.fill(self,"fork:",{aBlock:aBlock},globals.ForkPool)})},
- args: ["aBlock"],
- source: "fork: aBlock\x0a\x09poolSize < self maxPoolSize ifTrue: [ self addWorker ].\x0a\x09queue nextPut: aBlock",
- messageSends: ["ifTrue:", "<", "maxPoolSize", "addWorker", "nextPut:"],
- referencedClasses: []
- }),
- globals.ForkPool);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- function $Queue(){return globals.Queue||(typeof Queue=="undefined"?nil:Queue)}
- return smalltalk.withContext(function($ctx1) {
- globals.ForkPool.superclass.fn.prototype._initialize.apply(_st(self), []);
- self["@poolSize"]=(0);
- self["@queue"]=_st($Queue())._new();
- self["@worker"]=self._makeWorker();
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.ForkPool)})},
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09poolSize := 0.\x0a\x09queue := Queue new.\x0a\x09worker := self makeWorker",
- messageSends: ["initialize", "new", "makeWorker"],
- referencedClasses: ["Queue"]
- }),
- globals.ForkPool);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "makeWorker",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- var sentinel;
- function $Object(){return globals.Object||(typeof Object=="undefined"?nil:Object)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- sentinel=_st($Object())._new();
- $1=(function(){
- var block;
- return smalltalk.withContext(function($ctx2) {
- self["@poolSize"]=_st(self["@poolSize"]).__minus((1));
- self["@poolSize"];
- block=_st(self["@queue"])._nextIfAbsent_((function(){
- return sentinel;
- }));
- block;
- $2=_st(block).__eq_eq(sentinel);
- if(! smalltalk.assert($2)){
- return _st((function(){
- return smalltalk.withContext(function($ctx3) {
- return _st(block)._value();
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,4)})}))._ensure_((function(){
- return smalltalk.withContext(function($ctx3) {
- return self._addWorker();
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,5)})}));
- };
- }, function($ctx2) {$ctx2.fillBlock({block:block},$ctx1,1)})});
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"makeWorker",{sentinel:sentinel},globals.ForkPool)})},
- 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 ] ]]",
- messageSends: ["new", "-", "nextIfAbsent:", "ifFalse:", "==", "ensure:", "value", "addWorker"],
- referencedClasses: ["Object"]
- }),
- globals.ForkPool);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "maxPoolSize",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@maxPoolSize"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=self._defaultMaxPoolSize();
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"maxPoolSize",{},globals.ForkPool)})},
- args: [],
- source: "maxPoolSize\x0a\x09^ maxPoolSize ifNil: [ self defaultMaxPoolSize ]",
- messageSends: ["ifNil:", "defaultMaxPoolSize"],
- referencedClasses: []
- }),
- globals.ForkPool);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "maxPoolSize:",
- protocol: 'accessing',
- fn: function (anInteger){
- var self=this;
- self["@maxPoolSize"]=anInteger;
- return self},
- args: ["anInteger"],
- source: "maxPoolSize: anInteger\x0a\x09maxPoolSize := anInteger",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ForkPool);
- globals.ForkPool.klass.iVarNames = ['default'];
- smalltalk.addMethod(
- smalltalk.method({
- selector: "default",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@default"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@default"]=self._new();
- $1=self["@default"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"default",{},globals.ForkPool.klass)})},
- args: [],
- source: "default\x0a\x09^ default ifNil: [ default := self new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: []
- }),
- globals.ForkPool.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "defaultMaxPoolSize",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return (100);
- },
- args: [],
- source: "defaultMaxPoolSize\x0a\x09^ 100",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ForkPool.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "resetDefault",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- self["@default"]=nil;
- return self},
- args: [],
- source: "resetDefault\x0a\x09default := nil",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ForkPool.klass);
- smalltalk.addClass('Message', globals.Object, ['selector', 'arguments'], 'Kernel-Methods');
- globals.Message.comment="In general, the system does not use instances of me for efficiency reasons.\x0aHowever, when a message is not understood by its receiver, the interpreter will make up an instance of it in order to capture the information involved in an actual message transmission.\x0aThis instance is sent it as an argument with the message `#doesNotUnderstand:` to the receiver.\x0a\x0aSee boot.js, `messageNotUnderstood` and its counterpart `Object >> #doesNotUnderstand:`\x0a\x0a## API\x0a\x0aBesides accessing methods, `#sendTo:` provides a convenient way to send a message to an object.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arguments",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@arguments"];
- return $1;
- },
- args: [],
- source: "arguments\x0a\x09^ arguments",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Message);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arguments:",
- protocol: 'accessing',
- fn: function (anArray){
- var self=this;
- self["@arguments"]=anArray;
- return self},
- args: ["anArray"],
- source: "arguments: anArray\x0a\x09arguments := anArray",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Message);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- globals.Message.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]);
- _st(aStream)._nextPutAll_("(");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st(aStream)._nextPutAll_(self._selector());
- $ctx1.sendIdx["nextPutAll:"]=2;
- $1=_st(aStream)._nextPutAll_(")");
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.Message)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09super printOn: aStream.\x0a\x09aStream\x0a\x09\x09nextPutAll: '(';\x0a\x09\x09nextPutAll: self selector;\x0a\x09\x09nextPutAll: ')'",
- messageSends: ["printOn:", "nextPutAll:", "selector"],
- referencedClasses: []
- }),
- globals.Message);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@selector"];
- return $1;
- },
- args: [],
- source: "selector\x0a\x09^ selector",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Message);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@selector"]=aString;
- return self},
- args: ["aString"],
- source: "selector: aString\x0a\x09selector := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Message);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sendTo:",
- protocol: 'actions',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(anObject)._perform_withArguments_(self._selector(),self._arguments());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"sendTo:",{anObject:anObject},globals.Message)})},
- args: ["anObject"],
- source: "sendTo: anObject\x0a\x09^ anObject perform: self selector withArguments: self arguments",
- messageSends: ["perform:withArguments:", "selector", "arguments"],
- referencedClasses: []
- }),
- globals.Message);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector:arguments:",
- protocol: 'instance creation',
- fn: function (aString,anArray){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._selector_(aString);
- _st($2)._arguments_(anArray);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"selector:arguments:",{aString:aString,anArray:anArray},globals.Message.klass)})},
- args: ["aString", "anArray"],
- source: "selector: aString arguments: anArray\x0a\x09^ self new\x0a\x09\x09selector: aString;\x0a\x09\x09arguments: anArray;\x0a\x09\x09yourself",
- messageSends: ["selector:", "new", "arguments:", "yourself"],
- referencedClasses: []
- }),
- globals.Message.klass);
- smalltalk.addClass('MessageSend', globals.Object, ['receiver', 'message'], 'Kernel-Methods');
- globals.MessageSend.comment="I encapsulate message sends to objects. Arguments can be either predefined or supplied when the message send is performed. \x0a\x0a## API\x0a\x0aUse `#value` to perform a message send with its predefined arguments and `#value:*` if additonal arguments have to supplied.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arguments",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self["@message"])._arguments();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"arguments",{},globals.MessageSend)})},
- args: [],
- source: "arguments\x0a\x09^ message arguments",
- messageSends: ["arguments"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arguments:",
- protocol: 'accessing',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self["@message"])._arguments_(aCollection);
- return self}, function($ctx1) {$ctx1.fill(self,"arguments:",{aCollection:aCollection},globals.MessageSend)})},
- args: ["aCollection"],
- source: "arguments: aCollection\x0a\x09message arguments: aCollection",
- messageSends: ["arguments:"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- function $Message(){return globals.Message||(typeof Message=="undefined"?nil:Message)}
- return smalltalk.withContext(function($ctx1) {
- globals.MessageSend.superclass.fn.prototype._initialize.apply(_st(self), []);
- self["@message"]=_st($Message())._new();
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.MessageSend)})},
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a\x09message := Message new",
- messageSends: ["initialize", "new"],
- referencedClasses: ["Message"]
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- globals.MessageSend.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]);
- _st(aStream)._nextPutAll_("(");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st(aStream)._nextPutAll_(self._receiver());
- $ctx1.sendIdx["nextPutAll:"]=2;
- _st(aStream)._nextPutAll_(" >> ");
- $ctx1.sendIdx["nextPutAll:"]=3;
- _st(aStream)._nextPutAll_(self._selector());
- $ctx1.sendIdx["nextPutAll:"]=4;
- $1=_st(aStream)._nextPutAll_(")");
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.MessageSend)})},
- args: ["aStream"],
- 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: ')'",
- messageSends: ["printOn:", "nextPutAll:", "receiver", "selector"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "receiver",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@receiver"];
- return $1;
- },
- args: [],
- source: "receiver\x0a\x09^ receiver",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "receiver:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- self["@receiver"]=anObject;
- return self},
- args: ["anObject"],
- source: "receiver: anObject\x0a\x09receiver := anObject",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self["@message"])._selector();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"selector",{},globals.MessageSend)})},
- args: [],
- source: "selector\x0a\x09^ message selector",
- messageSends: ["selector"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self["@message"])._selector_(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"selector:",{aString:aString},globals.MessageSend)})},
- args: ["aString"],
- source: "selector: aString\x0a\x09message selector: aString",
- messageSends: ["selector:"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value",
- protocol: 'evaluating',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self["@message"])._sendTo_(self._receiver());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"value",{},globals.MessageSend)})},
- args: [],
- source: "value\x0a\x09^ message sendTo: self receiver",
- messageSends: ["sendTo:", "receiver"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:",
- protocol: 'evaluating',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self["@message"];
- _st($2)._arguments_([anObject]);
- $3=_st($2)._sendTo_(self._receiver());
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"value:",{anObject:anObject},globals.MessageSend)})},
- args: ["anObject"],
- source: "value: anObject\x0a\x09^ message \x0a\x09\x09arguments: { anObject };\x0a\x09\x09sendTo: self receiver",
- messageSends: ["arguments:", "sendTo:", "receiver"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:value:",
- protocol: 'evaluating',
- fn: function (firstArgument,secondArgument){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self["@message"];
- _st($2)._arguments_([firstArgument,secondArgument]);
- $3=_st($2)._sendTo_(self._receiver());
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"value:value:",{firstArgument:firstArgument,secondArgument:secondArgument},globals.MessageSend)})},
- args: ["firstArgument", "secondArgument"],
- source: "value: firstArgument value: secondArgument\x0a\x09^ message \x0a\x09\x09arguments: { firstArgument. secondArgument };\x0a\x09\x09sendTo: self receiver",
- messageSends: ["arguments:", "sendTo:", "receiver"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:value:value:",
- protocol: 'evaluating',
- fn: function (firstArgument,secondArgument,thirdArgument){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self["@message"];
- _st($2)._arguments_([firstArgument,secondArgument,thirdArgument]);
- $3=_st($2)._sendTo_(self._receiver());
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"value:value:value:",{firstArgument:firstArgument,secondArgument:secondArgument,thirdArgument:thirdArgument},globals.MessageSend)})},
- args: ["firstArgument", "secondArgument", "thirdArgument"],
- source: "value: firstArgument value: secondArgument value: thirdArgument\x0a\x09^ message \x0a\x09\x09arguments: { firstArgument. secondArgument. thirdArgument };\x0a\x09\x09sendTo: self receiver",
- messageSends: ["arguments:", "sendTo:", "receiver"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "valueWithPossibleArguments:",
- protocol: 'evaluating',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- self._arguments_(aCollection);
- $1=self._value();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"valueWithPossibleArguments:",{aCollection:aCollection},globals.MessageSend)})},
- args: ["aCollection"],
- source: "valueWithPossibleArguments: aCollection\x0a\x09self arguments: aCollection.\x0a\x09^ self value",
- messageSends: ["arguments:", "value"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addClass('MethodContext', globals.Object, [], 'Kernel-Methods');
- globals.MethodContext.comment="I hold all the dynamic state associated with the execution of either a method activation resulting from a message send. I am used to build the call stack while debugging.\x0a\x0aMy instances are JavaScript `SmalltalkMethodContext` objects defined in `boot.js`.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asString",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._isBlockContext();
- if(smalltalk.assert($2)){
- $3="a block (in ".__comma(_st(self._methodContext())._asString());
- $ctx1.sendIdx[","]=2;
- $1=_st($3).__comma(")");
- $ctx1.sendIdx[","]=1;
- } else {
- $1=_st(_st(_st(_st(self._receiver())._class())._name()).__comma(" >> ")).__comma(self._selector());
- $ctx1.sendIdx[","]=3;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asString",{},globals.MethodContext)})},
- args: [],
- source: "asString\x0a\x09^ self isBlockContext\x0a\x09\x09ifTrue: [ 'a block (in ', self methodContext asString, ')' ]\x0a\x09\x09ifFalse: [ self receiver class name, ' >> ', self selector ]",
- messageSends: ["ifTrue:ifFalse:", "isBlockContext", ",", "asString", "methodContext", "name", "class", "receiver", "selector"],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "evaluatedSelector",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.evaluatedSelector;
- return self}, function($ctx1) {$ctx1.fill(self,"evaluatedSelector",{},globals.MethodContext)})},
- args: [],
- source: "evaluatedSelector\x0a\x09<return self.evaluatedSelector>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "home",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.homeContext;
- return self}, function($ctx1) {$ctx1.fill(self,"home",{},globals.MethodContext)})},
- args: [],
- source: "home\x0a\x09<return self.homeContext>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "index",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.index || 0;
- return self}, function($ctx1) {$ctx1.fill(self,"index",{},globals.MethodContext)})},
- args: [],
- source: "index\x0a\x09<return self.index || 0>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isBlockContext",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._selector())._isNil();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isBlockContext",{},globals.MethodContext)})},
- args: [],
- source: "isBlockContext\x0a\x09\x22Block context do not have selectors.\x22\x0a\x09\x0a\x09^ self selector isNil",
- messageSends: ["isNil", "selector"],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "locals",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.locals || {};
- return self}, function($ctx1) {$ctx1.fill(self,"locals",{},globals.MethodContext)})},
- args: [],
- source: "locals\x0a\x09<return self.locals || {}>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "method",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$5,$4,$3,$1;
- $2=self._methodContext();
- $ctx1.sendIdx["methodContext"]=1;
- if(($receiver = $2) == nil || $receiver == null){
- $1=$2;
- } else {
- $5=self._methodContext();
- $ctx1.sendIdx["methodContext"]=2;
- $4=_st($5)._receiver();
- $3=_st($4)._class();
- $1=_st($3)._lookupSelector_(_st(self._methodContext())._selector());
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"method",{},globals.MethodContext)})},
- args: [],
- source: "method\x0a\x09^ self methodContext ifNotNil: [\x0a\x09\x09self methodContext receiver class lookupSelector: self methodContext selector ]",
- messageSends: ["ifNotNil:", "methodContext", "lookupSelector:", "class", "receiver", "selector"],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "methodContext",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$3,$2;
- $1=self._isBlockContext();
- if(! smalltalk.assert($1)){
- return self;
- };
- $3=self._outerContext();
- if(($receiver = $3) == nil || $receiver == null){
- $2=$3;
- } else {
- var outer;
- outer=$receiver;
- $2=_st(outer)._methodContext();
- };
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"methodContext",{},globals.MethodContext)})},
- args: [],
- source: "methodContext\x0a\x09self isBlockContext ifFalse: [ ^ self ].\x0a\x09\x0a\x09^ self outerContext ifNotNil: [ :outer |\x0a\x09\x09outer methodContext ]",
- messageSends: ["ifFalse:", "isBlockContext", "ifNotNil:", "outerContext", "methodContext"],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "outerContext",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.outerContext || self.homeContext;
- return self}, function($ctx1) {$ctx1.fill(self,"outerContext",{},globals.MethodContext)})},
- args: [],
- source: "outerContext\x0a\x09<return self.outerContext || self.homeContext>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- globals.MethodContext.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]);
- _st(aStream)._nextPutAll_("(");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st(aStream)._nextPutAll_(self._asString());
- $ctx1.sendIdx["nextPutAll:"]=2;
- $1=_st(aStream)._nextPutAll_(")");
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.MethodContext)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09super printOn: aStream.\x0a\x09aStream \x0a\x09\x09nextPutAll: '(';\x0a\x09\x09nextPutAll: self asString;\x0a\x09\x09nextPutAll: ')'",
- messageSends: ["printOn:", "nextPutAll:", "asString"],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "receiver",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.receiver;
- return self}, function($ctx1) {$ctx1.fill(self,"receiver",{},globals.MethodContext)})},
- args: [],
- source: "receiver\x0a\x09<return self.receiver>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- if(self.selector) {
- return smalltalk.convertSelector(self.selector);
- } else {
- return nil;
- }
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"selector",{},globals.MethodContext)})},
- args: [],
- 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>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sendIndexAt:",
- protocol: 'accessing',
- fn: function (aSelector){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.sendIdx[aSelector] || 0;
- return self}, function($ctx1) {$ctx1.fill(self,"sendIndexAt:",{aSelector:aSelector},globals.MethodContext)})},
- args: ["aSelector"],
- source: "sendIndexAt: aSelector\x0a\x09<return self.sendIdx[aSelector] || 0>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sendIndexes",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.sendIdx;
- return self}, function($ctx1) {$ctx1.fill(self,"sendIndexes",{},globals.MethodContext)})},
- args: [],
- source: "sendIndexes\x0a\x09<return self.sendIdx>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "temps",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- self._deprecatedAPI();
- $1=self._locals();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"temps",{},globals.MethodContext)})},
- args: [],
- source: "temps\x0a\x09self deprecatedAPI.\x0a\x09\x0a\x09^ self locals",
- messageSends: ["deprecatedAPI", "locals"],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addClass('NativeFunction', globals.Object, [], 'Kernel-Methods');
- globals.NativeFunction.comment="I am a wrapper around native functions, such as `WebSocket`.\x0aFor 'normal' functions (whose constructor is the JavaScript `Function` object), use `BlockClosure`.\x0a\x0a## API\x0a\x0aSee the class-side `instance creation` methods for instance creation.\x0a\x0aCreated instances will most probably be instance of `JSObjectProxy`.\x0a\x0a## Usage example:\x0a\x0a\x09| ws |\x0a\x09ws := NativeFunction constructor: 'WebSocket' value: 'ws://localhost'.\x0a\x09ws at: 'onopen' put: [ ws send: 'hey there from Amber' ]";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "constructor:",
- protocol: 'instance creation',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var native=eval(aString);
- return new native();
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"constructor:",{aString:aString},globals.NativeFunction.klass)})},
- args: ["aString"],
- source: "constructor: aString\x0a\x09<\x0a\x09\x09var native=eval(aString);\x0a\x09\x09return new native();\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.NativeFunction.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "constructor:value:",
- protocol: 'instance creation',
- fn: function (aString,anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var native=eval(aString);
- return new native(anObject);
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"constructor:value:",{aString:aString,anObject:anObject},globals.NativeFunction.klass)})},
- args: ["aString", "anObject"],
- source: "constructor: aString value:anObject\x0a\x09<\x0a\x09\x09var native=eval(aString);\x0a\x09\x09return new native(anObject);\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.NativeFunction.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "constructor:value:value:",
- protocol: 'instance creation',
- fn: function (aString,anObject,anObject2){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var native=eval(aString);
- return new native(anObject,anObject2);
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"constructor:value:value:",{aString:aString,anObject:anObject,anObject2:anObject2},globals.NativeFunction.klass)})},
- args: ["aString", "anObject", "anObject2"],
- source: "constructor: aString value:anObject value: anObject2\x0a\x09<\x0a\x09\x09var native=eval(aString);\x0a\x09\x09return new native(anObject,anObject2);\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.NativeFunction.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "constructor:value:value:value:",
- protocol: 'instance creation',
- fn: function (aString,anObject,anObject2,anObject3){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var native=eval(aString);
- return new native(anObject,anObject2, anObject3);
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"constructor:value:value:value:",{aString:aString,anObject:anObject,anObject2:anObject2,anObject3:anObject3},globals.NativeFunction.klass)})},
- args: ["aString", "anObject", "anObject2", "anObject3"],
- 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>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.NativeFunction.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "exists:",
- protocol: 'testing',
- fn: function (aString){
- var self=this;
- function $PlatformInterface(){return globals.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($PlatformInterface())._existsGlobal_(aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"exists:",{aString:aString},globals.NativeFunction.klass)})},
- args: ["aString"],
- source: "exists: aString\x0a\x09^ PlatformInterface existsGlobal: aString",
- messageSends: ["existsGlobal:"],
- referencedClasses: ["PlatformInterface"]
- }),
- globals.NativeFunction.klass);
- smalltalk.addClass('Timeout', globals.Object, ['rawTimeout'], 'Kernel-Methods');
- globals.Timeout.comment="I am wrapping the returns from `set{Timeout,Interval}`.\x0a\x0a## Motivation\x0a\x0aNumber suffices in browsers, but node.js returns an object.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "clearInterval",
- protocol: 'timeout/interval',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var interval = self["@rawTimeout"];
- clearInterval(interval);
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"clearInterval",{},globals.Timeout)})},
- args: [],
- source: "clearInterval\x0a\x09<\x0a\x09\x09var interval = self[\x22@rawTimeout\x22];\x0a\x09\x09clearInterval(interval);\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Timeout);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "clearTimeout",
- protocol: 'timeout/interval',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var timeout = self["@rawTimeout"];
- clearTimeout(timeout);
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"clearTimeout",{},globals.Timeout)})},
- args: [],
- source: "clearTimeout\x0a\x09<\x0a\x09\x09var timeout = self[\x22@rawTimeout\x22];\x0a\x09\x09clearTimeout(timeout);\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Timeout);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "rawTimeout:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- self["@rawTimeout"]=anObject;
- return self},
- args: ["anObject"],
- source: "rawTimeout: anObject\x0a\x09rawTimeout := anObject",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Timeout);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "on:",
- protocol: 'instance creation',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._rawTimeout_(anObject);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"on:",{anObject:anObject},globals.Timeout.klass)})},
- args: ["anObject"],
- source: "on: anObject\x0a\x09^ self new rawTimeout: anObject; yourself",
- messageSends: ["rawTimeout:", "new", "yourself"],
- referencedClasses: []
- }),
- globals.Timeout.klass);
- });
|