Browse Source

allow nil in asEavModel, change reverseTrapAt: accordingly

Herbert Vojčík 11 years ago
parent
commit
2322b1e1d5
2 changed files with 21 additions and 17 deletions
  1. 18 14
      lib/js/Trapped-Backend.js
  2. 3 3
      lib/st/Trapped-Backend.st

+ 18 - 14
lib/js/Trapped-Backend.js

@@ -842,15 +842,19 @@ fn: function (anObject){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 var $1;
+if(($receiver = anObject) == nil || $receiver == null){
+$1=anObject;
+} else {
 $1=_st(anObject)._at_ifAbsent_(self,(function(){
 return smalltalk.withContext(function($ctx2) {
 return nil;
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
+};
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"reverseTrapAt:",{anObject:anObject},smalltalk.Number)})},
 args: ["anObject"],
-source: "reverseTrapAt: anObject\x0a\x09^anObject at: self ifAbsent: [nil]",
-messageSends: ["at:ifAbsent:"],
+source: "reverseTrapAt: anObject\x0a\x09^anObject ifNotNil: [ anObject at: self ifAbsent: [nil] ]",
+messageSends: ["ifNotNil:", "at:ifAbsent:"],
 referencedClasses: []
 }),
 smalltalk.Number);
@@ -888,12 +892,8 @@ _st(model)._getBlock_((function(anObject){
 return smalltalk.withContext(function($ctx2) {
 return self._inject_into_(anObject,(function(soFar,segment){
 return smalltalk.withContext(function($ctx3) {
-if(($receiver = soFar) == nil || $receiver == null){
-return soFar;
-} else {
 return _st(segment)._reverseTrapAt_(soFar);
 $ctx3.sendIdx["reverseTrapAt:"]=1;
-};
 }, function($ctx3) {$ctx3.fillBlock({soFar:soFar,segment:segment},$ctx2,2)})}));
 $ctx2.sendIdx["inject:into:"]=1;
 }, function($ctx2) {$ctx2.fillBlock({anObject:anObject},$ctx1,1)})}));
@@ -909,17 +909,17 @@ return soFar;
 } else {
 return _st(segment)._reverseTrapAt_(soFar);
 };
-}, function($ctx3) {$ctx3.fillBlock({soFar:soFar,segment:segment},$ctx2,6)})}));
+}, function($ctx3) {$ctx3.fillBlock({soFar:soFar,segment:segment},$ctx2,5)})}));
 penultimate;
 return _st(self._last())._reverseTrapAt_put_(penultimate,value);
-}, function($ctx2) {$ctx2.fillBlock({anObject:anObject,value:value,penultimate:penultimate},$ctx1,5)})}));
+}, function($ctx2) {$ctx2.fillBlock({anObject:anObject,value:value,penultimate:penultimate},$ctx1,4)})}));
 };
 $2=model;
 return $2;
 }, function($ctx1) {$ctx1.fill(self,"asEavModel",{model:model},smalltalk.SequenceableCollection)})},
 args: [],
-source: "asEavModel\x0a    | model |\x0a    model := EavModel new.\x0a    model getBlock: [ :anObject |\x0a        self inject: anObject into: [ :soFar :segment |\x0a            soFar ifNotNil: [ segment reverseTrapAt: soFar ]]].\x0a    self isEmpty ifFalse: [\x0a        model putBlock: [ :anObject :value | | penultimate |\x0a            penultimate :=  self allButLast inject: anObject into: [ :soFar :segment |\x0a                soFar ifNotNil: [ segment reverseTrapAt: soFar ]].\x0a            self last reverseTrapAt: penultimate put: value ]].\x0a    ^model",
-messageSends: ["new", "getBlock:", "inject:into:", "ifNotNil:", "reverseTrapAt:", "ifFalse:", "isEmpty", "putBlock:", "allButLast", "reverseTrapAt:put:", "last"],
+source: "asEavModel\x0a    | model |\x0a    model := EavModel new.\x0a    model getBlock: [ :anObject |\x0a        self inject: anObject into: [ :soFar :segment |\x0a            segment reverseTrapAt: soFar ]].\x0a    self isEmpty ifFalse: [\x0a        model putBlock: [ :anObject :value | | penultimate |\x0a            penultimate :=  self allButLast inject: anObject into: [ :soFar :segment |\x0a                soFar ifNotNil: [ segment reverseTrapAt: soFar ]].\x0a            self last reverseTrapAt: penultimate put: value ]].\x0a    ^model",
+messageSends: ["new", "getBlock:", "inject:into:", "reverseTrapAt:", "ifFalse:", "isEmpty", "putBlock:", "allButLast", "ifNotNil:", "reverseTrapAt:put:", "last"],
 referencedClasses: ["EavModel"]
 }),
 smalltalk.SequenceableCollection);
@@ -932,15 +932,19 @@ fn: function (anObject){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 var $1;
+if(($receiver = anObject) == nil || $receiver == null){
+$1=anObject;
+} else {
 $1=_st(anObject)._at_ifAbsent_(self,(function(){
 return smalltalk.withContext(function($ctx2) {
 return nil;
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
+};
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"reverseTrapAt:",{anObject:anObject},smalltalk.String)})},
 args: ["anObject"],
-source: "reverseTrapAt: anObject\x0a\x09^anObject at: self ifAbsent: [nil]",
-messageSends: ["at:ifAbsent:"],
+source: "reverseTrapAt: anObject\x0a\x09^anObject ifNotNil: [ anObject at: self ifAbsent: [nil] ]",
+messageSends: ["ifNotNil:", "at:ifAbsent:"],
 referencedClasses: []
 }),
 smalltalk.String);

+ 3 - 3
lib/st/Trapped-Backend.st

@@ -338,7 +338,7 @@ reverseTrapAt: anObject put: value
 !Number methodsFor: '*Trapped-Backend'!
 
 reverseTrapAt: anObject
-	^anObject at: self ifAbsent: [nil]
+	^anObject ifNotNil: [ anObject at: self ifAbsent: [nil] ]
 !
 
 reverseTrapAt: anObject put: value
@@ -352,7 +352,7 @@ asEavModel
     model := EavModel new.
     model getBlock: [ :anObject |
         self inject: anObject into: [ :soFar :segment |
-            soFar ifNotNil: [ segment reverseTrapAt: soFar ]]].
+            segment reverseTrapAt: soFar ]].
     self isEmpty ifFalse: [
         model putBlock: [ :anObject :value | | penultimate |
             penultimate :=  self allButLast inject: anObject into: [ :soFar :segment |
@@ -364,7 +364,7 @@ asEavModel
 !String methodsFor: '*Trapped-Backend'!
 
 reverseTrapAt: anObject
-	^anObject at: self ifAbsent: [nil]
+	^anObject ifNotNil: [ anObject at: self ifAbsent: [nil] ]
 !
 
 reverseTrapAt: anObject put: value