UNPKG

amber

Version:

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

1,502 lines (1,435 loc) 345 kB
define(["amber/boot", "amber_core/Kernel-Objects"], function($boot){"use strict"; if(!("nilAsValue" in $boot))$boot.nilAsValue=$boot.nilAsReceiver; var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals; $core.addPackage("Kernel-Collections"); ($core.packageDescriptors||$core.packages)["Kernel-Collections"].innerEval = function (expr) { return eval(expr); }; ($core.packageDescriptors||$core.packages)["Kernel-Collections"].transport = {"type":"amd","amdNamespace":"amber_core"}; $core.addClass("Association", $globals.Object, ["key", "value"], "Kernel-Collections"); //>>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", fn: function (anAssociation){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $3,$2,$5,$4,$6,$1; $3=$self._class(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); $ctx1.sendIdx["class"]=1; //>>excludeEnd("ctx"); $2=$recv($3).__eq($recv(anAssociation)._class()); //>>excludeStart("ctx", pragmas.excludeDebugContexts); $ctx1.sendIdx["="]=1; //>>excludeEnd("ctx"); $1=$recv($2)._and_((function(){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); $5=$self._key(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); $ctx2.sendIdx["key"]=1; //>>excludeEnd("ctx"); $4=$recv($5).__eq($recv(anAssociation)._key()); //>>excludeStart("ctx", pragmas.excludeDebugContexts); $ctx2.sendIdx["="]=2; //>>excludeEnd("ctx"); return $recv($4)._and_((function(){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx3) { //>>excludeEnd("ctx"); $6=$self._value(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); $ctx3.sendIdx["value"]=1; //>>excludeEnd("ctx"); return $recv($6).__eq($recv(anAssociation)._value()); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)}); //>>excludeEnd("ctx"); })); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)}); //>>excludeEnd("ctx"); })); //>>excludeStart("ctx", pragmas.excludeDebugContexts); $ctx1.sendIdx["and:"]=1; //>>excludeEnd("ctx"); return $1; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"=",{anAssociation:anAssociation},$globals.Association)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: ["and:", "=", "class", "key", "value"] }), $globals.Association); $core.addMethod( $core.method({ selector: "key", protocol: "accessing", fn: function (){ var self=this,$self=this; return $self["@key"]; }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "key\x0a\x09^ key", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.Association); $core.addMethod( $core.method({ selector: "key:", protocol: "accessing", fn: function (aKey){ var self=this,$self=this; $self["@key"]=aKey; return self; }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aKey"], source: "key: aKey\x0a\x09key := aKey", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.Association); $core.addMethod( $core.method({ selector: "printOn:", protocol: "printing", fn: 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"); $recv(aStream)._nextPutAll_(" -> "); $recv($self._value())._printOn_(aStream); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},$globals.Association)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: ["printOn:", "key", "nextPutAll:", "value"] }), $globals.Association); $core.addMethod( $core.method({ selector: "value", protocol: "accessing", fn: function (){ var self=this,$self=this; return $self["@value"]; }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "value\x0a\x09^ value", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.Association); $core.addMethod( $core.method({ selector: "value:", protocol: "accessing", fn: function (aValue){ var self=this,$self=this; $self["@value"]=aValue; return self; }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aValue"], source: "value: aValue\x0a\x09value := aValue", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.Association); $core.addMethod( $core.method({ selector: "key:value:", protocol: "instance creation", fn: 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},$globals.Association.a$cls)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: ["key:", "new", "value:", "yourself"] }), $globals.Association.a$cls); $core.addClass("BucketStore", $globals.Object, ["buckets", "hashBlock"], "Kernel-Collections"); //>>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", fn: 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},$globals.BucketStore)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: [] }), $globals.BucketStore); $core.addMethod( $core.method({ selector: "do:", protocol: "enumerating", fn: 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},$globals.BucketStore)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: [] }), $globals.BucketStore); $core.addMethod( $core.method({ selector: "hashBlock:", protocol: "accessing", fn: function (aBlock){ var self=this,$self=this; $self["@hashBlock"]=aBlock; return self; }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "hashBlock: aBlock\x0a\x09hashBlock := aBlock", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BucketStore); $core.addMethod( $core.method({ selector: "initialize", protocol: "initialization", fn: function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); ( //>>excludeStart("ctx", pragmas.excludeDebugContexts); $ctx1.supercall = true, //>>excludeEnd("ctx"); ($globals.BucketStore.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, [])); //>>excludeStart("ctx", pragmas.excludeDebugContexts); $ctx1.supercall = false; //>>excludeEnd("ctx");; $self._removeAll(); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.BucketStore)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "initialize\x0a\x09super initialize.\x0a\x09self removeAll", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["initialize", "removeAll"] }), $globals.BucketStore); $core.addMethod( $core.method({ selector: "newBucket", protocol: "private", fn: 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",{},$globals.BucketStore)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "newBucket\x0a\x09self subclassResponsibility", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["subclassResponsibility"] }), $globals.BucketStore); $core.addMethod( $core.method({ selector: "removeAll", protocol: "adding/removing", fn: 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",{},$globals.BucketStore)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "removeAll\x0a\x09<inlineJS: '$self[''@buckets''] = Object.create(null);'>", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $globals.BucketStore); $core.addMethod( $core.method({ selector: "hashBlock:", protocol: "instance creation", fn: 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},$globals.BucketStore.a$cls)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "hashBlock: aBlock\x0a\x09^ self new\x0a\x09\x09hashBlock: aBlock;\x0a\x09\x09yourself", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["hashBlock:", "new", "yourself"] }), $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", fn: function (){ var self=this,$self=this; return []; }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "newBucket\x0a\x09^ #()", referencedClasses: [], //>>excludeEnd("ide"); messageSends: [] }), $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", fn: 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},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aCollection"], source: ", aCollection\x0a\x09^ self copy\x0a\x09\x09addAll: aCollection;\x0a\x09\x09yourself", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["addAll:", "copy", "yourself"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "add:", protocol: "adding/removing", fn: 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},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anObject"], source: "add: anObject\x0a\x09self subclassResponsibility", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["subclassResponsibility"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "addAll:", protocol: "adding/removing", fn: 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},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aCollection"], source: "addAll: aCollection\x0a\x09aCollection do: [ :each |\x0a\x09\x09self add: each ].\x0a\x09^ aCollection", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["do:", "add:"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "allSatisfy:", protocol: "enumerating", fn: function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1; var $early={}; try { $self._do_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); $1=$recv(aBlock)._value_(each); if(!$core.assert($1)){ 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},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: ["do:", "ifFalse:", "value:"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "anyOne", protocol: "accessing", fn: 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",{},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: ["ifEmpty:", "error:", "do:"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "anySatisfy:", protocol: "enumerating", fn: function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1; var $early={}; try { $self._do_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); $1=$recv(aBlock)._value_(each); if($core.assert($1)){ throw $early=[true]; } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)}); //>>excludeEnd("ctx"); })); return false; } catch(e) {if(e===$early)return e[0]; throw e} //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"anySatisfy:",{aBlock:aBlock},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: ["do:", "ifTrue:", "value:"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "asArray", protocol: "converting", fn: 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",{},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "asArray\x0a\x09^ Array withAll: self", referencedClasses: ["Array"], //>>excludeEnd("ide"); messageSends: ["withAll:"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "asJavaScriptObject", protocol: "converting", fn: 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",{},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "asJavaScriptObject\x0a\x09^ self asArray collect: [ :each | each asJavaScriptObject ]", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["collect:", "asArray", "asJavaScriptObject"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "asOrderedCollection", protocol: "converting", fn: 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",{},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "asOrderedCollection\x0a\x09^ self asArray", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["asArray"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "asSet", protocol: "converting", fn: 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",{},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "asSet\x0a\x09^ Set withAll: self", referencedClasses: ["Set"], //>>excludeEnd("ide"); messageSends: ["withAll:"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "collect:", protocol: "enumerating", fn: 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},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: ["writeStream", "new", "class", "do:", "nextPut:", "value:", "contents"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "copyWith:", protocol: "copying", fn: 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},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anObject"], source: "copyWith: anObject\x0a\x09^ self copy add: anObject; yourself", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["add:", "copy", "yourself"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "copyWithAll:", protocol: "copying", fn: 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,"copyWithAll:",{aCollection:aCollection},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aCollection"], source: "copyWithAll: aCollection\x0a\x09^ self copy addAll: aCollection; yourself", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["addAll:", "copy", "yourself"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "copyWithout:", protocol: "copying", fn: 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},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: ["reject:", "="] }), $globals.Collection); $core.addMethod( $core.method({ selector: "copyWithoutAll:", protocol: "copying", fn: 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},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: ["reject:", "includes:"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "deepCopy", protocol: "copying", fn: 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",{},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "deepCopy\x0a\x09^ self collect: [ :each | each deepCopy ]", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["collect:", "deepCopy"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "detect:", protocol: "enumerating", fn: 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},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "detect: aBlock\x0a\x09^ self detect: aBlock ifNone: [ self errorNotFound ]", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["detect:ifNone:", "errorNotFound"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "detect:ifNone:", protocol: "enumerating", fn: function (aBlock,anotherBlock){ 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,"detect:ifNone:",{aBlock:aBlock,anotherBlock:anotherBlock},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock", "anotherBlock"], source: "detect: aBlock ifNone: anotherBlock\x0a\x09self subclassResponsibility", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["subclassResponsibility"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "do:", protocol: "enumerating", fn: 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},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "do: aBlock\x0a\x09self subclassResponsibility", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["subclassResponsibility"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "do:separatedBy:", protocol: "enumerating", fn: 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},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: ["do:", "value", "value:"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "errorNotFound", protocol: "error handling", fn: 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",{},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "errorNotFound\x0a\x09self error: 'Object is not in the collection'", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["error:"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "ifEmpty:", protocol: "testing", fn: function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1; $1=$self._isEmpty(); if($core.assert($1)){ return $recv(aBlock)._value(); } else { return self; } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"ifEmpty:",{aBlock:aBlock},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: ["ifTrue:ifFalse:", "isEmpty", "value"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "ifEmpty:ifNotEmpty:", protocol: "testing", fn: function (aBlock,anotherBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1; $1=$self._isEmpty(); if($core.assert($1)){ 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},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: ["ifTrue:ifFalse:", "isEmpty", "value", "value:"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "ifNotEmpty:", protocol: "testing", fn: function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1; $1=$self._notEmpty(); if($core.assert($1)){ return $recv(aBlock)._value_(self); } else { return self; } //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"ifNotEmpty:",{aBlock:aBlock},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: ["ifTrue:ifFalse:", "notEmpty", "value:"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "ifNotEmpty:ifEmpty:", protocol: "testing", fn: function (aBlock,anotherBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1; $1=$self._notEmpty(); if($core.assert($1)){ 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},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: ["ifTrue:ifFalse:", "notEmpty", "value:", "value"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "includes:", protocol: "testing", fn: 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},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anObject"], source: "includes: anObject\x0a\x09^ self anySatisfy: [ :each | each = anObject ]", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["anySatisfy:", "="] }), $globals.Collection); $core.addMethod( $core.method({ selector: "inject:into:", protocol: "enumerating", fn: 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},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: ["do:", "value:value:"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "intersection:", protocol: "enumerating", fn: function (aCollection){ var self=this,$self=this; var set,outputSet; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $2,$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"); $2=$recv(set)._includes_(each); //>>excludeStart("ctx", pragmas.excludeDebugContexts); $ctx2.sendIdx["includes:"]=1; //>>excludeEnd("ctx"); $1=$recv($2)._and_((function(){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx3) { //>>excludeEnd("ctx"); return $recv($recv(outputSet)._includes_(each))._not(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)}); //>>excludeEnd("ctx"); })); if($core.assert($1)){ return $recv(outputSet)._add_(each); } //>>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},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: ["asSet", "new", "do:", "ifTrue:", "and:", "includes:", "not", "add:", "withAll:", "class", "asArray"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "isEmpty", protocol: "testing", fn: 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",{},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "isEmpty\x0a\x09^ self size = 0", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["=", "size"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "noneSatisfy:", protocol: "enumerating", fn: function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1; var $early={}; try { $self._do_((function(item){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); $1=$recv(aBlock)._value_(item); if($core.assert($1)){ throw $early=[false]; } //>>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},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: ["do:", "ifTrue:", "value:"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "notEmpty", protocol: "testing", fn: 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",{},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "notEmpty\x0a\x09^ self isEmpty not", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["not", "isEmpty"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "occurrencesOf:", protocol: "accessing", fn: function (anObject){ var self=this,$self=this; var tally; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1; tally=(0); $self._do_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); $1=$recv(anObject).__eq(each); if($core.assert($1)){ tally=$recv(tally).__plus((1)); return tally; } //>>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},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>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"); messageSends: ["do:", "ifTrue:", "=", "+"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "putOn:", protocol: "streaming", fn: 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},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aStream"], source: "putOn: aStream\x0a\x09self do: [ :each | each putOn: aStream ]", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["do:", "putOn:"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "reject:", protocol: "enumerating", fn: function (aBlock){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $self._select_((function(each){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); return $recv($recv(aBlock)._value_(each)).__eq(false); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)}); //>>excludeEnd("ctx"); })); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"reject:",{aBlock:aBlock},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["aBlock"], source: "reject: aBlock\x0a\x09^ self select: [ :each | (aBlock value: each) = false ]", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["select:", "=", "value:"] }), $globals.Collection); $core.addMethod( $core.method({ selector: "remove:", protocol: "adding/removing", fn: function (anObject){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); return $self._remove_ifAbsent_(anObject,(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,"remove:",{anObject:anObject},$globals.Collection)}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: ["anObject"], source: "remove: anObject\x0a\x09^ self remove: anObject ifAbsent: [ self errorNotFound ]", referencedClasses: [], //>>excludeEnd("ide"); messageSends: ["remove:ifAbsent:", "errorNotFound"] }), $globals.Collection); $core.addMethod( $cor