Symbols.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. var RTL$ = require("rtl.js");
  2. var JsString = require("js/JsString.js");
  3. var Object = require("js/Object.js");
  4. var ScopeBase = require("js/ScopeBase.js");
  5. var Types = require("js/Types.js");
  6. var Symbol = Object.Type.extend({
  7. init: function Symbol(){
  8. Object.Type.prototype.init.call(this);
  9. this.mId = null;
  10. this.mInfo = null;
  11. }
  12. });
  13. var FoundSymbol = RTL$.extend({
  14. init: function FoundSymbol(){
  15. this.mSymbol = null;
  16. this.mScope = null;
  17. }
  18. });
  19. Symbol.prototype.id = function(){
  20. return this.mId;
  21. }
  22. Symbol.prototype.info = function(){
  23. return this.mInfo;
  24. }
  25. Symbol.prototype.isModule = function(){
  26. return this.mInfo instanceof Types.Module;
  27. }
  28. Symbol.prototype.isVariable = function(){
  29. return this.mInfo instanceof Types.Variable;
  30. }
  31. Symbol.prototype.isConst = function(){
  32. return this.mInfo instanceof Types.Const;
  33. }
  34. Symbol.prototype.isType = function(){
  35. return this.mInfo instanceof Types.TypeId;
  36. }
  37. Symbol.prototype.isProcedure = function(){
  38. return this.mInfo instanceof Types.ProcedureId;
  39. }
  40. FoundSymbol.prototype.scope = function(){
  41. return this.mScope;
  42. }
  43. FoundSymbol.prototype.symbol = function(){
  44. return this.mSymbol;
  45. }
  46. function makeSymbol(id/*Type*/, info/*PId*/){
  47. var result = null;
  48. result = new Symbol();
  49. result.mId = id;
  50. result.mInfo = info;
  51. return result;
  52. }
  53. function makeFound(s/*PSymbol*/, scope/*PType*/){
  54. var result = null;
  55. result = new FoundSymbol();
  56. result.mSymbol = s;
  57. result.mScope = scope;
  58. return result;
  59. }
  60. exports.Symbol = Symbol;
  61. exports.FoundSymbol = FoundSymbol;
  62. exports.makeSymbol = makeSymbol;
  63. exports.makeFound = makeFound;