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