Преглед на файлове

Use self#error instead of Error#signal

Kenneth Pullen преди 11 години
родител
ревизия
4a5adae949
променени са 3 файла, в които са добавени 7 реда и са изтрити 9 реда
  1. 2 3
      js/Kernel-Collections.deploy.js
  2. 4 5
      js/Kernel-Collections.js
  3. 1 1
      st/Kernel-Collections.st

+ 2 - 3
js/Kernel-Collections.deploy.js

@@ -1356,12 +1356,11 @@ selector: "newFromPairs:",
 fn: function (aCollection){
 var self=this;
 var newCollection;
-function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
 return smalltalk.withContext(function($ctx1) { 
 var $1,$2;
 $1=_st(_st(aCollection)._size())._even();
 if(! smalltalk.assert($1)){
-_st($Error())._signal_("#newFromPairs only accepts arrays of an even length");
+_st(self)._error_("#newFromPairs only accepts arrays of an even length");
 };
 newCollection=_st(self)._new();
 _st(_st((1))._to_by_(_st(aCollection)._size(),(2)))._do_((function(keyIndex){
@@ -1371,7 +1370,7 @@ return _st(newCollection)._at_put_(_st(aCollection)._at_(keyIndex),_st(aCollecti
 $2=newCollection;
 return $2;
 }, function($ctx1) {$ctx1.fill(self,"newFromPairs:",{aCollection:aCollection,newCollection:newCollection},smalltalk.HashedCollection.klass)})},
-messageSends: ["ifFalse:", "signal:", "even", "size", "new", "do:", "at:put:", "at:", "+", "to:by:"]}),
+messageSends: ["ifFalse:", "error:", "even", "size", "new", "do:", "at:put:", "at:", "+", "to:by:"]}),
 smalltalk.HashedCollection.klass);
 
 

+ 4 - 5
js/Kernel-Collections.js

@@ -1796,12 +1796,11 @@ category: 'instance creation',
 fn: function (aCollection){
 var self=this;
 var newCollection;
-function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
 return smalltalk.withContext(function($ctx1) { 
 var $1,$2;
 $1=_st(_st(aCollection)._size())._even();
 if(! smalltalk.assert($1)){
-_st($Error())._signal_("#newFromPairs only accepts arrays of an even length");
+_st(self)._error_("#newFromPairs only accepts arrays of an even length");
 };
 newCollection=_st(self)._new();
 _st(_st((1))._to_by_(_st(aCollection)._size(),(2)))._do_((function(keyIndex){
@@ -1812,9 +1811,9 @@ $2=newCollection;
 return $2;
 }, function($ctx1) {$ctx1.fill(self,"newFromPairs:",{aCollection:aCollection,newCollection:newCollection},smalltalk.HashedCollection.klass)})},
 args: ["aCollection"],
-source: "newFromPairs: aCollection\x0a\x22Accept an array of elements where every two elements form an association - the odd element being the key, and the even element the value.\x22\x0a| newCollection |\x0aaCollection size even ifFalse: [ Error signal: '#newFromPairs only accepts arrays of an even length' ].\x0anewCollection := self new.\x0a( 1 to: aCollection size by: 2 ) do: [ :keyIndex | newCollection at: ( aCollection at: keyIndex ) put: ( aCollection at: keyIndex + 1 ) ].\x0a^ newCollection.",
-messageSends: ["ifFalse:", "signal:", "even", "size", "new", "do:", "at:put:", "at:", "+", "to:by:"],
-referencedClasses: ["Error"]
+source: "newFromPairs: aCollection\x0a\x22Accept an array of elements where every two elements form an association - the odd element being the key, and the even element the value.\x22\x0a| newCollection |\x0aaCollection size even ifFalse: [ self error: '#newFromPairs only accepts arrays of an even length' ].\x0anewCollection := self new.\x0a( 1 to: aCollection size by: 2 ) do: [ :keyIndex | newCollection at: ( aCollection at: keyIndex ) put: ( aCollection at: keyIndex + 1 ) ].\x0a^ newCollection.",
+messageSends: ["ifFalse:", "error:", "even", "size", "new", "do:", "at:put:", "at:", "+", "to:by:"],
+referencedClasses: []
 }),
 smalltalk.HashedCollection.klass);
 

+ 1 - 1
st/Kernel-Collections.st

@@ -597,7 +597,7 @@ aCollection do: [:each | newCollection add: each].
 newFromPairs: aCollection
 "Accept an array of elements where every two elements form an association - the odd element being the key, and the even element the value."
 | newCollection |
-aCollection size even ifFalse: [ Error signal: '#newFromPairs only accepts arrays of an even length' ].
+aCollection size even ifFalse: [ self error: '#newFromPairs only accepts arrays of an even length' ].
 newCollection := self new.
 ( 1 to: aCollection size by: 2 ) do: [ :keyIndex | newCollection at: ( aCollection at: keyIndex ) put: ( aCollection at: keyIndex + 1 ) ].
 ^ newCollection.