Compiler-Exceptions.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. define("amber_core/Compiler-Exceptions", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Kernel-Exceptions"], function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Compiler-Exceptions');
  3. smalltalk.packages["Compiler-Exceptions"].transport = {"type":"amd","amdNamespace":"amber_core"};
  4. smalltalk.addClass('CompilerError', smalltalk.Error, [], 'Compiler-Exceptions');
  5. smalltalk.CompilerError.comment="I am the common superclass of all compiling errors.";
  6. smalltalk.addClass('ParseError', smalltalk.CompilerError, [], 'Compiler-Exceptions');
  7. smalltalk.ParseError.comment="Instance of ParseError are signaled on any parsing error.\x0aSee `Smalltalk >> #parse:`";
  8. smalltalk.addClass('SemanticError', smalltalk.CompilerError, [], 'Compiler-Exceptions');
  9. smalltalk.SemanticError.comment="I represent an abstract semantic error thrown by the SemanticAnalyzer.\x0aSemantic errors can be unknown variable errors, etc.\x0aSee my subclasses for concrete errors.\x0a\x0aThe IDE should catch instances of Semantic error to deal with them when compiling";
  10. smalltalk.addClass('InliningError', smalltalk.SemanticError, [], 'Compiler-Exceptions');
  11. smalltalk.InliningError.comment="Instances of InliningError are signaled when using an `InliningCodeGenerator`in a `Compiler`.";
  12. smalltalk.addClass('InvalidAssignmentError', smalltalk.SemanticError, ['variableName'], 'Compiler-Exceptions');
  13. smalltalk.InvalidAssignmentError.comment="I get signaled when a pseudo variable gets assigned.";
  14. smalltalk.addMethod(
  15. smalltalk.method({
  16. selector: "messageText",
  17. category: 'accessing',
  18. fn: function (){
  19. var self=this;
  20. return smalltalk.withContext(function($ctx1) {
  21. var $1;
  22. $1=" Invalid assignment to variable: ".__comma(self._variableName());
  23. return $1;
  24. }, function($ctx1) {$ctx1.fill(self,"messageText",{},smalltalk.InvalidAssignmentError)})},
  25. args: [],
  26. source: "messageText\x0a\x09^ ' Invalid assignment to variable: ', self variableName",
  27. messageSends: [",", "variableName"],
  28. referencedClasses: []
  29. }),
  30. smalltalk.InvalidAssignmentError);
  31. smalltalk.addMethod(
  32. smalltalk.method({
  33. selector: "variableName",
  34. category: 'accessing',
  35. fn: function (){
  36. var self=this;
  37. return smalltalk.withContext(function($ctx1) {
  38. var $1;
  39. $1=self["@variableName"];
  40. return $1;
  41. }, function($ctx1) {$ctx1.fill(self,"variableName",{},smalltalk.InvalidAssignmentError)})},
  42. args: [],
  43. source: "variableName\x0a\x09^ variableName",
  44. messageSends: [],
  45. referencedClasses: []
  46. }),
  47. smalltalk.InvalidAssignmentError);
  48. smalltalk.addMethod(
  49. smalltalk.method({
  50. selector: "variableName:",
  51. category: 'accessing',
  52. fn: function (aString){
  53. var self=this;
  54. return smalltalk.withContext(function($ctx1) {
  55. self["@variableName"]=aString;
  56. return self}, function($ctx1) {$ctx1.fill(self,"variableName:",{aString:aString},smalltalk.InvalidAssignmentError)})},
  57. args: ["aString"],
  58. source: "variableName: aString\x0a\x09variableName := aString",
  59. messageSends: [],
  60. referencedClasses: []
  61. }),
  62. smalltalk.InvalidAssignmentError);
  63. smalltalk.addClass('ShadowingVariableError', smalltalk.SemanticError, ['variableName'], 'Compiler-Exceptions');
  64. smalltalk.ShadowingVariableError.comment="I get signaled when a variable in a block or method scope shadows a variable of the same name in an outer scope.";
  65. smalltalk.addMethod(
  66. smalltalk.method({
  67. selector: "messageText",
  68. category: 'accessing',
  69. fn: function (){
  70. var self=this;
  71. return smalltalk.withContext(function($ctx1) {
  72. var $1;
  73. $1=_st("Variable shadowing error: ".__comma(self._variableName())).__comma(" is already defined");
  74. $ctx1.sendIdx[","]=1;
  75. return $1;
  76. }, function($ctx1) {$ctx1.fill(self,"messageText",{},smalltalk.ShadowingVariableError)})},
  77. args: [],
  78. source: "messageText\x0a\x09^ 'Variable shadowing error: ', self variableName, ' is already defined'",
  79. messageSends: [",", "variableName"],
  80. referencedClasses: []
  81. }),
  82. smalltalk.ShadowingVariableError);
  83. smalltalk.addMethod(
  84. smalltalk.method({
  85. selector: "variableName",
  86. category: 'accessing',
  87. fn: function (){
  88. var self=this;
  89. return smalltalk.withContext(function($ctx1) {
  90. var $1;
  91. $1=self["@variableName"];
  92. return $1;
  93. }, function($ctx1) {$ctx1.fill(self,"variableName",{},smalltalk.ShadowingVariableError)})},
  94. args: [],
  95. source: "variableName\x0a\x09^ variableName",
  96. messageSends: [],
  97. referencedClasses: []
  98. }),
  99. smalltalk.ShadowingVariableError);
  100. smalltalk.addMethod(
  101. smalltalk.method({
  102. selector: "variableName:",
  103. category: 'accessing',
  104. fn: function (aString){
  105. var self=this;
  106. return smalltalk.withContext(function($ctx1) {
  107. self["@variableName"]=aString;
  108. return self}, function($ctx1) {$ctx1.fill(self,"variableName:",{aString:aString},smalltalk.ShadowingVariableError)})},
  109. args: ["aString"],
  110. source: "variableName: aString\x0a\x09variableName := aString",
  111. messageSends: [],
  112. referencedClasses: []
  113. }),
  114. smalltalk.ShadowingVariableError);
  115. smalltalk.addClass('UnknownVariableError', smalltalk.SemanticError, ['variableName'], 'Compiler-Exceptions');
  116. smalltalk.UnknownVariableError.comment="I get signaled when a variable is not defined.\x0aThe default behavior is to allow it, as this is how Amber currently is able to seamlessly send messages to JavaScript objects.";
  117. smalltalk.addMethod(
  118. smalltalk.method({
  119. selector: "messageText",
  120. category: 'accessing',
  121. fn: function (){
  122. var self=this;
  123. return smalltalk.withContext(function($ctx1) {
  124. var $1;
  125. $1=_st("Unknown Variable error: ".__comma(self._variableName())).__comma(" is not defined");
  126. $ctx1.sendIdx[","]=1;
  127. return $1;
  128. }, function($ctx1) {$ctx1.fill(self,"messageText",{},smalltalk.UnknownVariableError)})},
  129. args: [],
  130. source: "messageText\x0a\x09^ 'Unknown Variable error: ', self variableName, ' is not defined'",
  131. messageSends: [",", "variableName"],
  132. referencedClasses: []
  133. }),
  134. smalltalk.UnknownVariableError);
  135. smalltalk.addMethod(
  136. smalltalk.method({
  137. selector: "variableName",
  138. category: 'accessing',
  139. fn: function (){
  140. var self=this;
  141. return smalltalk.withContext(function($ctx1) {
  142. var $1;
  143. $1=self["@variableName"];
  144. return $1;
  145. }, function($ctx1) {$ctx1.fill(self,"variableName",{},smalltalk.UnknownVariableError)})},
  146. args: [],
  147. source: "variableName\x0a\x09^ variableName",
  148. messageSends: [],
  149. referencedClasses: []
  150. }),
  151. smalltalk.UnknownVariableError);
  152. smalltalk.addMethod(
  153. smalltalk.method({
  154. selector: "variableName:",
  155. category: 'accessing',
  156. fn: function (aString){
  157. var self=this;
  158. return smalltalk.withContext(function($ctx1) {
  159. self["@variableName"]=aString;
  160. return self}, function($ctx1) {$ctx1.fill(self,"variableName:",{aString:aString},smalltalk.UnknownVariableError)})},
  161. args: ["aString"],
  162. source: "variableName: aString\x0a\x09variableName := aString",
  163. messageSends: [],
  164. referencedClasses: []
  165. }),
  166. smalltalk.UnknownVariableError);
  167. smalltalk.addClass('RethrowErrorHandler', smalltalk.ErrorHandler, [], 'Compiler-Exceptions');
  168. smalltalk.RethrowErrorHandler.comment="This class is used in the commandline version of the compiler.\x0aIt uses the handleError: message of ErrorHandler for printing the stacktrace and throws the error again as JS exception.\x0aAs a result Smalltalk errors are not swallowd by the Amber runtime and compilation can be aborted.";
  169. smalltalk.addMethod(
  170. smalltalk.method({
  171. selector: "basicSignal:",
  172. category: 'error handling',
  173. fn: function (anError){
  174. var self=this;
  175. return smalltalk.withContext(function($ctx1) {
  176. throw anError;
  177. return self}, function($ctx1) {$ctx1.fill(self,"basicSignal:",{anError:anError},smalltalk.RethrowErrorHandler)})},
  178. args: ["anError"],
  179. source: "basicSignal: anError\x0a\x09<throw anError>",
  180. messageSends: [],
  181. referencedClasses: []
  182. }),
  183. smalltalk.RethrowErrorHandler);
  184. smalltalk.addMethod(
  185. smalltalk.method({
  186. selector: "handleError:",
  187. category: 'error handling',
  188. fn: function (anError){
  189. var self=this;
  190. return smalltalk.withContext(function($ctx1) {
  191. smalltalk.RethrowErrorHandler.superclass.fn.prototype._handleError_.apply(_st(self), [anError]);
  192. self._basicSignal_(anError);
  193. return self}, function($ctx1) {$ctx1.fill(self,"handleError:",{anError:anError},smalltalk.RethrowErrorHandler)})},
  194. args: ["anError"],
  195. source: "handleError: anError\x0a\x09super handleError: anError.\x0a\x09self basicSignal: anError",
  196. messageSends: ["handleError:", "basicSignal:"],
  197. referencedClasses: []
  198. }),
  199. smalltalk.RethrowErrorHandler);
  200. });