UNPKG

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