1
0

Compiler-Exceptions.st 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. Smalltalk current createPackage: 'Compiler-Exceptions' properties: #{}!
  2. Error subclass: #CompilerError
  3. instanceVariableNames: ''
  4. package: 'Compiler-Exceptions'!
  5. CompilerError subclass: #ParseError
  6. instanceVariableNames: ''
  7. package: 'Compiler-Exceptions'!
  8. CompilerError subclass: #SemanticError
  9. instanceVariableNames: ''
  10. package: 'Compiler-Exceptions'!
  11. !SemanticError commentStamp!
  12. I represent an abstract semantic error thrown by the SemanticAnalyzer.
  13. Semantic errors can be unknown variable errors, etc.
  14. See my subclasses for concrete errors.
  15. The IDE should catch instances of Semantic error to deal with them when compiling!
  16. SemanticError subclass: #InliningError
  17. instanceVariableNames: 'variableName'
  18. package: 'Compiler-Exceptions'!
  19. SemanticError subclass: #InvalidAssignmentError
  20. instanceVariableNames: 'variableName'
  21. package: 'Compiler-Exceptions'!
  22. !InvalidAssignmentError commentStamp!
  23. I get signaled when a pseudo variable gets assigned.!
  24. !InvalidAssignmentError methodsFor: 'accessing'!
  25. messageText
  26. ^ ' Invalid assignment to variable: ', self variableName
  27. !
  28. variableName
  29. ^ variableName
  30. !
  31. variableName: aString
  32. variableName := aString
  33. ! !
  34. SemanticError subclass: #ShadowingVariableError
  35. instanceVariableNames: 'variableName'
  36. package: 'Compiler-Exceptions'!
  37. !ShadowingVariableError commentStamp!
  38. I get signaled when a variable in a block or method scope shadows a variable of the same name in an outer scope.!
  39. !ShadowingVariableError methodsFor: 'accessing'!
  40. messageText
  41. ^ 'Variable shadowing error: ', self variableName, ' is already defined'
  42. !
  43. variableName
  44. ^ variableName
  45. !
  46. variableName: aString
  47. variableName := aString
  48. ! !
  49. SemanticError subclass: #UnknownVariableError
  50. instanceVariableNames: 'variableName'
  51. package: 'Compiler-Exceptions'!
  52. !UnknownVariableError commentStamp!
  53. I get signaled when a variable is not defined.
  54. The default behavior is to allow it, as this is how Amber currently is able to seamlessly send messages to JavaScript objects.!
  55. !UnknownVariableError methodsFor: 'accessing'!
  56. variableName
  57. ^ variableName
  58. !
  59. variableName: aString
  60. variableName := aString
  61. ! !