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 |
|
25 | /**
|
26 | * A Variable represents a locally scoped identifier. These include arguments to
|
27 | * functions.
|
28 | * @class Variable
|
29 | */
|
30 | export default class Variable {
|
31 | constructor(name, scope) {
|
32 | /**
|
33 | * The variable name, as given in the source code.
|
34 | * @member {String} Variable#name
|
35 | */
|
36 | this.name = name;
|
37 | /**
|
38 | * List of defining occurrences of this variable (like in 'var ...'
|
39 | * statements or as parameter), as AST nodes.
|
40 | * @member {esprima.Identifier[]} Variable#identifiers
|
41 | */
|
42 | this.identifiers = [];
|
43 | /**
|
44 | * List of {@link Reference|references} of this variable (excluding parameter entries)
|
45 | * in its defining scope and all nested scopes. For defining
|
46 | * occurrences only see {@link Variable#defs}.
|
47 | * @member {Reference[]} Variable#references
|
48 | */
|
49 | this.references = [];
|
50 |
|
51 | /**
|
52 | * List of defining occurrences of this variable (like in 'var ...'
|
53 | * statements or as parameter), as custom objects.
|
54 | * @member {Definition[]} Variable#defs
|
55 | */
|
56 | this.defs = [];
|
57 |
|
58 | this.tainted = false;
|
59 | /**
|
60 | * Whether this is a stack variable.
|
61 | * @member {boolean} Variable#stack
|
62 | */
|
63 | this.stack = true;
|
64 | /**
|
65 | * Reference to the enclosing Scope.
|
66 | * @member {Scope} Variable#scope
|
67 | */
|
68 | this.scope = scope;
|
69 | }
|
70 | }
|
71 |
|
72 | Variable.CatchClause = 'CatchClause';
|
73 | Variable.Parameter = 'Parameter';
|
74 | Variable.FunctionName = 'FunctionName';
|
75 | Variable.ClassName = 'ClassName';
|
76 | Variable.Variable = 'Variable';
|
77 | Variable.ImportBinding = 'ImportBinding';
|
78 | Variable.TDZ = 'TDZ';
|
79 | Variable.ImplicitGlobalVariable = 'ImplicitGlobalVariable';
|
80 |
|
81 | /* vim: set sw=4 ts=4 et tw=80 : */
|