Compiler-Exceptions.js 5.6 KB

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