2
0

Compiler-Exceptions.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. smalltalk.addPackage('Compiler-Exceptions', {});
  2. smalltalk.addClass('CompilerError', smalltalk.Error, [], 'Compiler-Exceptions');
  3. smalltalk.CompilerError.comment="I am the common superclass of all compiling errors."
  4. smalltalk.addClass('ParseError', smalltalk.CompilerError, [], 'Compiler-Exceptions');
  5. smalltalk.ParseError.comment="Instance of ParseError are signaled on any parsing error. \x0aSee `Smalltalk >> #parse:`"
  6. smalltalk.addClass('SemanticError', smalltalk.CompilerError, [], 'Compiler-Exceptions');
  7. 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"
  8. smalltalk.addClass('InliningError', smalltalk.SemanticError, [], 'Compiler-Exceptions');
  9. smalltalk.InliningError.comment="Instances of InliningError are signaled when using an `InliningCodeGenerator`in a `Compiler`."
  10. smalltalk.addClass('InvalidAssignmentError', smalltalk.SemanticError, ['variableName'], 'Compiler-Exceptions');
  11. smalltalk.InvalidAssignmentError.comment="I get signaled when a pseudo variable gets assigned."
  12. smalltalk.addMethod(
  13. "_messageText",
  14. smalltalk.method({
  15. selector: "messageText",
  16. category: 'accessing',
  17. fn: function (){
  18. var self=this;
  19. return smalltalk.withContext(function($ctx1) { var $1;
  20. $1=_st(" Invalid assignment to variable: ").__comma(_st(self)._variableName());
  21. return $1;
  22. }, function($ctx1) {$ctx1.fill(self,"messageText",{}, smalltalk.InvalidAssignmentError)})},
  23. args: [],
  24. source: "messageText\x0a\x09^ ' Invalid assignment to variable: ', self variableName",
  25. messageSends: [",", "variableName"],
  26. referencedClasses: []
  27. }),
  28. smalltalk.InvalidAssignmentError);
  29. smalltalk.addMethod(
  30. "_variableName",
  31. smalltalk.method({
  32. selector: "variableName",
  33. category: 'accessing',
  34. fn: function (){
  35. var self=this;
  36. return smalltalk.withContext(function($ctx1) { var $1;
  37. $1=self["@variableName"];
  38. return $1;
  39. }, function($ctx1) {$ctx1.fill(self,"variableName",{}, smalltalk.InvalidAssignmentError)})},
  40. args: [],
  41. source: "variableName\x0a\x09^ variableName",
  42. messageSends: [],
  43. referencedClasses: []
  44. }),
  45. smalltalk.InvalidAssignmentError);
  46. smalltalk.addMethod(
  47. "_variableName_",
  48. smalltalk.method({
  49. selector: "variableName:",
  50. category: 'accessing',
  51. fn: function (aString){
  52. var self=this;
  53. return smalltalk.withContext(function($ctx1) { self["@variableName"]=aString;
  54. return self}, function($ctx1) {$ctx1.fill(self,"variableName:",{aString:aString}, smalltalk.InvalidAssignmentError)})},
  55. args: ["aString"],
  56. source: "variableName: aString\x0a\x09variableName := aString",
  57. messageSends: [],
  58. referencedClasses: []
  59. }),
  60. smalltalk.InvalidAssignmentError);
  61. smalltalk.addClass('ShadowingVariableError', smalltalk.SemanticError, ['variableName'], 'Compiler-Exceptions');
  62. 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."
  63. smalltalk.addMethod(
  64. "_messageText",
  65. smalltalk.method({
  66. selector: "messageText",
  67. category: 'accessing',
  68. fn: function (){
  69. var self=this;
  70. return smalltalk.withContext(function($ctx1) { var $1;
  71. $1=_st(_st("Variable shadowing error: ").__comma(_st(self)._variableName())).__comma(" is already defined");
  72. return $1;
  73. }, function($ctx1) {$ctx1.fill(self,"messageText",{}, smalltalk.ShadowingVariableError)})},
  74. args: [],
  75. source: "messageText\x0a\x09^ 'Variable shadowing error: ', self variableName, ' is already defined'",
  76. messageSends: [",", "variableName"],
  77. referencedClasses: []
  78. }),
  79. smalltalk.ShadowingVariableError);
  80. smalltalk.addMethod(
  81. "_variableName",
  82. smalltalk.method({
  83. selector: "variableName",
  84. category: 'accessing',
  85. fn: function (){
  86. var self=this;
  87. return smalltalk.withContext(function($ctx1) { var $1;
  88. $1=self["@variableName"];
  89. return $1;
  90. }, function($ctx1) {$ctx1.fill(self,"variableName",{}, smalltalk.ShadowingVariableError)})},
  91. args: [],
  92. source: "variableName\x0a\x09^ variableName",
  93. messageSends: [],
  94. referencedClasses: []
  95. }),
  96. smalltalk.ShadowingVariableError);
  97. smalltalk.addMethod(
  98. "_variableName_",
  99. smalltalk.method({
  100. selector: "variableName:",
  101. category: 'accessing',
  102. fn: function (aString){
  103. var self=this;
  104. return smalltalk.withContext(function($ctx1) { self["@variableName"]=aString;
  105. return self}, function($ctx1) {$ctx1.fill(self,"variableName:",{aString:aString}, smalltalk.ShadowingVariableError)})},
  106. args: ["aString"],
  107. source: "variableName: aString\x0a\x09variableName := aString",
  108. messageSends: [],
  109. referencedClasses: []
  110. }),
  111. smalltalk.ShadowingVariableError);
  112. smalltalk.addClass('UnknownVariableError', smalltalk.SemanticError, ['variableName'], 'Compiler-Exceptions');
  113. 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."
  114. smalltalk.addMethod(
  115. "_messageText",
  116. smalltalk.method({
  117. selector: "messageText",
  118. category: 'accessing',
  119. fn: function (){
  120. var self=this;
  121. return smalltalk.withContext(function($ctx1) { var $1;
  122. $1=_st(_st("Unknown Variable error: ").__comma(_st(self)._variableName())).__comma(" is not defined");
  123. return $1;
  124. }, function($ctx1) {$ctx1.fill(self,"messageText",{}, smalltalk.UnknownVariableError)})},
  125. args: [],
  126. source: "messageText\x0a\x09^ 'Unknown Variable error: ', self variableName, ' is not defined'",
  127. messageSends: [",", "variableName"],
  128. referencedClasses: []
  129. }),
  130. smalltalk.UnknownVariableError);
  131. smalltalk.addMethod(
  132. "_variableName",
  133. smalltalk.method({
  134. selector: "variableName",
  135. category: 'accessing',
  136. fn: function (){
  137. var self=this;
  138. return smalltalk.withContext(function($ctx1) { var $1;
  139. $1=self["@variableName"];
  140. return $1;
  141. }, function($ctx1) {$ctx1.fill(self,"variableName",{}, smalltalk.UnknownVariableError)})},
  142. args: [],
  143. source: "variableName\x0a\x09^ variableName",
  144. messageSends: [],
  145. referencedClasses: []
  146. }),
  147. smalltalk.UnknownVariableError);
  148. smalltalk.addMethod(
  149. "_variableName_",
  150. smalltalk.method({
  151. selector: "variableName:",
  152. category: 'accessing',
  153. fn: function (aString){
  154. var self=this;
  155. return smalltalk.withContext(function($ctx1) { self["@variableName"]=aString;
  156. return self}, function($ctx1) {$ctx1.fill(self,"variableName:",{aString:aString}, smalltalk.UnknownVariableError)})},
  157. args: ["aString"],
  158. source: "variableName: aString\x0a\x09variableName := aString",
  159. messageSends: [],
  160. referencedClasses: []
  161. }),
  162. smalltalk.UnknownVariableError);