Przeglądaj źródła

Use `CompilerError signal:` in compiler.

Instead of `self error:`.
Herby Vojčík 5 lat temu
rodzic
commit
c6b6a752a3

+ 8 - 8
src/Compiler-AST.js

@@ -2350,7 +2350,7 @@ $recv(aCollection)._ifNotEmpty_((function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
-return $self._error_("Block must have no pragmas.");
+return $recv($globals.CompilerError)._signal_("Block must have no pragmas.");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
 //>>excludeEnd("ctx");
@@ -2370,10 +2370,10 @@ return $1;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aCollection"],
-source: "pragmas: aCollection\x0a\x09aCollection ifNotEmpty: [\x0a\x09\x09self error: 'Block must have no pragmas.' ].\x0a\x09^ super pragmas: aCollection",
-referencedClasses: [],
+source: "pragmas: aCollection\x0a\x09aCollection ifNotEmpty: [\x0a\x09\x09CompilerError signal: 'Block must have no pragmas.' ].\x0a\x09^ super pragmas: aCollection",
+referencedClasses: ["CompilerError"],
 //>>excludeEnd("ide");
-messageSends: ["ifNotEmpty:", "error:", "pragmas:"]
+messageSends: ["ifNotEmpty:", "signal:", "pragmas:"]
 }),
 $globals.BlockSequenceNode);
 
@@ -3174,7 +3174,7 @@ $recv($1)._ifEmpty_((function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
-return $self._error_("Method source is empty");
+return $recv($globals.CompilerError)._signal_("Method source is empty");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
 //>>excludeEnd("ctx");
@@ -3186,10 +3186,10 @@ return $recv($recv($globals.Compiler)._new())._ast_forClass_protocol_($self._sou
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "ast\x0a\x09self source ifEmpty: [ self error: 'Method source is empty' ].\x0a\x09\x0a\x09^ Compiler new\x0a\x09\x09ast: self source\x0a\x09\x09forClass: self methodClass\x0a\x09\x09protocol: self protocol",
-referencedClasses: ["Compiler"],
+source: "ast\x0a\x09self source ifEmpty: [ CompilerError signal: 'Method source is empty' ].\x0a\x09\x0a\x09^ Compiler new\x0a\x09\x09ast: self source\x0a\x09\x09forClass: self methodClass\x0a\x09\x09protocol: self protocol",
+referencedClasses: ["CompilerError", "Compiler"],
 //>>excludeEnd("ide");
-messageSends: ["ifEmpty:", "source", "error:", "ast:forClass:protocol:", "new", "methodClass", "protocol"]
+messageSends: ["ifEmpty:", "source", "signal:", "ast:forClass:protocol:", "new", "methodClass", "protocol"]
 }),
 $globals.CompiledMethod);
 

+ 2 - 2
src/Compiler-AST.st

@@ -591,7 +591,7 @@ acceptDagVisitor: aVisitor
 
 pragmas: aCollection
 	aCollection ifNotEmpty: [
-		self error: 'Block must have no pragmas.' ].
+		CompilerError signal: 'Block must have no pragmas.' ].
 	^ super pragmas: aCollection
 ! !
 
@@ -781,7 +781,7 @@ visitVariableNode: aNode
 !CompiledMethod methodsFor: '*Compiler-AST'!
 
 ast
-	self source ifEmpty: [ self error: 'Method source is empty' ].
+	self source ifEmpty: [ CompilerError signal: 'Method source is empty' ].
 	
 	^ Compiler new
 		ast: self source

+ 4 - 4
src/Compiler-Core.js

@@ -416,7 +416,7 @@ throw $early=[x];
 
 }));
 $self._compileNode_($self._parse_(aString));
-$self._error_("AST transformation failed.");
+$recv($globals.CompilerError)._signal_("AST transformation failed.");
 return self;
 }
 catch(e) {if(e===$early)return e[0]; throw e}
@@ -426,10 +426,10 @@ catch(e) {if(e===$early)return e[0]; throw e}
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aString", "aClass", "anotherString"],
-source: "ast: aString forClass: aClass protocol: anotherString\x0a\x09self\x0a\x09\x09source: aString;\x0a\x09\x09forClass: aClass protocol: anotherString.\x0a\x0a\x09self codeGenerator transformersDictionary at: '2500-astCheckpoint' put: [ :x | ^x ].\x0a\x09\x0a\x09self compileNode: (self parse: aString).\x0a\x0a\x09self error: 'AST transformation failed.'",
-referencedClasses: [],
+source: "ast: aString forClass: aClass protocol: anotherString\x0a\x09self\x0a\x09\x09source: aString;\x0a\x09\x09forClass: aClass protocol: anotherString.\x0a\x0a\x09self codeGenerator transformersDictionary at: '2500-astCheckpoint' put: [ :x | ^x ].\x0a\x09\x0a\x09self compileNode: (self parse: aString).\x0a\x0a\x09CompilerError signal: 'AST transformation failed.'",
+referencedClasses: ["CompilerError"],
 //>>excludeEnd("ide");
-messageSends: ["source:", "forClass:protocol:", "at:put:", "transformersDictionary", "codeGenerator", "compileNode:", "parse:", "error:"]
+messageSends: ["source:", "forClass:protocol:", "at:put:", "transformersDictionary", "codeGenerator", "compileNode:", "parse:", "signal:"]
 }),
 $globals.Compiler);
 

+ 1 - 1
src/Compiler-Core.st

@@ -160,7 +160,7 @@ ast: aString forClass: aClass protocol: anotherString
 	
 	self compileNode: (self parse: aString).
 
-	self error: 'AST transformation failed.'
+	CompilerError signal: 'AST transformation failed.'
 !
 
 compile: aString forClass: aClass protocol: anotherString

+ 4 - 4
src/Compiler-Semantic.js

@@ -2859,7 +2859,7 @@ $recv($1)._ifNotEmpty_((function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
-return $self._error_("inlineJS: does not allow smalltalk statements");
+return $recv($globals.CompilerError)._signal_("inlineJS: does not allow smalltalk statements");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
 //>>excludeEnd("ctx");
@@ -2876,10 +2876,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aString"],
-source: "inlineJS: aString\x0a\x09self sequenceNode dagChildren ifNotEmpty: [\x0a\x09\x09self error: 'inlineJS: does not allow smalltalk statements' ].\x0a\x09self sequenceNode addDagChild: (\x0a\x09\x09JSStatementNode new\x0a\x09\x09\x09source: aString;\x0a\x09\x09\x09yourself)",
-referencedClasses: ["JSStatementNode"],
+source: "inlineJS: aString\x0a\x09self sequenceNode dagChildren ifNotEmpty: [\x0a\x09\x09CompilerError signal: 'inlineJS: does not allow smalltalk statements' ].\x0a\x09self sequenceNode addDagChild: (\x0a\x09\x09JSStatementNode new\x0a\x09\x09\x09source: aString;\x0a\x09\x09\x09yourself)",
+referencedClasses: ["CompilerError", "JSStatementNode"],
 //>>excludeEnd("ide");
-messageSends: ["ifNotEmpty:", "dagChildren", "sequenceNode", "error:", "addDagChild:", "source:", "new", "yourself"]
+messageSends: ["ifNotEmpty:", "dagChildren", "sequenceNode", "signal:", "addDagChild:", "source:", "new", "yourself"]
 }),
 $globals.EarlyPragmator);
 

+ 1 - 1
src/Compiler-Semantic.st

@@ -718,7 +718,7 @@ variableName: aString
 
 inlineJS: aString
 	self sequenceNode dagChildren ifNotEmpty: [
-		self error: 'inlineJS: does not allow smalltalk statements' ].
+		CompilerError signal: 'inlineJS: does not allow smalltalk statements' ].
 	self sequenceNode addDagChild: (
 		JSStatementNode new
 			source: aString;

+ 3 - 3
src/Compiler-Tests.js

@@ -1328,7 +1328,7 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-$self._should_receiver_raise_("foo ^ [ < fooBar > 4 ] value",$self["@receiver"],$globals.Error);
+$self._should_receiver_raise_("foo ^ [ < fooBar > 4 ] value",$self["@receiver"],$globals.CompilerError);
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"testPragmaInBlock",{},$globals.CodeGeneratorTest)});
@@ -1336,8 +1336,8 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testPragmaInBlock\x0a\x09self should: 'foo ^ [ < fooBar > 4 ] value' receiver: receiver raise: Error",
-referencedClasses: ["Error"],
+source: "testPragmaInBlock\x0a\x09self should: 'foo ^ [ < fooBar > 4 ] value' receiver: receiver raise: CompilerError",
+referencedClasses: ["CompilerError"],
 //>>excludeEnd("ide");
 messageSends: ["should:receiver:raise:"]
 }),

+ 1 - 1
src/Compiler-Tests.st

@@ -351,7 +351,7 @@ testPascalCaseGlobal
 !
 
 testPragmaInBlock
-	self should: 'foo ^ [ < fooBar > 4 ] value' receiver: receiver raise: Error
+	self should: 'foo ^ [ < fooBar > 4 ] value' receiver: receiver raise: CompilerError
 !
 
 testPragmaJSStatement