2
0

Compiler-Exceptions.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. var $1;
  20. $1=smalltalk.send(" Invalid assignment to variable: ","__comma",[smalltalk.send(self,"_variableName",[])]);
  21. return $1;
  22. },
  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 self["@variableName"];
  37. },
  38. args: [],
  39. source: "variableName\x0a\x09^ variableName",
  40. messageSends: [],
  41. referencedClasses: []
  42. }),
  43. smalltalk.InvalidAssignmentError);
  44. smalltalk.addMethod(
  45. "_variableName_",
  46. smalltalk.method({
  47. selector: "variableName:",
  48. category: 'accessing',
  49. fn: function (aString){
  50. var self=this;
  51. self["@variableName"]=aString;
  52. return self},
  53. args: ["aString"],
  54. source: "variableName: aString\x0a\x09variableName := aString",
  55. messageSends: [],
  56. referencedClasses: []
  57. }),
  58. smalltalk.InvalidAssignmentError);
  59. smalltalk.addClass('ShadowingVariableError', smalltalk.SemanticError, ['variableName'], 'Compiler-Exceptions');
  60. 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."
  61. smalltalk.addMethod(
  62. "_messageText",
  63. smalltalk.method({
  64. selector: "messageText",
  65. category: 'accessing',
  66. fn: function (){
  67. var self=this;
  68. var $1;
  69. $1=smalltalk.send(smalltalk.send("Variable shadowing error: ","__comma",[smalltalk.send(self,"_variableName",[])]),"__comma",[" is already defined"]);
  70. return $1;
  71. },
  72. args: [],
  73. source: "messageText\x0a\x09^ 'Variable shadowing error: ', self variableName, ' is already defined'",
  74. messageSends: [",", "variableName"],
  75. referencedClasses: []
  76. }),
  77. smalltalk.ShadowingVariableError);
  78. smalltalk.addMethod(
  79. "_variableName",
  80. smalltalk.method({
  81. selector: "variableName",
  82. category: 'accessing',
  83. fn: function (){
  84. var self=this;
  85. return self["@variableName"];
  86. },
  87. args: [],
  88. source: "variableName\x0a\x09^ variableName",
  89. messageSends: [],
  90. referencedClasses: []
  91. }),
  92. smalltalk.ShadowingVariableError);
  93. smalltalk.addMethod(
  94. "_variableName_",
  95. smalltalk.method({
  96. selector: "variableName:",
  97. category: 'accessing',
  98. fn: function (aString){
  99. var self=this;
  100. self["@variableName"]=aString;
  101. return self},
  102. args: ["aString"],
  103. source: "variableName: aString\x0a\x09variableName := aString",
  104. messageSends: [],
  105. referencedClasses: []
  106. }),
  107. smalltalk.ShadowingVariableError);
  108. smalltalk.addClass('UnknownVariableError', smalltalk.SemanticError, ['variableName'], 'Compiler-Exceptions');
  109. 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."
  110. smalltalk.addMethod(
  111. "_variableName",
  112. smalltalk.method({
  113. selector: "variableName",
  114. category: 'accessing',
  115. fn: function (){
  116. var self=this;
  117. return self["@variableName"];
  118. },
  119. args: [],
  120. source: "variableName\x0a\x09^ variableName",
  121. messageSends: [],
  122. referencedClasses: []
  123. }),
  124. smalltalk.UnknownVariableError);
  125. smalltalk.addMethod(
  126. "_variableName_",
  127. smalltalk.method({
  128. selector: "variableName:",
  129. category: 'accessing',
  130. fn: function (aString){
  131. var self=this;
  132. self["@variableName"]=aString;
  133. return self},
  134. args: ["aString"],
  135. source: "variableName: aString\x0a\x09variableName := aString",
  136. messageSends: [],
  137. referencedClasses: []
  138. }),
  139. smalltalk.UnknownVariableError);