1
0
Prechádzať zdrojové kódy

Add Exception >> pass and Exception >> outer.

Deprecate Exception >> resignal,
which should have been #pass from the start.
Herby Vojčík 6 rokov pred
rodič
commit
f87b0b227d

+ 5 - 0
API-CHANGES.txt

@@ -1,10 +1,15 @@
 0.22.0:
 
+* Deprecate Exception >> resignal. Should have been #pass.
+
 + Compiler >>
   + ast:forClass:protocol:
   + cleanCodeGenerator
   + codeGenerator
   + forClass:protocol:
++ Exception
+  + outer
+  + pass
 + JSObjectProxy >>
   + removeKey:
 + Number >>

+ 3 - 3
external/cli/src/AmberCli.js

@@ -2890,7 +2890,7 @@ return $core.withContext(function($ctx3) {
 //>>excludeEnd("ctx");
 $1=$recv(e)._isSmalltalkError();
 if($core.assert($1)){
-return $recv(e)._resignal();
+return $recv(e)._pass();
 } else {
 return $recv($recv(process)._stdout())._write_($recv(e)._jsStack());
 }
@@ -2909,10 +2909,10 @@ return result;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["buffer", "anObject"],
-source: "eval: buffer on: anObject\x0a\x09| result |\x0a\x09buffer ifNotEmpty: [\x0a\x09\x09[result := Compiler new evaluateExpression: buffer on: anObject]\x0a\x09\x09\x09tryCatch: [:e |\x0a\x09\x09\x09\x09e isSmalltalkError\x0a\x09\x09\x09\x09\x09ifTrue: [ e resignal ]\x0a\x09\x09\x09\x09\x09ifFalse: [ process stdout write: e jsStack ]]].\x0a\x09^ result",
+source: "eval: buffer on: anObject\x0a\x09| result |\x0a\x09buffer ifNotEmpty: [\x0a\x09\x09[result := Compiler new evaluateExpression: buffer on: anObject]\x0a\x09\x09\x09tryCatch: [:e |\x0a\x09\x09\x09\x09e isSmalltalkError\x0a\x09\x09\x09\x09\x09ifTrue: [ e pass ]\x0a\x09\x09\x09\x09\x09ifFalse: [ process stdout write: e jsStack ]]].\x0a\x09^ result",
 referencedClasses: ["Compiler"],
 //>>excludeEnd("ide");
-messageSends: ["ifNotEmpty:", "tryCatch:", "evaluateExpression:on:", "new", "ifTrue:ifFalse:", "isSmalltalkError", "resignal", "write:", "stdout", "jsStack"]
+messageSends: ["ifNotEmpty:", "tryCatch:", "evaluateExpression:on:", "new", "ifTrue:ifFalse:", "isSmalltalkError", "pass", "write:", "stdout", "jsStack"]
 }),
 $globals.Repl);
 

+ 1 - 1
external/cli/src/AmberCli.st

@@ -1140,7 +1140,7 @@ eval: buffer on: anObject
 		[result := Compiler new evaluateExpression: buffer on: anObject]
 			tryCatch: [:e |
 				e isSmalltalkError
-					ifTrue: [ e resignal ]
+					ifTrue: [ e pass ]
 					ifFalse: [ process stdout write: e jsStack ]]].
 	^ result
 !

+ 3 - 3
src/Kernel-Classes.js

@@ -1769,7 +1769,7 @@ $1=$self._basicRemoveClass_(newClass);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx2.sendIdx["basicRemoveClass:"]=1;
 //>>excludeEnd("ctx");
-return $recv(exception)._resignal();
+return $recv(exception)._pass();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx2) {$ctx2.fillBlock({exception:exception},$ctx1,2)});
 //>>excludeEnd("ctx");
@@ -1802,10 +1802,10 @@ return newClass;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["className", "aClass", "aCollection", "packageName"],
-source: "migrateClassNamed: className superclass: aClass instanceVariableNames: aCollection package: packageName\x0a\x09| oldClass newClass tmp |\x0a\x09\x0a\x09tmp := 'new*', className.\x0a\x09oldClass := Smalltalk globals at: className.\x0a\x09\x0a\x09newClass := self\x0a\x09\x09addSubclassOf: aClass\x0a\x09\x09named: tmp\x0a\x09\x09instanceVariableNames: aCollection\x0a\x09\x09package: packageName.\x0a\x0a\x09self basicSwapClassNames: oldClass with: newClass.\x0a\x0a\x09[ self copyClass: oldClass to: newClass ]\x0a\x09\x09on: Error\x0a\x09\x09do: [ :exception |\x0a\x09\x09\x09self\x0a\x09\x09\x09\x09basicSwapClassNames: oldClass with: newClass;\x0a\x09\x09\x09\x09basicRemoveClass: newClass.\x0a\x09\x09\x09\x09exception resignal ].\x0a\x0a\x09self\x0a\x09\x09rawRenameClass: oldClass to: tmp;\x0a\x09\x09rawRenameClass: newClass to: className.\x0a\x0a\x09oldClass subclasses \x0a\x09\x09do: [ :each | self migrateClass: each superclass: newClass ].\x0a\x0a\x09self basicRemoveClass: oldClass.\x0a\x09\x0a\x09SystemAnnouncer current announce: (ClassMigrated new\x0a\x09\x09theClass: newClass;\x0a\x09\x09oldClass: oldClass;\x0a\x09\x09yourself).\x0a\x09\x0a\x09^ newClass",
+source: "migrateClassNamed: className superclass: aClass instanceVariableNames: aCollection package: packageName\x0a\x09| oldClass newClass tmp |\x0a\x09\x0a\x09tmp := 'new*', className.\x0a\x09oldClass := Smalltalk globals at: className.\x0a\x09\x0a\x09newClass := self\x0a\x09\x09addSubclassOf: aClass\x0a\x09\x09named: tmp\x0a\x09\x09instanceVariableNames: aCollection\x0a\x09\x09package: packageName.\x0a\x0a\x09self basicSwapClassNames: oldClass with: newClass.\x0a\x0a\x09[ self copyClass: oldClass to: newClass ]\x0a\x09\x09on: Error\x0a\x09\x09do: [ :exception |\x0a\x09\x09\x09self\x0a\x09\x09\x09\x09basicSwapClassNames: oldClass with: newClass;\x0a\x09\x09\x09\x09basicRemoveClass: newClass.\x0a\x09\x09\x09\x09exception pass ].\x0a\x0a\x09self\x0a\x09\x09rawRenameClass: oldClass to: tmp;\x0a\x09\x09rawRenameClass: newClass to: className.\x0a\x0a\x09oldClass subclasses \x0a\x09\x09do: [ :each | self migrateClass: each superclass: newClass ].\x0a\x0a\x09self basicRemoveClass: oldClass.\x0a\x09\x0a\x09SystemAnnouncer current announce: (ClassMigrated new\x0a\x09\x09theClass: newClass;\x0a\x09\x09oldClass: oldClass;\x0a\x09\x09yourself).\x0a\x09\x0a\x09^ newClass",
 referencedClasses: ["Smalltalk", "Error", "SystemAnnouncer", "ClassMigrated"],
 //>>excludeEnd("ide");
-messageSends: [",", "at:", "globals", "addSubclassOf:named:instanceVariableNames:package:", "basicSwapClassNames:with:", "on:do:", "copyClass:to:", "basicRemoveClass:", "resignal", "rawRenameClass:to:", "do:", "subclasses", "migrateClass:superclass:", "announce:", "current", "theClass:", "new", "oldClass:", "yourself"]
+messageSends: [",", "at:", "globals", "addSubclassOf:named:instanceVariableNames:package:", "basicSwapClassNames:with:", "on:do:", "copyClass:to:", "basicRemoveClass:", "pass", "rawRenameClass:to:", "do:", "subclasses", "migrateClass:superclass:", "announce:", "current", "theClass:", "new", "oldClass:", "yourself"]
 }),
 $globals.ClassBuilder);
 

+ 1 - 1
src/Kernel-Classes.st

@@ -387,7 +387,7 @@ migrateClassNamed: className superclass: aClass instanceVariableNames: aCollecti
 			self
 				basicSwapClassNames: oldClass with: newClass;
 				basicRemoveClass: newClass.
-				exception resignal ].
+				exception pass ].
 
 	self
 		rawRenameClass: oldClass to: tmp;

+ 51 - 4
src/Kernel-Exceptions.js

@@ -192,7 +192,30 @@ $globals.Error);
 
 $core.addMethod(
 $core.method({
-selector: "resignal",
+selector: "outer",
+protocol: "signaling",
+fn: function (){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return $self._pass();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"outer",{},$globals.Error)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "outer\x0a\x09\x22Pharo compatibility. Just sends #pass.\x22\x0a\x09\x0a\x09^ self pass",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["pass"]
+}),
+$globals.Error);
+
+$core.addMethod(
+$core.method({
+selector: "pass",
 protocol: "signaling",
 fn: function (){
 var self=this,$self=this;
@@ -201,22 +224,46 @@ return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 
 		self.amberHandled = false;
-		throw(self);
+		throw self;
 	;
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"resignal",{},$globals.Error)});
+}, function($ctx1) {$ctx1.fill(self,"pass",{},$globals.Error)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "resignal\x0a\x09\x22Resignal the receiver without changing its exception context\x22\x0a\x09\x0a\x09<inlineJS: '\x0a\x09\x09self.amberHandled = false;\x0a\x09\x09throw(self);\x0a\x09'>",
+source: "pass\x0a\x09\x22Let outer handler take care of this.\x22\x0a\x09\x0a\x09<inlineJS: '\x0a\x09\x09self.amberHandled = false;\x0a\x09\x09throw self;\x0a\x09'>",
 referencedClasses: [],
 //>>excludeEnd("ide");
 messageSends: []
 }),
 $globals.Error);
 
+$core.addMethod(
+$core.method({
+selector: "resignal",
+protocol: "signaling",
+fn: function (){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+$self._deprecatedAPI_("Use #pass.");
+return $self._pass();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"resignal",{},$globals.Error)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "resignal\x0a\x09self deprecatedAPI: 'Use #pass.'.\x0a\x09^ self pass",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["deprecatedAPI:", "pass"]
+}),
+$globals.Error);
+
 $core.addMethod(
 $core.method({
 selector: "signal",

+ 14 - 3
src/Kernel-Exceptions.st

@@ -59,15 +59,26 @@ initialize
 
 !Error methodsFor: 'signaling'!
 
-resignal
-	"Resignal the receiver without changing its exception context"
+outer
+	"Pharo compatibility. Just sends #pass."
+	
+	^ self pass
+!
+
+pass
+	"Let outer handler take care of this."
 	
 	<inlineJS: '
 		self.amberHandled = false;
-		throw(self);
+		throw self;
 	'>
 !
 
+resignal
+	self deprecatedAPI: 'Use #pass.'.
+	^ self pass
+!
+
 signal
 	<inlineJS: '
 		self.amberHandled = false;

+ 3 - 3
src/Kernel-Infrastructure.js

@@ -3589,7 +3589,7 @@ $1=$recv(anException)._basicAt_("location");
 $ctx1.sendIdx["basicAt:"]=1;
 //>>excludeEnd("ctx");
 if(($receiver = $1) == null || $receiver.a$nil){
-return $recv(anException)._resignal();
+return $recv(anException)._pass();
 } else {
 var loc;
 loc=$receiver;
@@ -3626,10 +3626,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["anException", "aString"],
-source: "parseError: anException parsing: aString\x0a\x09(anException basicAt: 'location')\x0a\x09\x09ifNil: [ ^ anException resignal ]\x0a\x09\x09ifNotNil: [ :loc |\x0a\x09\x09\x09^ ParseError new \x0a\x09\x09\x09\x09messageText: \x0a\x09\x09\x09\x09\x09'Parse error on line ', loc start line ,\x0a\x09\x09\x09\x09\x09' column ' , loc start column ,\x0a\x09\x09\x09\x09\x09' : Unexpected character ', (anException basicAt: 'found');\x0a\x09\x09\x09\x09yourself ]",
+source: "parseError: anException parsing: aString\x0a\x09(anException basicAt: 'location')\x0a\x09\x09ifNil: [ ^ anException pass ]\x0a\x09\x09ifNotNil: [ :loc |\x0a\x09\x09\x09^ ParseError new \x0a\x09\x09\x09\x09messageText: \x0a\x09\x09\x09\x09\x09'Parse error on line ', loc start line ,\x0a\x09\x09\x09\x09\x09' column ' , loc start column ,\x0a\x09\x09\x09\x09\x09' : Unexpected character ', (anException basicAt: 'found');\x0a\x09\x09\x09\x09yourself ]",
 referencedClasses: ["ParseError"],
 //>>excludeEnd("ide");
-messageSends: ["ifNil:ifNotNil:", "basicAt:", "resignal", "messageText:", "new", ",", "line", "start", "column", "yourself"]
+messageSends: ["ifNil:ifNotNil:", "basicAt:", "pass", "messageText:", "new", ",", "line", "start", "column", "yourself"]
 }),
 $globals.SmalltalkImage);
 

+ 1 - 1
src/Kernel-Infrastructure.st

@@ -942,7 +942,7 @@ asSmalltalkException: anObject
 
 parseError: anException parsing: aString
 	(anException basicAt: 'location')
-		ifNil: [ ^ anException resignal ]
+		ifNil: [ ^ anException pass ]
 		ifNotNil: [ :loc |
 			^ ParseError new 
 				messageText: 

+ 3 - 3
src/Kernel-Methods.js

@@ -324,7 +324,7 @@ $1=$recv(smalltalkError)._isKindOf_(anErrorClass);
 if($core.assert($1)){
 return $recv(aBlock)._value_(smalltalkError);
 } else {
-return $recv(smalltalkError)._resignal();
+return $recv(smalltalkError)._pass();
 }
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx2) {$ctx2.fillBlock({error:error,smalltalkError:smalltalkError},$ctx1,1)});
@@ -336,10 +336,10 @@ return $recv(smalltalkError)._resignal();
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["anErrorClass", "aBlock"],
-source: "on: anErrorClass do: aBlock\x0a\x09\x22All exceptions thrown in the Smalltalk stack are cought.\x0a\x09Convert all JS exceptions to JavaScriptException instances.\x22\x0a\x09\x0a\x09^ self tryCatch: [ :error | | smalltalkError |\x0a\x09\x09smalltalkError := Smalltalk asSmalltalkException: error.\x0a\x09\x09(smalltalkError isKindOf: anErrorClass)\x0a\x09\x09ifTrue: [ aBlock value: smalltalkError ]\x0a\x09\x09ifFalse: [ smalltalkError resignal ] ]",
+source: "on: anErrorClass do: aBlock\x0a\x09\x22All exceptions thrown in the Smalltalk stack are cought.\x0a\x09Convert all JS exceptions to JavaScriptException instances.\x22\x0a\x09\x0a\x09^ self tryCatch: [ :error | | smalltalkError |\x0a\x09\x09smalltalkError := Smalltalk asSmalltalkException: error.\x0a\x09\x09(smalltalkError isKindOf: anErrorClass)\x0a\x09\x09ifTrue: [ aBlock value: smalltalkError ]\x0a\x09\x09ifFalse: [ smalltalkError pass ] ]",
 referencedClasses: ["Smalltalk"],
 //>>excludeEnd("ide");
-messageSends: ["tryCatch:", "asSmalltalkException:", "ifTrue:ifFalse:", "isKindOf:", "value:", "resignal"]
+messageSends: ["tryCatch:", "asSmalltalkException:", "ifTrue:ifFalse:", "isKindOf:", "value:", "pass"]
 }),
 $globals.BlockClosure);
 

+ 1 - 1
src/Kernel-Methods.st

@@ -89,7 +89,7 @@ on: anErrorClass do: aBlock
 		smalltalkError := Smalltalk asSmalltalkException: error.
 		(smalltalkError isKindOf: anErrorClass)
 		ifTrue: [ aBlock value: smalltalkError ]
-		ifFalse: [ smalltalkError resignal ] ]
+		ifFalse: [ smalltalkError pass ] ]
 !
 
 tryCatch: aBlock

+ 3 - 3
src/Platform-ImportExport.js

@@ -2765,7 +2765,7 @@ return $self["@lastSection"];
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
 $self["@lastChunk"]=$recv(parser)._last();
-return $recv(e)._resignal();
+return $recv(e)._pass();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx2) {$ctx2.fillBlock({e:e},$ctx1,7)});
 //>>excludeEnd("ctx");
@@ -2777,10 +2777,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aStream"],
-source: "import: aStream\x0a\x09| chunk result parser lastEmpty |\x0a\x09parser := ChunkParser on: aStream.\x0a\x09lastEmpty := false.\x0a\x09lastSection := 'n/a, not started'.\x0a\x09lastChunk := nil.\x0a\x09[\x0a\x09[ chunk := parser nextChunk.\x0a\x09chunk isNil ] whileFalse: [\x0a\x09\x09chunk\x0a\x09\x09\x09ifEmpty: [ lastEmpty := true ]\x0a\x09\x09\x09ifNotEmpty: [\x0a\x09\x09\x09\x09lastSection := chunk.\x0a\x09\x09\x09\x09result := Compiler new evaluateExpression: chunk.\x0a\x09\x09\x09\x09lastEmpty\x0a\x09\x09\x09\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09lastEmpty := false.\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09result scanFrom: parser ]] ].\x0a\x09lastSection := 'n/a, finished'\x0a\x09] on: Error do: [:e | lastChunk := parser last. e resignal ].",
+source: "import: aStream\x0a\x09| chunk result parser lastEmpty |\x0a\x09parser := ChunkParser on: aStream.\x0a\x09lastEmpty := false.\x0a\x09lastSection := 'n/a, not started'.\x0a\x09lastChunk := nil.\x0a\x09[\x0a\x09[ chunk := parser nextChunk.\x0a\x09chunk isNil ] whileFalse: [\x0a\x09\x09chunk\x0a\x09\x09\x09ifEmpty: [ lastEmpty := true ]\x0a\x09\x09\x09ifNotEmpty: [\x0a\x09\x09\x09\x09lastSection := chunk.\x0a\x09\x09\x09\x09result := Compiler new evaluateExpression: chunk.\x0a\x09\x09\x09\x09lastEmpty\x0a\x09\x09\x09\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09lastEmpty := false.\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09result scanFrom: parser ]] ].\x0a\x09lastSection := 'n/a, finished'\x0a\x09] on: Error do: [:e | lastChunk := parser last. e pass ].",
 referencedClasses: ["ChunkParser", "Compiler", "Error"],
 //>>excludeEnd("ide");
-messageSends: ["on:", "on:do:", "whileFalse:", "nextChunk", "isNil", "ifEmpty:ifNotEmpty:", "evaluateExpression:", "new", "ifTrue:", "scanFrom:", "last", "resignal"]
+messageSends: ["on:", "on:do:", "whileFalse:", "nextChunk", "isNil", "ifEmpty:ifNotEmpty:", "evaluateExpression:", "new", "ifTrue:", "scanFrom:", "last", "pass"]
 }),
 $globals.Importer);
 

+ 1 - 1
src/Platform-ImportExport.st

@@ -737,7 +737,7 @@ import: aStream
 									lastEmpty := false.
 									result scanFrom: parser ]] ].
 	lastSection := 'n/a, finished'
-	] on: Error do: [:e | lastChunk := parser last. e resignal ].
+	] on: Error do: [:e | lastChunk := parser last. e pass ].
 ! !
 
 Error subclass: #PackageCommitError

+ 3 - 3
src/Platform-Services.js

@@ -748,7 +748,7 @@ $1=$recv(exception)._isKindOf_($self._classNamed_($recv(anErrorClass)._name()));
 if($core.assert($1)){
 return $recv(exceptionBlock)._value_(exception);
 } else {
-return $recv(exception)._resignal();
+return $recv(exception)._pass();
 }
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx2) {$ctx2.fillBlock({exception:exception},$ctx1,1)});
@@ -761,10 +761,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aBlock", "anErrorClass", "exceptionBlock"],
-source: "evaluate: aBlock on: anErrorClass do: exceptionBlock\x0a\x09\x22Evaluate a block and catch exceptions happening on the environment stack\x22\x0a\x09\x0a\x09aBlock tryCatch: [ :exception | \x0a\x09\x09(exception isKindOf: (self classNamed: anErrorClass name))\x0a\x09\x09\x09ifTrue: [ exceptionBlock value: exception ]\x0a \x09\x09\x09ifFalse: [ exception resignal ] ]",
+source: "evaluate: aBlock on: anErrorClass do: exceptionBlock\x0a\x09\x22Evaluate a block and catch exceptions happening on the environment stack\x22\x0a\x09\x0a\x09aBlock tryCatch: [ :exception | \x0a\x09\x09(exception isKindOf: (self classNamed: anErrorClass name))\x0a\x09\x09\x09ifTrue: [ exceptionBlock value: exception ]\x0a \x09\x09\x09ifFalse: [ exception pass ] ]",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["tryCatch:", "ifTrue:ifFalse:", "isKindOf:", "classNamed:", "name", "value:", "resignal"]
+messageSends: ["tryCatch:", "ifTrue:ifFalse:", "isKindOf:", "classNamed:", "name", "value:", "pass"]
 }),
 $globals.Environment);
 

+ 1 - 1
src/Platform-Services.st

@@ -260,7 +260,7 @@ evaluate: aBlock on: anErrorClass do: exceptionBlock
 	aBlock tryCatch: [ :exception | 
 		(exception isKindOf: (self classNamed: anErrorClass name))
 			ifTrue: [ exceptionBlock value: exception ]
- 			ifFalse: [ exception resignal ] ]
+ 			ifFalse: [ exception pass ] ]
 ! !
 
 !Environment methodsFor: 'evaluating'!