variable.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions are met:
  5. * Redistributions of source code must retain the above copyright
  6. notice, this list of conditions and the following disclaimer.
  7. * Redistributions in binary form must reproduce the above copyright
  8. notice, this list of conditions and the following disclaimer in the
  9. documentation and/or other materials provided with the distribution.
  10. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  11. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  13. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  14. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  15. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  16. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  17. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  18. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  19. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20. */
  21. "use strict";
  22. /**
  23. * A Variable represents a locally scoped identifier. These include arguments to
  24. * functions.
  25. * @class Variable
  26. */
  27. class Variable {
  28. constructor(name, scope) {
  29. /**
  30. * The variable name, as given in the source code.
  31. * @member {String} Variable#name
  32. */
  33. this.name = name;
  34. /**
  35. * List of defining occurrences of this variable (like in 'var ...'
  36. * statements or as parameter), as AST nodes.
  37. * @member {espree.Identifier[]} Variable#identifiers
  38. */
  39. this.identifiers = [];
  40. /**
  41. * List of {@link Reference|references} of this variable (excluding parameter entries)
  42. * in its defining scope and all nested scopes. For defining
  43. * occurrences only see {@link Variable#defs}.
  44. * @member {Reference[]} Variable#references
  45. */
  46. this.references = [];
  47. /**
  48. * List of defining occurrences of this variable (like in 'var ...'
  49. * statements or as parameter), as custom objects.
  50. * @member {Definition[]} Variable#defs
  51. */
  52. this.defs = [];
  53. this.tainted = false;
  54. /**
  55. * Whether this is a stack variable.
  56. * @member {boolean} Variable#stack
  57. */
  58. this.stack = true;
  59. /**
  60. * Reference to the enclosing Scope.
  61. * @member {Scope} Variable#scope
  62. */
  63. this.scope = scope;
  64. }
  65. }
  66. Variable.CatchClause = "CatchClause";
  67. Variable.Parameter = "Parameter";
  68. Variable.FunctionName = "FunctionName";
  69. Variable.ClassName = "ClassName";
  70. Variable.Variable = "Variable";
  71. Variable.ImportBinding = "ImportBinding";
  72. Variable.ImplicitGlobalVariable = "ImplicitGlobalVariable";
  73. module.exports = Variable;
  74. /* vim: set sw=4 ts=4 et tw=80 : */