Ver Fonte

Reverts Smalltalk >> asJavaScriptException:

Nicolas Petton há 11 anos atrás
pai
commit
84c28ba80a
3 ficheiros alterados com 15 adições e 7 exclusões
  1. 6 2
      js/Kernel-Objects.deploy.js
  2. 8 4
      js/Kernel-Objects.js
  3. 1 1
      st/Kernel-Objects.st

+ 6 - 2
js/Kernel-Objects.deploy.js

@@ -3585,9 +3585,13 @@ selector: "asSmalltalkException:",
 fn: function (anObject){
 var self=this;
 function $JavaScriptException(){return smalltalk.JavaScriptException||(typeof JavaScriptException=="undefined"?nil:JavaScriptException)}
+function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
 return smalltalk.withContext(function($ctx1) { 
 var $2,$1;
-$2=_st(self)._isSmalltalkObject_(anObject);
+$2=_st(_st(self)._isSmalltalkObject_(anObject))._and_((function(){
+return smalltalk.withContext(function($ctx2) {
+return _st(anObject)._isKindOf_($Error());
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
 if(smalltalk.assert($2)){
 $1=anObject;
 } else {
@@ -3595,7 +3599,7 @@ $1=_st($JavaScriptException())._on_(anObject);
 };
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"asSmalltalkException:",{anObject:anObject},smalltalk.Smalltalk)})},
-messageSends: ["ifTrue:ifFalse:", "on:", "isSmalltalkObject:"]}),
+messageSends: ["ifTrue:ifFalse:", "on:", "and:", "isKindOf:", "isSmalltalkObject:"]}),
 smalltalk.Smalltalk);
 
 smalltalk.addMethod(

+ 8 - 4
js/Kernel-Objects.js

@@ -4890,9 +4890,13 @@ category: 'error handling',
 fn: function (anObject){
 var self=this;
 function $JavaScriptException(){return smalltalk.JavaScriptException||(typeof JavaScriptException=="undefined"?nil:JavaScriptException)}
+function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
 return smalltalk.withContext(function($ctx1) { 
 var $2,$1;
-$2=_st(self)._isSmalltalkObject_(anObject);
+$2=_st(_st(self)._isSmalltalkObject_(anObject))._and_((function(){
+return smalltalk.withContext(function($ctx2) {
+return _st(anObject)._isKindOf_($Error());
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
 if(smalltalk.assert($2)){
 $1=anObject;
 } else {
@@ -4901,9 +4905,9 @@ $1=_st($JavaScriptException())._on_(anObject);
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"asSmalltalkException:",{anObject:anObject},smalltalk.Smalltalk)})},
 args: ["anObject"],
-source: "asSmalltalkException: anObject\x0a\x09\x22A JavaScript exception may be thrown.\x0a\x09We then need to convert it back to a Smalltalk object\x22\x0a\x09\x0a\x09^ (self isSmalltalkObject: anObject)\x0a\x09\x09ifTrue: [ anObject ]\x0a\x09\x09ifFalse: [ JavaScriptException on: anObject ]",
-messageSends: ["ifTrue:ifFalse:", "on:", "isSmalltalkObject:"],
-referencedClasses: ["JavaScriptException"]
+source: "asSmalltalkException: anObject\x0a\x09\x22A JavaScript exception may be thrown.\x0a\x09We then need to convert it back to a Smalltalk object\x22\x0a\x09\x0a\x09^ ((self isSmalltalkObject: anObject) and: [ anObject isKindOf: Error ])\x0a\x09\x09ifTrue: [ anObject ]\x0a\x09\x09ifFalse: [ JavaScriptException on: anObject ]",
+messageSends: ["ifTrue:ifFalse:", "on:", "and:", "isKindOf:", "isSmalltalkObject:"],
+referencedClasses: ["JavaScriptException", "Error"]
 }),
 smalltalk.Smalltalk);
 

+ 1 - 1
st/Kernel-Objects.st

@@ -1799,7 +1799,7 @@ asSmalltalkException: anObject
 	"A JavaScript exception may be thrown.
 	We then need to convert it back to a Smalltalk object"
 	
-	^ (self isSmalltalkObject: anObject)
+	^ ((self isSmalltalkObject: anObject) and: [ anObject isKindOf: Error ])
 		ifTrue: [ anObject ]
 		ifFalse: [ JavaScriptException on: anObject ]
 !