UNPKG

@ambers/lang

Version:

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

1,462 lines (1,396 loc) 377 kB
define(["amber/boot", "require", "amber/core/Kernel-Objects"], function($boot,requirejs){"use strict"; var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals; var $pkg = $core.addPackage("Kernel-Collections"); $pkg.transport = {"type":"amd","amdNamespace":"amber/core"}; $core.addClass("Association", $globals.Object, "Kernel-Collections"); $core.setSlots($globals.Association, ["key", "value"]); //>>excludeStart("ide", pragmas.excludeIdeData); $globals.Association.comment="I represent a pair of associated objects, a key and a value. My instances can serve as entries in a dictionary.\x0a\x0aInstances can be created with the class-side method `#key:value:`"; //>>excludeEnd("ide"); $core.addMethod( $core.method({ selector: "=", protocol: "comparing", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anAssociation"], source: "= anAssociation\x0a\x09^ self class = anAssociation class and: [\x0a\x09\x09self key = anAssociation key and: [\x0a\x09\x09self value = anAssociation value ]]", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["and:", "=", "class", "key", "value"] }, function ($methodClass){ return function (anAssociation){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); if($core.assert([$recv([$self._class() //>>excludeStart("ctx", pragmas.excludeDebugContexts); ,$ctx1.sendIdx["class"]=1 //>>excludeEnd("ctx"); ][0]).__eq($recv(anAssociation)._class()) //>>excludeStart("ctx", pragmas.excludeDebugContexts); ,$ctx1.sendIdx["="]=1 //>>excludeEnd("ctx"); ][0])){ if($core.assert([$recv([$self._key() //>>excludeStart("ctx", pragmas.excludeDebugContexts); ,$ctx1.sendIdx["key"]=1 //>>excludeEnd("ctx"); ][0]).__eq($recv(anAssociation)._key()) //>>excludeStart("ctx", pragmas.excludeDebugContexts); ,$ctx1.sendIdx["="]=2 //>>excludeEnd("ctx"); ][0])){ return $recv([$self._value() //>>excludeStart("ctx", pragmas.excludeDebugContexts); ,$ctx1.sendIdx["value"]=1 //>>excludeEnd("ctx"); ][0]).__eq($recv(anAssociation)._value()); } else { return false; } } else { return false; } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"=",{anAssociation:anAssociation})}); //>>excludeEnd("ctx"); }; }), $globals.Association); $core.addMethod( $core.method({ selector: "key", protocol: "accessing", //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "key\x0a\x09^ key", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: [] }, function ($methodClass){ return function (){ var self=this,$self=this; return $self.key; }; }), $globals.Association); $core.addMethod( $core.method({ selector: "key:", protocol: "accessing", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aKey"], source: "key: aKey\x0a\x09key := aKey", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: [] }, function ($methodClass){ return function (aKey){ var self=this,$self=this; $self.key=aKey; return self; }; }), $globals.Association); $core.addMethod( $core.method({ selector: "printOn:", protocol: "printing", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aStream"], source: "printOn: aStream\x0a\x09self key printOn: aStream.\x0a\x09aStream nextPutAll: ' -> '.\x0a\x09self value printOn: aStream", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["printOn:", "key", "nextPutAll:", "value"] }, function ($methodClass){ return function (aStream){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); [$recv($self._key())._printOn_(aStream) //>>excludeStart("ctx", pragmas.excludeDebugContexts); ,$ctx1.sendIdx["printOn:"]=1 //>>excludeEnd("ctx"); ][0]; $recv(aStream)._nextPutAll_(" -> "); $recv($self._value())._printOn_(aStream); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream})}); //>>excludeEnd("ctx"); }; }), $globals.Association); $core.addMethod( $core.method({ selector: "value", protocol: "accessing", //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "value\x0a\x09^ value", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: [] }, function ($methodClass){ return function (){ var self=this,$self=this; return $self.value; }; }), $globals.Association); $core.addMethod( $core.method({ selector: "value:", protocol: "accessing", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aValue"], source: "value: aValue\x0a\x09value := aValue", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: [] }, function ($methodClass){ return function (aValue){ var self=this,$self=this; $self.value=aValue; return self; }; }), $globals.Association); $core.addMethod( $core.method({ selector: "key:value:", protocol: "instance creation", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aKey", "aValue"], source: "key: aKey value: aValue\x0a\x09\x09^ self new\x0a\x09\x09key: aKey;\x0a\x09\x09value: aValue;\x0a\x09\x09yourself", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["key:", "new", "value:", "yourself"] }, function ($methodClass){ return function (aKey,aValue){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1; $1=$self._new(); $recv($1)._key_(aKey); $recv($1)._value_(aValue); return $recv($1)._yourself(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"key:value:",{aKey:aKey,aValue:aValue})}); //>>excludeEnd("ctx"); }; }), $globals.Association.a$cls); $core.addClass("BucketStore", $globals.Object, "Kernel-Collections"); $core.setSlots($globals.BucketStore, ["buckets", "hashBlock"]); //>>excludeStart("ide", pragmas.excludeIdeData); $globals.BucketStore.comment="I am an helper class for hash-based stores.\x0a\x0aI hold buckets which are selected by a hash, specified using `#hashBlock:`.\x0aThe hash can be any object, and\x0ait is used as a JS property (that is, in ES5\x0aits toString() value counts).\x0a\x0a## API\x0aI maintain a list of buckets. Client code can use this API:\x0a - `#bucketOfElement:` (to ask a bucket for element, I can return JS null if n/a)\x0a - `#do:` (to enumerate all elements of all buckets)\x0a - `#removeAll` (to remove all buckets)\x0a\x0aClient code itself should add/remove elements\x0ain a bucket. The `nil` object should not be put into any bucket.\x0a\x0aTypes of buckets are the responsibility of subclasses via `#newBucket`."; //>>excludeEnd("ide"); $core.addMethod( $core.method({ selector: "bucketOfElement:", protocol: "accessing", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anObject"], source: "bucketOfElement: anObject\x0a\x09<inlineJS: '\x0a\x09\x09var hash = $self.hashBlock(anObject);\x0a\x09\x09if (!hash) return null;\x0a\x09\x09var buckets = $self.buckets,\x0a\x09\x09\x09bucket = buckets[hash];\x0a\x09\x09if (!bucket) { bucket = buckets[hash] = $self._newBucket(); }\x0a\x09\x09return bucket;\x0a\x09'>", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [["inlineJS:", ["\x0a\x09\x09var hash = $self.hashBlock(anObject);\x0a\x09\x09if (!hash) return null;\x0a\x09\x09var buckets = $self.buckets,\x0a\x09\x09\x09bucket = buckets[hash];\x0a\x09\x09if (!bucket) { bucket = buckets[hash] = $self._newBucket(); }\x0a\x09\x09return bucket;\x0a\x09"]]], messageSends: [] }, function ($methodClass){ return function (anObject){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var hash = $self.hashBlock(anObject); if (!hash) return null; var buckets = $self.buckets, bucket = buckets[hash]; if (!bucket) { bucket = buckets[hash] = $self._newBucket(); } return bucket; ; return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"bucketOfElement:",{anObject:anObject})}); //>>excludeEnd("ctx"); }; }), $globals.BucketStore); $core.addMethod( $core.method({ selector: "do:", protocol: "enumerating", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "do: aBlock\x0a\x09<inlineJS: '\x0a\x09\x09var buckets = $self.buckets;\x0a\x09\x09var keys = Object.keys(buckets);\x0a\x09\x09for (var i = 0; i < keys.length; ++i) { buckets[keys[i]]._do_(aBlock); }\x0a\x09'>", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [["inlineJS:", ["\x0a\x09\x09var buckets = $self.buckets;\x0a\x09\x09var keys = Object.keys(buckets);\x0a\x09\x09for (var i = 0; i < keys.length; ++i) { buckets[keys[i]]._do_(aBlock); }\x0a\x09"]]], messageSends: [] }, function ($methodClass){ return function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var buckets = $self.buckets; var keys = Object.keys(buckets); for (var i = 0; i < keys.length; ++i) { buckets[keys[i]]._do_(aBlock); } ; return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock})}); //>>excludeEnd("ctx"); }; }), $globals.BucketStore); $core.addMethod( $core.method({ selector: "hashBlock:", protocol: "accessing", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "hashBlock: aBlock\x0a\x09hashBlock := aBlock", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: [] }, function ($methodClass){ return function (aBlock){ var self=this,$self=this; $self.hashBlock=aBlock; return self; }; }), $globals.BucketStore); $core.addMethod( $core.method({ selector: "initialize", protocol: "initialization", //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "initialize\x0a\x09super initialize.\x0a\x09self removeAll", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["initialize", "removeAll"] }, function ($methodClass){ return 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"); ($methodClass.superclass||$boot.nilAsClass).fn.prototype._initialize.call($self)) //>>excludeStart("ctx", pragmas.excludeDebugContexts); ,$ctx1.supercall = false //>>excludeEnd("ctx"); ][0]; $self._removeAll(); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"initialize",{})}); //>>excludeEnd("ctx"); }; }), $globals.BucketStore); $core.addMethod( $core.method({ selector: "newBucket", protocol: "private", //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "newBucket\x0a\x09self subclassResponsibility", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["subclassResponsibility"] }, function ($methodClass){ return function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); $self._subclassResponsibility(); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"newBucket",{})}); //>>excludeEnd("ctx"); }; }), $globals.BucketStore); $core.addMethod( $core.method({ selector: "removeAll", protocol: "adding/removing", //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "removeAll\x0a\x09<inlineJS: '$self.buckets = Object.create(null);'>", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [["inlineJS:", ["$self.buckets = Object.create(null);"]]], messageSends: [] }, function ($methodClass){ return function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); $self.buckets = Object.create(null);; return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"removeAll",{})}); //>>excludeEnd("ctx"); }; }), $globals.BucketStore); $core.addMethod( $core.method({ selector: "hashBlock:", protocol: "instance creation", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "hashBlock: aBlock\x0a\x09^ self new\x0a\x09\x09hashBlock: aBlock;\x0a\x09\x09yourself", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["hashBlock:", "new", "yourself"] }, function ($methodClass){ return function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1; $1=$self._new(); $recv($1)._hashBlock_(aBlock); return $recv($1)._yourself(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"hashBlock:",{aBlock:aBlock})}); //>>excludeEnd("ctx"); }; }), $globals.BucketStore.a$cls); $core.addClass("ArrayBucketStore", $globals.BucketStore, "Kernel-Collections"); //>>excludeStart("ide", pragmas.excludeIdeData); $globals.ArrayBucketStore.comment="I am a concrete `BucketStore` with buckets being instance of `Array`."; //>>excludeEnd("ide"); $core.addMethod( $core.method({ selector: "newBucket", protocol: "private", //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "newBucket\x0a\x09^ #()", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: [] }, function ($methodClass){ return function (){ var self=this,$self=this; return []; }; }), $globals.ArrayBucketStore); $core.addClass("Collection", $globals.Object, "Kernel-Collections"); //>>excludeStart("ide", pragmas.excludeIdeData); $globals.Collection.comment="I am the abstract superclass of all classes that represent a group of elements.\x0a\x0aI provide a set of useful methods to the Collection hierarchy such as enumerating and converting methods."; //>>excludeEnd("ide"); $core.addMethod( $core.method({ selector: ",", protocol: "copying", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aCollection"], source: ", aCollection\x0a\x09^ self copy\x0a\x09\x09addAll: aCollection;\x0a\x09\x09yourself", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["addAll:", "copy", "yourself"] }, function ($methodClass){ return function (aCollection){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1; $1=$self._copy(); $recv($1)._addAll_(aCollection); return $recv($1)._yourself(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,",",{aCollection:aCollection})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "add:", protocol: "adding/removing", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anObject"], source: "add: anObject\x0a\x09self subclassResponsibility", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["subclassResponsibility"] }, function ($methodClass){ return function (anObject){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); $self._subclassResponsibility(); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"add:",{anObject:anObject})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "addAll:", protocol: "adding/removing", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aCollection"], source: "addAll: aCollection\x0a\x09aCollection do: [ :each |\x0a\x09\x09self add: each ].\x0a\x09^ aCollection", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["do:", "add:"] }, function ($methodClass){ return function (aCollection){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); $recv(aCollection)._do_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); return $self._add_(each); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)}); //>>excludeEnd("ctx"); })); return aCollection; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"addAll:",{aCollection:aCollection})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "allSatisfy:", protocol: "enumerating", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "allSatisfy: aBlock\x0a\x09\x22Evaluate aBlock with the elements of the receiver.\x0a\x09If aBlock returns false for any element return false.\x0a\x09Otherwise return true.\x22\x0a\x0a\x09self do: [ :each | (aBlock value: each) ifFalse: [ ^ false ] ].\x0a\x09^ true", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["do:", "ifFalse:", "value:"] }, function ($methodClass){ return function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $early={}; try { $self._do_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); if($core.assert($recv(aBlock)._value_(each))){ return nil; } else { throw $early=[false]; } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)}); //>>excludeEnd("ctx"); })); return true; } catch(e) {if(e===$early)return e[0]; throw e} //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"allSatisfy:",{aBlock:aBlock})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "anyOne", protocol: "accessing", //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "anyOne\x0a\x09\x22Answer a representative sample of the receiver. This method can\x0a\x09be helpful when needing to preinfer the nature of the contents of \x0a\x09semi-homogeneous collections.\x22\x0a\x0a\x09self ifEmpty: [ self error: 'Collection is empty' ].\x0a\x09self do: [ :each | ^ each ]", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["ifEmpty:", "error:", "do:"] }, function ($methodClass){ return function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $early={}; try { $self._ifEmpty_((function(){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); return $self._error_("Collection is empty"); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)}); //>>excludeEnd("ctx"); })); $self._do_((function(each){ throw $early=[each]; })); return self; } catch(e) {if(e===$early)return e[0]; throw e} //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"anyOne",{})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "anySatisfy:", protocol: "enumerating", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "anySatisfy: aBlock\x0a\x09\x22Evaluate aBlock with the elements of the receiver.\x0a\x09If aBlock returns true for any element return true.\x0a\x09Otherwise return false.\x22\x0a\x0a\x09self do: [ :each | (aBlock value: each) ifTrue: [ ^ true ] ].\x0a\x09^ false", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["do:", "ifTrue:", "value:"] }, function ($methodClass){ return function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $early={}; try { $self._do_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); if($core.assert($recv(aBlock)._value_(each))){ throw $early=[true]; } else { return nil; } //>>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,"anySatisfy:",{aBlock:aBlock})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "asArray", protocol: "converting", //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "asArray\x0a\x09^ Array withAll: self", referencedClasses: ["Array"], //>>excludeEnd("ide"); pragmas: [], messageSends: ["withAll:"] }, function ($methodClass){ return function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $recv($globals.Array)._withAll_(self); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"asArray",{})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "asJavaScriptObject", protocol: "converting", //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "asJavaScriptObject\x0a\x09^ self asArray collect: [ :each | each asJavaScriptObject ]", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["collect:", "asArray", "asJavaScriptObject"] }, function ($methodClass){ return function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $recv($self._asArray())._collect_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); return $recv(each)._asJavaScriptObject(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)}); //>>excludeEnd("ctx"); })); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"asJavaScriptObject",{})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "asOrderedCollection", protocol: "converting", //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "asOrderedCollection\x0a\x09^ self asArray", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["asArray"] }, function ($methodClass){ return function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $self._asArray(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"asOrderedCollection",{})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "asSet", protocol: "converting", //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "asSet\x0a\x09^ Set withAll: self", referencedClasses: ["Set"], //>>excludeEnd("ide"); pragmas: [], messageSends: ["withAll:"] }, function ($methodClass){ return function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $recv($globals.Set)._withAll_(self); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"asSet",{})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "collect:", protocol: "enumerating", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "collect: aBlock\x0a\x09| stream |\x0a\x09stream := self class new writeStream.\x0a\x09self do: [ :each |\x0a\x09\x09stream nextPut: (aBlock value: each) ].\x0a\x09^ stream contents", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["writeStream", "new", "class", "do:", "nextPut:", "value:", "contents"] }, function ($methodClass){ return function (aBlock){ var self=this,$self=this; var stream; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); stream=$recv($recv($self._class())._new())._writeStream(); $self._do_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); return $recv(stream)._nextPut_($recv(aBlock)._value_(each)); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)}); //>>excludeEnd("ctx"); })); return $recv(stream)._contents(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"collect:",{aBlock:aBlock,stream:stream})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "copyEmpty", protocol: "copying", //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "copyEmpty\x0a\x09^ self class new", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["new", "class"] }, function ($methodClass){ return function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $recv($self._class())._new(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"copyEmpty",{})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "copyWith:", protocol: "copying", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anObject"], source: "copyWith: anObject\x0a\x09^ self copy add: anObject; yourself", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["add:", "copy", "yourself"] }, function ($methodClass){ return function (anObject){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1; $1=$self._copy(); $recv($1)._add_(anObject); return $recv($1)._yourself(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"copyWith:",{anObject:anObject})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "copyWithAll:", protocol: "copying", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aCollection"], source: "copyWithAll: aCollection\x0a\x09self deprecatedAPI: 'Use #, instead.'.\x0a\x09^ self, aCollection", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["deprecatedAPI:", ","] }, function ($methodClass){ return function (aCollection){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); $self._deprecatedAPI_("Use #, instead."); return $self.__comma(aCollection); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"copyWithAll:",{aCollection:aCollection})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "copyWithout:", protocol: "copying", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anObject"], source: "copyWithout: anObject\x0a\x09\x22Answer a copy of the receiver that does not contain\x0a\x09any occurrences of anObject.\x22\x0a\x0a\x09^ self reject: [ :each | each = anObject ]", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["reject:", "="] }, function ($methodClass){ return function (anObject){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $self._reject_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); return $recv(each).__eq(anObject); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)}); //>>excludeEnd("ctx"); })); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"copyWithout:",{anObject:anObject})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "copyWithoutAll:", protocol: "copying", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aCollection"], source: "copyWithoutAll: aCollection\x0a\x09\x22Answer a copy of the receiver that does not contain any elements\x0a\x09equal to those in aCollection.\x22\x0a\x0a\x09^ self reject: [ :each | aCollection includes: each ]", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["reject:", "includes:"] }, function ($methodClass){ return function (aCollection){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $self._reject_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); return $recv(aCollection)._includes_(each); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)}); //>>excludeEnd("ctx"); })); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"copyWithoutAll:",{aCollection:aCollection})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "deepCopy", protocol: "copying", //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "deepCopy\x0a\x09^ self collect: [ :each | each deepCopy ]", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["collect:", "deepCopy"] }, function ($methodClass){ return function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $self._collect_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); return $recv(each)._deepCopy(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)}); //>>excludeEnd("ctx"); })); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"deepCopy",{})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "detect:", protocol: "enumerating", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "detect: aBlock\x0a\x09^ self detect: aBlock ifNone: [ self errorNotFound ]", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["detect:ifNone:", "errorNotFound"] }, function ($methodClass){ return function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $self._detect_ifNone_(aBlock,(function(){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); return $self._errorNotFound(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)}); //>>excludeEnd("ctx"); })); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"detect:",{aBlock:aBlock})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "detect:ifNone:", protocol: "enumerating", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock", "anotherBlock"], source: "detect: aBlock ifNone: anotherBlock\x0a\x09self do: [ :each | (aBlock value: each) ifTrue: [ ^each ] ].\x0a\x09^ anotherBlock value", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["do:", "ifTrue:", "value:", "value"] }, function ($methodClass){ return function (aBlock,anotherBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $early={}; try { $self._do_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); if($core.assert($recv(aBlock)._value_(each))){ throw $early=[each]; } else { return nil; } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)}); //>>excludeEnd("ctx"); })); return $recv(anotherBlock)._value(); } catch(e) {if(e===$early)return e[0]; throw e} //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"detect:ifNone:",{aBlock:aBlock,anotherBlock:anotherBlock})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "do:", protocol: "enumerating", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "do: aBlock\x0a\x09self subclassResponsibility", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["subclassResponsibility"] }, function ($methodClass){ return function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); $self._subclassResponsibility(); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "do:separatedBy:", protocol: "enumerating", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock", "anotherBlock"], source: "do: aBlock separatedBy: anotherBlock\x0a\x09| actionBeforeElement |\x0a\x09actionBeforeElement := [ actionBeforeElement := anotherBlock ].\x0a\x09self do: [ :each |\x0a\x09\x09actionBeforeElement value.\x0a\x09\x09aBlock value: each ]", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["do:", "value", "value:"] }, function ($methodClass){ return function (aBlock,anotherBlock){ var self=this,$self=this; var actionBeforeElement; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); actionBeforeElement=(function(){ actionBeforeElement=anotherBlock; return actionBeforeElement; }); $self._do_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); $recv(actionBeforeElement)._value(); return $recv(aBlock)._value_(each); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)}); //>>excludeEnd("ctx"); })); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"do:separatedBy:",{aBlock:aBlock,anotherBlock:anotherBlock,actionBeforeElement:actionBeforeElement})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "errorNotFound", protocol: "error handling", //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "errorNotFound\x0a\x09self error: 'Object is not in the collection'", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["error:"] }, function ($methodClass){ return function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); $self._error_("Object is not in the collection"); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"errorNotFound",{})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "ifEmpty:", protocol: "testing", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "ifEmpty: aBlock\x0a\x09\x22Evaluate the given block with the receiver as argument, answering its value if the receiver is empty, otherwise answer the receiver. \x0a\x09Note that the fact that this method returns its argument in case the receiver is not empty allows one to write expressions like the following ones: \x0a\x09\x09self classifyMethodAs:\x0a\x09\x09\x09(myProtocol ifEmpty: ['As yet unclassified'])\x22\x0a\x09^ self isEmpty\x0a\x09\x09ifTrue: \x22aBlock\x22 [ aBlock value ]\x0a\x09\x09ifFalse: [ self ]", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["ifTrue:ifFalse:", "isEmpty", "value"] }, function ($methodClass){ return function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); if($core.assert($self._isEmpty())){ return $recv(aBlock)._value(); } else { return self; } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"ifEmpty:",{aBlock:aBlock})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "ifEmpty:ifNotEmpty:", protocol: "testing", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock", "anotherBlock"], source: "ifEmpty: aBlock ifNotEmpty: anotherBlock\x0a\x09^ self isEmpty\x0a\x09\x09ifTrue: \x22aBlock\x22 [ aBlock value ]\x0a\x09\x09ifFalse: [ anotherBlock value: self ]", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["ifTrue:ifFalse:", "isEmpty", "value", "value:"] }, function ($methodClass){ return function (aBlock,anotherBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); if($core.assert($self._isEmpty())){ return $recv(aBlock)._value(); } else { return $recv(anotherBlock)._value_(self); } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"ifEmpty:ifNotEmpty:",{aBlock:aBlock,anotherBlock:anotherBlock})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "ifNotEmpty:", protocol: "testing", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "ifNotEmpty: aBlock\x0a\x09^ self notEmpty\x0a\x09\x09ifTrue: [ aBlock value: self ]\x0a\x09\x09ifFalse: [ self ]", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["ifTrue:ifFalse:", "notEmpty", "value:"] }, function ($methodClass){ return function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); if($core.assert($self._notEmpty())){ return $recv(aBlock)._value_(self); } else { return self; } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"ifNotEmpty:",{aBlock:aBlock})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "ifNotEmpty:ifEmpty:", protocol: "testing", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock", "anotherBlock"], source: "ifNotEmpty: aBlock ifEmpty: anotherBlock\x0a\x09^ self notEmpty\x0a\x09\x09ifTrue: [ aBlock value: self ]\x0a\x09\x09ifFalse: \x22anotherBlock\x22 [ anotherBlock value ]", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["ifTrue:ifFalse:", "notEmpty", "value:", "value"] }, function ($methodClass){ return function (aBlock,anotherBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); if($core.assert($self._notEmpty())){ return $recv(aBlock)._value_(self); } else { return $recv(anotherBlock)._value(); } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"ifNotEmpty:ifEmpty:",{aBlock:aBlock,anotherBlock:anotherBlock})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "includes:", protocol: "testing", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anObject"], source: "includes: anObject\x0a\x09^ self anySatisfy: [ :each | each = anObject ]", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["anySatisfy:", "="] }, function ($methodClass){ return function (anObject){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $self._anySatisfy_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); return $recv(each).__eq(anObject); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)}); //>>excludeEnd("ctx"); })); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"includes:",{anObject:anObject})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "inject:into:", protocol: "enumerating", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anObject", "aBlock"], source: "inject: anObject into: aBlock\x0a\x09| result |\x0a\x09result := anObject.\x0a\x09self do: [ :each |\x0a\x09\x09result := aBlock value: result value: each ].\x0a\x09^ result", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["do:", "value:value:"] }, function ($methodClass){ return function (anObject,aBlock){ var self=this,$self=this; var result; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); result=anObject; $self._do_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); result=$recv(aBlock)._value_value_(result,each); return result; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)}); //>>excludeEnd("ctx"); })); return result; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"inject:into:",{anObject:anObject,aBlock:aBlock,result:result})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "intersection:", protocol: "enumerating", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aCollection"], source: "intersection: aCollection\x0a\x09\x22Answer the set theoretic intersection of two collections.\x22\x0a\x0a\x09| set outputSet |\x0a\x09\x0a\x09set := self asSet.\x0a\x09outputSet := Set new.\x0a\x09\x0a\x09aCollection do: [ :each |\x0a\x09\x09((set includes: each) and: [ (outputSet includes: each) not ])\x0a\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09outputSet add: each ]].\x0a\x09\x09\x0a\x09^ self class withAll: outputSet asArray", referencedClasses: ["Set"], //>>excludeEnd("ide"); pragmas: [], messageSends: ["asSet", "new", "do:", "ifTrue:", "and:", "includes:", "not", "add:", "withAll:", "class", "asArray"] }, function ($methodClass){ return function (aCollection){ var self=this,$self=this; var set,outputSet; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1; set=$self._asSet(); outputSet=$recv($globals.Set)._new(); $recv(aCollection)._do_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); if($core.assert([$recv(set)._includes_(each) //>>excludeStart("ctx", pragmas.excludeDebugContexts); ,$ctx2.sendIdx["includes:"]=1 //>>excludeEnd("ctx"); ][0])){ $1=$recv($recv(outputSet)._includes_(each))._not(); } else { $1=false; } if($core.assert($1)){ return $recv(outputSet)._add_(each); } else { return nil; } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)}); //>>excludeEnd("ctx"); })); return $recv($self._class())._withAll_($recv(outputSet)._asArray()); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"intersection:",{aCollection:aCollection,set:set,outputSet:outputSet})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "isEmpty", protocol: "testing", //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "isEmpty\x0a\x09^ self size = 0", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["=", "size"] }, function ($methodClass){ return function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $recv($self._size()).__eq((0)); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"isEmpty",{})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "noneSatisfy:", protocol: "enumerating", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "noneSatisfy: aBlock\x0a\x09\x22Evaluate aBlock with the elements of the receiver.\x0a\x09If aBlock returns false for all elements return true.\x0a\x09Otherwise return false\x22\x0a\x0a\x09self do: [ :item | (aBlock value: item) ifTrue: [ ^ false ] ].\x0a\x09^ true", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["do:", "ifTrue:", "value:"] }, function ($methodClass){ return function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $early={}; try { $self._do_((function(item){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); if($core.assert($recv(aBlock)._value_(item))){ throw $early=[false]; } else { return nil; } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({item:item},$ctx1,1)}); //>>excludeEnd("ctx"); })); return true; } catch(e) {if(e===$early)return e[0]; throw e} //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"noneSatisfy:",{aBlock:aBlock})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "notEmpty", protocol: "testing", //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "notEmpty\x0a\x09^ self isEmpty not", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["not", "isEmpty"] }, function ($methodClass){ return function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $recv($self._isEmpty())._not(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"notEmpty",{})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "occurrencesOf:", protocol: "accessing", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anObject"], source: "occurrencesOf: anObject\x0a\x09\x22Answer how many of the receiver's elements are equal to anObject.\x22\x0a\x0a\x09| tally |\x0a\x09tally := 0.\x0a\x09self do: [ :each | anObject = each ifTrue: [ tally := tally + 1 ]].\x0a\x09^ tally", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["do:", "ifTrue:", "=", "+"] }, function ($methodClass){ return function (anObject){ var self=this,$self=this; var tally; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); tally=(0); $self._do_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); if($core.assert($recv(anObject).__eq(each))){ tally=$recv(tally).__plus((1)); return tally; } else { return nil; } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)}); //>>excludeEnd("ctx"); })); return tally; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"occurrencesOf:",{anObject:anObject,tally:tally})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "putOn:", protocol: "streaming", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aStream"], source: "putOn: aStream\x0a\x09self do: [ :each | each putOn: aStream ]", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["do:", "putOn:"] }, function ($methodClass){ return function (aStream){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); $self._do_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); return $recv(each)._putOn_(aStream); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)}); //>>excludeEnd("ctx"); })); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"putOn:",{aStream:aStream})}); //>>excludeEnd("ctx"); }; }), $globals.Collection); $core.addMethod( $core.method({ selector: "reject:", protocol: "enumerating", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "reject: aBlock\x0a\x09^ self select: [ :each | (aBlock value: each) = false ]", refer