Compiler-Exceptions.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. smalltalk.addPackage('Compiler-Exceptions', {});
  2. smalltalk.addClass('CompilerError', smalltalk.Error, [], 'Compiler-Exceptions');
  3. smalltalk.addClass('ParseError', smalltalk.CompilerError, [], 'Compiler-Exceptions');
  4. smalltalk.addClass('SemanticError', smalltalk.CompilerError, [], 'Compiler-Exceptions');
  5. 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"
  6. smalltalk.addClass('ShadowingVariableError', smalltalk.SemanticError, ['variableName'], 'Compiler-Exceptions');
  7. 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."
  8. smalltalk.addMethod(
  9. "_variableName",
  10. smalltalk.method({
  11. selector: "variableName",
  12. category: 'accessing',
  13. fn: function () {
  14. var self=this;
  15. return self['@variableName'];
  16. return self;},
  17. args: [],
  18. source: "variableName\x0a\x09^ variableName",
  19. messageSends: [],
  20. referencedClasses: []
  21. }),
  22. smalltalk.ShadowingVariableError);
  23. smalltalk.addMethod(
  24. "_variableName_",
  25. smalltalk.method({
  26. selector: "variableName:",
  27. category: 'accessing',
  28. fn: function (aString) {
  29. var self=this;
  30. (self['@variableName']=aString);
  31. return self;},
  32. args: ["aString"],
  33. source: "variableName: aString\x0a\x09variableName := aString",
  34. messageSends: [],
  35. referencedClasses: []
  36. }),
  37. smalltalk.ShadowingVariableError);
  38. smalltalk.addClass('UnknownVariableError', smalltalk.SemanticError, ['variableName'], 'Compiler-Exceptions');
  39. 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."
  40. smalltalk.addMethod(
  41. "_variableName",
  42. smalltalk.method({
  43. selector: "variableName",
  44. category: 'accessing',
  45. fn: function () {
  46. var self=this;
  47. return self['@variableName'];
  48. return self;},
  49. args: [],
  50. source: "variableName\x0a\x09^ variableName",
  51. messageSends: [],
  52. referencedClasses: []
  53. }),
  54. smalltalk.UnknownVariableError);
  55. smalltalk.addMethod(
  56. "_variableName_",
  57. smalltalk.method({
  58. selector: "variableName:",
  59. category: 'accessing',
  60. fn: function (aString) {
  61. var self=this;
  62. (self['@variableName']=aString);
  63. return self;},
  64. args: ["aString"],
  65. source: "variableName: aString\x0a\x09variableName := aString",
  66. messageSends: [],
  67. referencedClasses: []
  68. }),
  69. smalltalk.UnknownVariableError);