Browse Source

Move more things to TNativeZeroBasedCollection.

Herby Vojčík 5 years ago
parent
commit
4bf5b4254e
2 changed files with 100 additions and 128 deletions
  1. 80 104
      lang/src/Kernel-Collections.js
  2. 20 24
      lang/src/Kernel-Collections.st

+ 80 - 104
lang/src/Kernel-Collections.js

@@ -4455,62 +4455,6 @@ messageSends: [",", "join:", "collect:", "asJavaScriptSource"]
 }),
 $globals.Array);
 
-$core.addMethod(
-$core.method({
-selector: "at:ifAbsent:",
-protocol: "accessing",
-fn: function (anIndex,aBlock){
-var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-
-		return anIndex >= 1 && anIndex <= self.length
-			? self[anIndex - 1]
-			: aBlock._value()
-	;
-return self;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"at:ifAbsent:",{anIndex:anIndex,aBlock:aBlock},$globals.Array)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["anIndex", "aBlock"],
-source: "at: anIndex ifAbsent: aBlock\x0a\x09<inlineJS: '\x0a\x09\x09return anIndex >= 1 && anIndex <= self.length\x0a\x09\x09\x09? self[anIndex - 1]\x0a\x09\x09\x09: aBlock._value()\x0a\x09'>",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: []
-}),
-$globals.Array);
-
-$core.addMethod(
-$core.method({
-selector: "at:ifPresent:ifAbsent:",
-protocol: "accessing",
-fn: function (anIndex,aBlock,anotherBlock){
-var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-
-		return anIndex >= 1 && anIndex <= self.length
-			? aBlock._value_(self[anIndex - 1])
-			: anotherBlock._value()
-	;
-return self;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"at:ifPresent:ifAbsent:",{anIndex:anIndex,aBlock:aBlock,anotherBlock:anotherBlock},$globals.Array)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["anIndex", "aBlock", "anotherBlock"],
-source: "at: anIndex ifPresent: aBlock ifAbsent: anotherBlock\x0a\x09<inlineJS: '\x0a\x09\x09return anIndex >= 1 && anIndex <= self.length\x0a\x09\x09\x09? aBlock._value_(self[anIndex - 1])\x0a\x09\x09\x09: anotherBlock._value()\x0a\x09'>",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: []
-}),
-$globals.Array);
-
 $core.addMethod(
 $core.method({
 selector: "at:put:",
@@ -4876,30 +4820,6 @@ messageSends: []
 }),
 $globals.Array);
 
-$core.addMethod(
-$core.method({
-selector: "size",
-protocol: "accessing",
-fn: function (){
-var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-return self.length;
-return self;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"size",{},$globals.Array)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: [],
-source: "size\x0a\x09<inlineJS: 'return self.length'>",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: []
-}),
-$globals.Array);
-
 $core.addMethod(
 $core.method({
 selector: "sort",
@@ -6607,30 +6527,6 @@ messageSends: []
 }),
 $globals.String);
 
-$core.addMethod(
-$core.method({
-selector: "size",
-protocol: "accessing",
-fn: function (){
-var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-return self.length;
-return self;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"size",{},$globals.String)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: [],
-source: "size\x0a\x09<inlineJS: 'return self.length'>",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: []
-}),
-$globals.String);
-
 $core.addMethod(
 $core.method({
 selector: "subStrings:",
@@ -9908,6 +9804,62 @@ $globals.TKeyValueCollection);
 
 
 $core.addTrait("TNativeZeroBasedCollection", "Kernel-Collections");
+$core.addMethod(
+$core.method({
+selector: "at:ifAbsent:",
+protocol: "accessing",
+fn: function (anIndex,aBlock){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+
+		return anIndex >= 1 && anIndex <= self.length
+			? self[anIndex - 1]
+			: aBlock._value()
+	;
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"at:ifAbsent:",{anIndex:anIndex,aBlock:aBlock},$globals.TNativeZeroBasedCollection)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["anIndex", "aBlock"],
+source: "at: anIndex ifAbsent: aBlock\x0a\x09<inlineJS: '\x0a\x09\x09return anIndex >= 1 && anIndex <= self.length\x0a\x09\x09\x09? self[anIndex - 1]\x0a\x09\x09\x09: aBlock._value()\x0a\x09'>",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.TNativeZeroBasedCollection);
+
+$core.addMethod(
+$core.method({
+selector: "at:ifPresent:ifAbsent:",
+protocol: "accessing",
+fn: function (anIndex,aBlock,anotherBlock){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+
+		return anIndex >= 1 && anIndex <= self.length
+			? aBlock._value_(self[anIndex - 1])
+			: anotherBlock._value()
+	;
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"at:ifPresent:ifAbsent:",{anIndex:anIndex,aBlock:aBlock,anotherBlock:anotherBlock},$globals.TNativeZeroBasedCollection)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["anIndex", "aBlock", "anotherBlock"],
+source: "at: anIndex ifPresent: aBlock ifAbsent: anotherBlock\x0a\x09<inlineJS: '\x0a\x09\x09return anIndex >= 1 && anIndex <= self.length\x0a\x09\x09\x09? aBlock._value_(self[anIndex - 1])\x0a\x09\x09\x09: anotherBlock._value()\x0a\x09'>",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.TNativeZeroBasedCollection);
+
 $core.addMethod(
 $core.method({
 selector: "detect:ifNone:",
@@ -10050,6 +10002,30 @@ messageSends: []
 }),
 $globals.TNativeZeroBasedCollection);
 
+$core.addMethod(
+$core.method({
+selector: "size",
+protocol: "accessing",
+fn: function (){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return self.length;
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"size",{},$globals.TNativeZeroBasedCollection)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "size\x0a\x09<inlineJS: 'return self.length'>",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.TNativeZeroBasedCollection);
+
 $core.addMethod(
 $core.method({
 selector: "with:do:",

+ 20 - 24
lang/src/Kernel-Collections.st

@@ -1042,28 +1042,8 @@ I am directly mapped to JavaScript Number.
 
 !Array methodsFor: 'accessing'!
 
-at: anIndex ifAbsent: aBlock
-	<inlineJS: '
-		return anIndex >= 1 && anIndex <= self.length
-			? self[anIndex - 1]
-			: aBlock._value()
-	'>
-!
-
-at: anIndex ifPresent: aBlock ifAbsent: anotherBlock
-	<inlineJS: '
-		return anIndex >= 1 && anIndex <= self.length
-			? aBlock._value_(self[anIndex - 1])
-			: anotherBlock._value()
-	'>
-!
-
 at: anIndex put: anObject
 	<inlineJS: 'return self[anIndex - 1] = anObject'>
-!
-
-size
-	<inlineJS: 'return self.length'>
 ! !
 
 !Array methodsFor: 'adding/removing'!
@@ -1255,10 +1235,6 @@ at: anIndex put: anObject
 
 charCodeAt: anInteger
 	<inlineJS: 'return self.charCodeAt(anInteger - 1)'>
-!
-
-size
-	<inlineJS: 'return self.length'>
 ! !
 
 !String methodsFor: 'adding/removing'!
@@ -2343,6 +2319,22 @@ Trait named: #TNativeZeroBasedCollection
 
 !TNativeZeroBasedCollection methodsFor: 'accessing'!
 
+at: anIndex ifAbsent: aBlock
+	<inlineJS: '
+		return anIndex >= 1 && anIndex <= self.length
+			? self[anIndex - 1]
+			: aBlock._value()
+	'>
+!
+
+at: anIndex ifPresent: aBlock ifAbsent: anotherBlock
+	<inlineJS: '
+		return anIndex >= 1 && anIndex <= self.length
+			? aBlock._value_(self[anIndex - 1])
+			: anotherBlock._value()
+	'>
+!
+
 indexOf: anObject ifAbsent: aBlock
 	<inlineJS: '
 		for(var i=0; i < self.length; i++) {
@@ -2367,6 +2359,10 @@ single
 	if (self.length > 1) throw new Error("Collection holds more than one element.");
 	return self[0];
 '>
+!
+
+size
+	<inlineJS: 'return self.length'>
 ! !
 
 !TNativeZeroBasedCollection methodsFor: 'enumerating'!