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 | import Variable from './variable';
|
26 |
|
27 | /**
|
28 | * @class Definition
|
29 | */
|
30 | export default class Definition {
|
31 | constructor(type, name, node, parent, index, kind) {
|
32 | /**
|
33 | * @member {String} Definition#type - type of the occurrence (e.g. "Parameter", "Variable", ...).
|
34 | */
|
35 | this.type = type;
|
36 | /**
|
37 | * @member {esprima.Identifier} Definition#name - the identifier AST node of the occurrence.
|
38 | */
|
39 | this.name = name;
|
40 | /**
|
41 | * @member {esprima.Node} Definition#node - the enclosing node of the identifier.
|
42 | */
|
43 | this.node = node;
|
44 | /**
|
45 | * @member {esprima.Node?} Definition#parent - the enclosing statement node of the identifier.
|
46 | */
|
47 | this.parent = parent;
|
48 | /**
|
49 | * @member {Number?} Definition#index - the index in the declaration statement.
|
50 | */
|
51 | this.index = index;
|
52 | /**
|
53 | * @member {String?} Definition#kind - the kind of the declaration statement.
|
54 | */
|
55 | this.kind = kind;
|
56 | }
|
57 | }
|
58 |
|
59 | /**
|
60 | * @class ParameterDefinition
|
61 | */
|
62 | class ParameterDefinition extends Definition {
|
63 | constructor(name, node, index, rest) {
|
64 | super(Variable.Parameter, name, node, null, index, null);
|
65 | /**
|
66 | * Whether the parameter definition is a part of a rest parameter.
|
67 | * @member {boolean} ParameterDefinition#rest
|
68 | */
|
69 | this.rest = rest;
|
70 | }
|
71 | }
|
72 |
|
73 | export {
|
74 | ParameterDefinition,
|
75 | Definition
|
76 | }
|
77 |
|
78 | /* vim: set sw=4 ts=4 et tw=80 : */
|