static-injector 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/import/commonjs/index.js +1248 -0
  2. package/import/es2015/decorator/injectable.js +14 -0
  3. package/import/es2015/decorator/interface/provider.js +8 -0
  4. package/import/es2015/di/forward_ref.js +53 -0
  5. package/import/es2015/di/inject_switch.js +31 -0
  6. package/import/es2015/di/injection_token.js +71 -0
  7. package/import/es2015/di/injector.js +63 -0
  8. package/import/es2015/di/injector_compatibility.js +172 -0
  9. package/import/es2015/di/injector_marker.js +8 -0
  10. package/import/es2015/di/injector_token.js +21 -0
  11. package/import/es2015/di/interface/defs.js +72 -0
  12. package/import/es2015/di/interface/injector.js +25 -0
  13. package/import/es2015/di/interface/provider.js +8 -0
  14. package/import/es2015/di/metadata.js +49 -0
  15. package/import/es2015/di/null_injector.js +19 -0
  16. package/import/es2015/di/provider_token.js +8 -0
  17. package/import/es2015/di/r3_injector.js +382 -0
  18. package/import/es2015/di/scope.js +14 -0
  19. package/import/es2015/index.js +11 -0
  20. package/import/es2015/interface/lifecycle_hooks.js +8 -0
  21. package/import/es2015/interface/type.js +8 -0
  22. package/import/es2015/render3/definition_factory.js +15 -0
  23. package/import/es2015/render3/error_code.js +29 -0
  24. package/import/es2015/render3/errors_di.js +14 -0
  25. package/import/es2015/render3/fields.js +11 -0
  26. package/import/es2015/render3/instructions/di.js +23 -0
  27. package/import/es2015/render3/util/stringify_utils.js +37 -0
  28. package/import/es2015/util/array_utils.js +17 -0
  29. package/import/es2015/util/closure.js +19 -0
  30. package/import/es2015/util/decorators.js +30 -0
  31. package/import/es2015/util/empty.js +14 -0
  32. package/import/es2015/util/property.js +15 -0
  33. package/import/es2015/util/stringify.js +30 -0
  34. package/import/fesm2015/index.js +1211 -0
  35. package/import/typings/decorator/injectable.d.ts +82 -0
  36. package/import/typings/decorator/interface/provider.d.ts +312 -0
  37. package/import/typings/di/forward_ref.d.ts +49 -0
  38. package/import/typings/di/inject_switch.d.ts +17 -0
  39. package/import/typings/di/injection_token.d.ts +57 -0
  40. package/import/typings/di/injector.d.ts +76 -0
  41. package/import/typings/di/injector_compatibility.d.ts +77 -0
  42. package/import/typings/di/injector_marker.d.ts +23 -0
  43. package/import/typings/di/injector_token.d.ts +18 -0
  44. package/import/typings/di/interface/defs.d.ts +155 -0
  45. package/import/typings/di/interface/injector.d.ts +48 -0
  46. package/import/typings/di/interface/provider.d.ts +312 -0
  47. package/import/typings/di/metadata.d.ts +176 -0
  48. package/import/typings/di/null_injector.d.ts +11 -0
  49. package/import/typings/di/provider_token.d.ts +17 -0
  50. package/import/typings/di/r3_injector.d.ts +92 -0
  51. package/import/typings/di/scope.d.ts +14 -0
  52. package/import/typings/index.d.ts +11 -0
  53. package/import/typings/interface/lifecycle_hooks.d.ts +28 -0
  54. package/import/typings/interface/type.d.ts +21 -0
  55. package/import/typings/render3/definition_factory.d.ts +24 -0
  56. package/import/typings/render3/error_code.d.ts +24 -0
  57. package/import/typings/render3/errors_di.d.ts +2 -0
  58. package/import/typings/render3/fields.d.ts +8 -0
  59. package/import/typings/render3/instructions/di.d.ts +20 -0
  60. package/import/typings/render3/util/stringify_utils.d.ts +20 -0
  61. package/import/typings/util/array_utils.d.ts +10 -0
  62. package/import/typings/util/closure.d.ts +17 -0
  63. package/import/typings/util/decorators.d.ts +27 -0
  64. package/import/typings/util/empty.d.ts +14 -0
  65. package/import/typings/util/property.d.ts +8 -0
  66. package/import/typings/util/stringify.d.ts +8 -0
  67. package/package.json +34 -0
  68. package/readme.md +27 -0
  69. package/transform/compiler/index.d.ts +5 -0
  70. package/transform/compiler/index.js +17 -0
  71. package/transform/compiler/src/core.d.ts +19 -0
  72. package/transform/compiler/src/core.js +9 -0
  73. package/transform/compiler/src/injectable_compiler_2.d.ts +53 -0
  74. package/transform/compiler/src/injectable_compiler_2.js +159 -0
  75. package/transform/compiler/src/output/output_ast.d.ts +534 -0
  76. package/transform/compiler/src/output/output_ast.js +986 -0
  77. package/transform/compiler/src/parse_util.d.ts +50 -0
  78. package/transform/compiler/src/parse_util.js +61 -0
  79. package/transform/compiler/src/render3/partial/api.d.ts +166 -0
  80. package/transform/compiler/src/render3/partial/api.js +11 -0
  81. package/transform/compiler/src/render3/partial/util.d.ts +16 -0
  82. package/transform/compiler/src/render3/partial/util.js +44 -0
  83. package/transform/compiler/src/render3/r3_factory.d.ts +97 -0
  84. package/transform/compiler/src/render3/r3_factory.js +239 -0
  85. package/transform/compiler/src/render3/r3_identifiers.d.ts +20 -0
  86. package/transform/compiler/src/render3/r3_identifiers.js +51 -0
  87. package/transform/compiler/src/render3/util.d.ts +21 -0
  88. package/transform/compiler/src/render3/util.js +41 -0
  89. package/transform/compiler/src/render3/view/util.d.ts +30 -0
  90. package/transform/compiler/src/render3/view/util.js +57 -0
  91. package/transform/compiler-cli/src/ngtsc/annotations/src/factory.d.ts +11 -0
  92. package/transform/compiler-cli/src/ngtsc/annotations/src/factory.js +21 -0
  93. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.d.ts +42 -0
  94. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +278 -0
  95. package/transform/compiler-cli/src/ngtsc/annotations/src/util.d.ts +91 -0
  96. package/transform/compiler-cli/src/ngtsc/annotations/src/util.js +370 -0
  97. package/transform/compiler-cli/src/ngtsc/diagnostics/error.d.ts +24 -0
  98. package/transform/compiler-cli/src/ngtsc/diagnostics/error.js +76 -0
  99. package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.d.ts +188 -0
  100. package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.js +206 -0
  101. package/transform/compiler-cli/src/ngtsc/diagnostics/index.d.ts +2 -0
  102. package/transform/compiler-cli/src/ngtsc/diagnostics/index.js +14 -0
  103. package/transform/compiler-cli/src/ngtsc/imports/index.d.ts +1 -0
  104. package/transform/compiler-cli/src/ngtsc/imports/index.js +13 -0
  105. package/transform/compiler-cli/src/ngtsc/imports/src/core.d.ts +36 -0
  106. package/transform/compiler-cli/src/ngtsc/imports/src/core.js +25 -0
  107. package/transform/compiler-cli/src/ngtsc/reflection/index.d.ts +3 -0
  108. package/transform/compiler-cli/src/ngtsc/reflection/index.js +15 -0
  109. package/transform/compiler-cli/src/ngtsc/reflection/src/host.d.ts +667 -0
  110. package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +98 -0
  111. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.d.ts +24 -0
  112. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.js +271 -0
  113. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.d.ts +50 -0
  114. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +396 -0
  115. package/transform/compiler-cli/src/ngtsc/reflection/src/util.d.ts +12 -0
  116. package/transform/compiler-cli/src/ngtsc/reflection/src/util.js +45 -0
  117. package/transform/compiler-cli/src/ngtsc/transform/index.d.ts +2 -0
  118. package/transform/compiler-cli/src/ngtsc/transform/index.js +14 -0
  119. package/transform/compiler-cli/src/ngtsc/transform/src/api.d.ts +115 -0
  120. package/transform/compiler-cli/src/ngtsc/transform/src/api.js +30 -0
  121. package/transform/compiler-cli/src/ngtsc/transform/src/utils.d.ts +15 -0
  122. package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +84 -0
  123. package/transform/compiler-cli/src/ngtsc/translator/index.d.ts +5 -0
  124. package/transform/compiler-cli/src/ngtsc/translator/index.js +17 -0
  125. package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.d.ts +274 -0
  126. package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.js +9 -0
  127. package/transform/compiler-cli/src/ngtsc/translator/src/api/import_generator.d.ts +27 -0
  128. package/transform/compiler-cli/src/ngtsc/translator/src/api/import_generator.js +9 -0
  129. package/transform/compiler-cli/src/ngtsc/translator/src/context.d.ts +18 -0
  130. package/transform/compiler-cli/src/ngtsc/translator/src/context.js +27 -0
  131. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.d.ts +29 -0
  132. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +70 -0
  133. package/transform/compiler-cli/src/ngtsc/translator/src/translator.d.ts +58 -0
  134. package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +270 -0
  135. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.d.ts +54 -0
  136. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +245 -0
  137. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.d.ts +13 -0
  138. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.js +21 -0
  139. package/transform/compiler-cli/src/ngtsc/util/src/typescript.d.ts +11 -0
  140. package/transform/compiler-cli/src/ngtsc/util/src/typescript.js +39 -0
  141. package/transform/index.d.ts +1 -0
  142. package/transform/index.js +13 -0
  143. package/transform/injectable-transform.d.ts +41 -0
  144. package/transform/injectable-transform.js +195 -0
  145. package/transform/node-Iteration.d.ts +2 -0
  146. package/transform/node-Iteration.js +12 -0
@@ -0,0 +1,986 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.io/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.LiteralArrayExpr = exports.ReadKeyExpr = exports.ReadPropExpr = exports.BinaryOperatorExpr = exports.UnaryOperatorExpr = exports.FunctionExpr = exports.FnParam = exports.CastExpr = exports.AssertNotNull = exports.NotExpr = exports.ConditionalExpr = exports.ExternalReference = exports.ExternalExpr = exports.PlaceholderPiece = exports.LiteralPiece = exports.MessagePiece = exports.TemplateLiteralElement = exports.TemplateLiteral = exports.LiteralExpr = exports.InstantiateExpr = exports.InvokeFunctionExpr = exports.InvokeMethodExpr = exports.BuiltinMethod = exports.WritePropExpr = exports.WriteKeyExpr = exports.WriteVarExpr = exports.WrappedNodeExpr = exports.TypeofExpr = exports.ReadVarExpr = exports.BuiltinVar = exports.Expression = exports.areAllEquivalent = exports.nullSafeIsEquivalent = exports.BinaryOperator = exports.UnaryOperator = exports.NONE_TYPE = exports.FUNCTION_TYPE = exports.STRING_TYPE = exports.NUMBER_TYPE = exports.INT_TYPE = exports.BOOL_TYPE = exports.INFERRED_TYPE = exports.DYNAMIC_TYPE = exports.MapType = exports.ArrayType = exports.ExpressionType = exports.BuiltinType = exports.BuiltinTypeName = exports.Type = exports.TypeModifier = void 0;
11
+ exports.isNull = exports.literal = exports.ifStmt = exports.fn = exports.assertNotNull = exports.not = exports.unary = exports.literalMap = exports.literalArr = exports.typeofExpr = exports.expressionType = exports.importExpr = exports.variable = exports.IfStmt = exports.ClassStmt = exports.ClassGetter = exports.ClassMethod = exports.ClassField = exports.AbstractClassPart = exports.ReturnStatement = exports.ExpressionStatement = exports.DeclareFunctionStmt = exports.DeclareVarStmt = exports.Statement = exports.JSDocComment = exports.LeadingComment = exports.StmtModifier = exports.TYPED_NULL_EXPR = exports.NULL_EXPR = exports.CATCH_STACK_VAR = exports.CATCH_ERROR_VAR = exports.SUPER_EXPR = exports.THIS_EXPR = exports.CommaExpr = exports.LiteralMapExpr = exports.LiteralMapEntry = void 0;
12
+ //// Types
13
+ var TypeModifier;
14
+ (function (TypeModifier) {
15
+ TypeModifier[TypeModifier["Const"] = 0] = "Const";
16
+ })(TypeModifier = exports.TypeModifier || (exports.TypeModifier = {}));
17
+ class Type {
18
+ constructor(modifiers = []) {
19
+ this.modifiers = modifiers;
20
+ }
21
+ hasModifier(modifier) {
22
+ return this.modifiers.indexOf(modifier) !== -1;
23
+ }
24
+ }
25
+ exports.Type = Type;
26
+ var BuiltinTypeName;
27
+ (function (BuiltinTypeName) {
28
+ BuiltinTypeName[BuiltinTypeName["Dynamic"] = 0] = "Dynamic";
29
+ BuiltinTypeName[BuiltinTypeName["Bool"] = 1] = "Bool";
30
+ BuiltinTypeName[BuiltinTypeName["String"] = 2] = "String";
31
+ BuiltinTypeName[BuiltinTypeName["Int"] = 3] = "Int";
32
+ BuiltinTypeName[BuiltinTypeName["Number"] = 4] = "Number";
33
+ BuiltinTypeName[BuiltinTypeName["Function"] = 5] = "Function";
34
+ BuiltinTypeName[BuiltinTypeName["Inferred"] = 6] = "Inferred";
35
+ BuiltinTypeName[BuiltinTypeName["None"] = 7] = "None";
36
+ })(BuiltinTypeName = exports.BuiltinTypeName || (exports.BuiltinTypeName = {}));
37
+ class BuiltinType extends Type {
38
+ constructor(name, modifiers) {
39
+ super(modifiers);
40
+ this.name = name;
41
+ }
42
+ visitType(visitor, context) {
43
+ return visitor.visitBuiltinType(this, context);
44
+ }
45
+ }
46
+ exports.BuiltinType = BuiltinType;
47
+ class ExpressionType extends Type {
48
+ constructor(value, modifiers, typeParams = null) {
49
+ super(modifiers);
50
+ this.value = value;
51
+ this.typeParams = typeParams;
52
+ }
53
+ visitType(visitor, context) {
54
+ return visitor.visitExpressionType(this, context);
55
+ }
56
+ }
57
+ exports.ExpressionType = ExpressionType;
58
+ class ArrayType extends Type {
59
+ constructor(of, modifiers) {
60
+ super(modifiers);
61
+ this.of = of;
62
+ }
63
+ visitType(visitor, context) {
64
+ return visitor.visitArrayType(this, context);
65
+ }
66
+ }
67
+ exports.ArrayType = ArrayType;
68
+ class MapType extends Type {
69
+ constructor(valueType, modifiers) {
70
+ super(modifiers);
71
+ this.valueType = valueType || null;
72
+ }
73
+ visitType(visitor, context) {
74
+ return visitor.visitMapType(this, context);
75
+ }
76
+ }
77
+ exports.MapType = MapType;
78
+ exports.DYNAMIC_TYPE = new BuiltinType(BuiltinTypeName.Dynamic);
79
+ exports.INFERRED_TYPE = new BuiltinType(BuiltinTypeName.Inferred);
80
+ exports.BOOL_TYPE = new BuiltinType(BuiltinTypeName.Bool);
81
+ exports.INT_TYPE = new BuiltinType(BuiltinTypeName.Int);
82
+ exports.NUMBER_TYPE = new BuiltinType(BuiltinTypeName.Number);
83
+ exports.STRING_TYPE = new BuiltinType(BuiltinTypeName.String);
84
+ exports.FUNCTION_TYPE = new BuiltinType(BuiltinTypeName.Function);
85
+ exports.NONE_TYPE = new BuiltinType(BuiltinTypeName.None);
86
+ ///// Expressions
87
+ var UnaryOperator;
88
+ (function (UnaryOperator) {
89
+ UnaryOperator[UnaryOperator["Minus"] = 0] = "Minus";
90
+ UnaryOperator[UnaryOperator["Plus"] = 1] = "Plus";
91
+ })(UnaryOperator = exports.UnaryOperator || (exports.UnaryOperator = {}));
92
+ var BinaryOperator;
93
+ (function (BinaryOperator) {
94
+ BinaryOperator[BinaryOperator["Equals"] = 0] = "Equals";
95
+ BinaryOperator[BinaryOperator["NotEquals"] = 1] = "NotEquals";
96
+ BinaryOperator[BinaryOperator["Identical"] = 2] = "Identical";
97
+ BinaryOperator[BinaryOperator["NotIdentical"] = 3] = "NotIdentical";
98
+ BinaryOperator[BinaryOperator["Minus"] = 4] = "Minus";
99
+ BinaryOperator[BinaryOperator["Plus"] = 5] = "Plus";
100
+ BinaryOperator[BinaryOperator["Divide"] = 6] = "Divide";
101
+ BinaryOperator[BinaryOperator["Multiply"] = 7] = "Multiply";
102
+ BinaryOperator[BinaryOperator["Modulo"] = 8] = "Modulo";
103
+ BinaryOperator[BinaryOperator["And"] = 9] = "And";
104
+ BinaryOperator[BinaryOperator["Or"] = 10] = "Or";
105
+ BinaryOperator[BinaryOperator["BitwiseAnd"] = 11] = "BitwiseAnd";
106
+ BinaryOperator[BinaryOperator["Lower"] = 12] = "Lower";
107
+ BinaryOperator[BinaryOperator["LowerEquals"] = 13] = "LowerEquals";
108
+ BinaryOperator[BinaryOperator["Bigger"] = 14] = "Bigger";
109
+ BinaryOperator[BinaryOperator["BiggerEquals"] = 15] = "BiggerEquals";
110
+ BinaryOperator[BinaryOperator["NullishCoalesce"] = 16] = "NullishCoalesce";
111
+ })(BinaryOperator = exports.BinaryOperator || (exports.BinaryOperator = {}));
112
+ function nullSafeIsEquivalent(base, other) {
113
+ if (base == null || other == null) {
114
+ return base == other;
115
+ }
116
+ return base.isEquivalent(other);
117
+ }
118
+ exports.nullSafeIsEquivalent = nullSafeIsEquivalent;
119
+ function areAllEquivalentPredicate(base, other, equivalentPredicate) {
120
+ const len = base.length;
121
+ if (len !== other.length) {
122
+ return false;
123
+ }
124
+ for (let i = 0; i < len; i++) {
125
+ if (!equivalentPredicate(base[i], other[i])) {
126
+ return false;
127
+ }
128
+ }
129
+ return true;
130
+ }
131
+ function areAllEquivalent(base, other) {
132
+ return areAllEquivalentPredicate(base, other, (baseElement, otherElement) => baseElement.isEquivalent(otherElement));
133
+ }
134
+ exports.areAllEquivalent = areAllEquivalent;
135
+ class Expression {
136
+ constructor(type, sourceSpan) {
137
+ this.type = type || null;
138
+ this.sourceSpan = sourceSpan || null;
139
+ }
140
+ prop(name, sourceSpan) {
141
+ return new ReadPropExpr(this, name, null, sourceSpan);
142
+ }
143
+ callMethod(name, params, sourceSpan) {
144
+ return new InvokeMethodExpr(this, name, params, null, sourceSpan);
145
+ }
146
+ callFn(params, sourceSpan, pure) {
147
+ return new InvokeFunctionExpr(this, params, null, sourceSpan, pure);
148
+ }
149
+ toStmt() {
150
+ return new ExpressionStatement(this, null);
151
+ }
152
+ }
153
+ exports.Expression = Expression;
154
+ var BuiltinVar;
155
+ (function (BuiltinVar) {
156
+ BuiltinVar[BuiltinVar["This"] = 0] = "This";
157
+ BuiltinVar[BuiltinVar["Super"] = 1] = "Super";
158
+ BuiltinVar[BuiltinVar["CatchError"] = 2] = "CatchError";
159
+ BuiltinVar[BuiltinVar["CatchStack"] = 3] = "CatchStack";
160
+ })(BuiltinVar = exports.BuiltinVar || (exports.BuiltinVar = {}));
161
+ class ReadVarExpr extends Expression {
162
+ constructor(name, type, sourceSpan) {
163
+ super(type, sourceSpan);
164
+ if (typeof name === 'string') {
165
+ this.name = name;
166
+ this.builtin = null;
167
+ }
168
+ else {
169
+ this.name = null;
170
+ this.builtin = name;
171
+ }
172
+ }
173
+ isEquivalent(e) {
174
+ return (e instanceof ReadVarExpr &&
175
+ this.name === e.name &&
176
+ this.builtin === e.builtin);
177
+ }
178
+ isConstant() {
179
+ return false;
180
+ }
181
+ visitExpression(visitor, context) {
182
+ return visitor.visitReadVarExpr(this, context);
183
+ }
184
+ set(value) {
185
+ if (!this.name) {
186
+ throw new Error(`Built in variable ${this.builtin} can not be assigned to.`);
187
+ }
188
+ return new WriteVarExpr(this.name, value, null, this.sourceSpan);
189
+ }
190
+ }
191
+ exports.ReadVarExpr = ReadVarExpr;
192
+ class TypeofExpr extends Expression {
193
+ constructor(expr, type, sourceSpan) {
194
+ super(type, sourceSpan);
195
+ this.expr = expr;
196
+ }
197
+ visitExpression(visitor, context) {
198
+ return visitor.visitTypeofExpr(this, context);
199
+ }
200
+ isEquivalent(e) {
201
+ return e instanceof TypeofExpr && e.expr.isEquivalent(this.expr);
202
+ }
203
+ isConstant() {
204
+ return this.expr.isConstant();
205
+ }
206
+ }
207
+ exports.TypeofExpr = TypeofExpr;
208
+ class WrappedNodeExpr extends Expression {
209
+ constructor(node, type, sourceSpan) {
210
+ super(type, sourceSpan);
211
+ this.node = node;
212
+ }
213
+ isEquivalent(e) {
214
+ return e instanceof WrappedNodeExpr && this.node === e.node;
215
+ }
216
+ isConstant() {
217
+ return false;
218
+ }
219
+ visitExpression(visitor, context) {
220
+ return visitor.visitWrappedNodeExpr(this, context);
221
+ }
222
+ }
223
+ exports.WrappedNodeExpr = WrappedNodeExpr;
224
+ class WriteVarExpr extends Expression {
225
+ constructor(name, value, type, sourceSpan) {
226
+ super(type || value.type, sourceSpan);
227
+ this.name = name;
228
+ this.value = value;
229
+ }
230
+ isEquivalent(e) {
231
+ return (e instanceof WriteVarExpr &&
232
+ this.name === e.name &&
233
+ this.value.isEquivalent(e.value));
234
+ }
235
+ isConstant() {
236
+ return false;
237
+ }
238
+ visitExpression(visitor, context) {
239
+ return visitor.visitWriteVarExpr(this, context);
240
+ }
241
+ toDeclStmt(type, modifiers) {
242
+ return new DeclareVarStmt(this.name, this.value, type, modifiers, this.sourceSpan);
243
+ }
244
+ toConstDecl() {
245
+ return this.toDeclStmt(exports.INFERRED_TYPE, [StmtModifier.Final]);
246
+ }
247
+ }
248
+ exports.WriteVarExpr = WriteVarExpr;
249
+ class WriteKeyExpr extends Expression {
250
+ constructor(receiver, index, value, type, sourceSpan) {
251
+ super(type || value.type, sourceSpan);
252
+ this.receiver = receiver;
253
+ this.index = index;
254
+ this.value = value;
255
+ }
256
+ isEquivalent(e) {
257
+ return (e instanceof WriteKeyExpr &&
258
+ this.receiver.isEquivalent(e.receiver) &&
259
+ this.index.isEquivalent(e.index) &&
260
+ this.value.isEquivalent(e.value));
261
+ }
262
+ isConstant() {
263
+ return false;
264
+ }
265
+ visitExpression(visitor, context) {
266
+ return visitor.visitWriteKeyExpr(this, context);
267
+ }
268
+ }
269
+ exports.WriteKeyExpr = WriteKeyExpr;
270
+ class WritePropExpr extends Expression {
271
+ constructor(receiver, name, value, type, sourceSpan) {
272
+ super(type || value.type, sourceSpan);
273
+ this.receiver = receiver;
274
+ this.name = name;
275
+ this.value = value;
276
+ }
277
+ isEquivalent(e) {
278
+ return (e instanceof WritePropExpr &&
279
+ this.receiver.isEquivalent(e.receiver) &&
280
+ this.name === e.name &&
281
+ this.value.isEquivalent(e.value));
282
+ }
283
+ isConstant() {
284
+ return false;
285
+ }
286
+ visitExpression(visitor, context) {
287
+ return visitor.visitWritePropExpr(this, context);
288
+ }
289
+ }
290
+ exports.WritePropExpr = WritePropExpr;
291
+ var BuiltinMethod;
292
+ (function (BuiltinMethod) {
293
+ BuiltinMethod[BuiltinMethod["ConcatArray"] = 0] = "ConcatArray";
294
+ BuiltinMethod[BuiltinMethod["SubscribeObservable"] = 1] = "SubscribeObservable";
295
+ BuiltinMethod[BuiltinMethod["Bind"] = 2] = "Bind";
296
+ })(BuiltinMethod = exports.BuiltinMethod || (exports.BuiltinMethod = {}));
297
+ class InvokeMethodExpr extends Expression {
298
+ constructor(receiver, method, args, type, sourceSpan) {
299
+ super(type, sourceSpan);
300
+ this.receiver = receiver;
301
+ this.args = args;
302
+ if (typeof method === 'string') {
303
+ this.name = method;
304
+ this.builtin = null;
305
+ }
306
+ else {
307
+ this.name = null;
308
+ this.builtin = method;
309
+ }
310
+ }
311
+ isEquivalent(e) {
312
+ return (e instanceof InvokeMethodExpr &&
313
+ this.receiver.isEquivalent(e.receiver) &&
314
+ this.name === e.name &&
315
+ this.builtin === e.builtin &&
316
+ areAllEquivalent(this.args, e.args));
317
+ }
318
+ isConstant() {
319
+ return false;
320
+ }
321
+ visitExpression(visitor, context) {
322
+ return visitor.visitInvokeMethodExpr(this, context);
323
+ }
324
+ }
325
+ exports.InvokeMethodExpr = InvokeMethodExpr;
326
+ class InvokeFunctionExpr extends Expression {
327
+ constructor(fn, args, type, sourceSpan, pure = false) {
328
+ super(type, sourceSpan);
329
+ this.fn = fn;
330
+ this.args = args;
331
+ this.pure = pure;
332
+ }
333
+ isEquivalent(e) {
334
+ return (e instanceof InvokeFunctionExpr &&
335
+ this.fn.isEquivalent(e.fn) &&
336
+ areAllEquivalent(this.args, e.args) &&
337
+ this.pure === e.pure);
338
+ }
339
+ isConstant() {
340
+ return false;
341
+ }
342
+ visitExpression(visitor, context) {
343
+ return visitor.visitInvokeFunctionExpr(this, context);
344
+ }
345
+ }
346
+ exports.InvokeFunctionExpr = InvokeFunctionExpr;
347
+ class InstantiateExpr extends Expression {
348
+ constructor(classExpr, args, type, sourceSpan) {
349
+ super(type, sourceSpan);
350
+ this.classExpr = classExpr;
351
+ this.args = args;
352
+ }
353
+ isEquivalent(e) {
354
+ return (e instanceof InstantiateExpr &&
355
+ this.classExpr.isEquivalent(e.classExpr) &&
356
+ areAllEquivalent(this.args, e.args));
357
+ }
358
+ isConstant() {
359
+ return false;
360
+ }
361
+ visitExpression(visitor, context) {
362
+ return visitor.visitInstantiateExpr(this, context);
363
+ }
364
+ }
365
+ exports.InstantiateExpr = InstantiateExpr;
366
+ class LiteralExpr extends Expression {
367
+ constructor(value, type, sourceSpan) {
368
+ super(type, sourceSpan);
369
+ this.value = value;
370
+ }
371
+ isEquivalent(e) {
372
+ return e instanceof LiteralExpr && this.value === e.value;
373
+ }
374
+ isConstant() {
375
+ return true;
376
+ }
377
+ visitExpression(visitor, context) {
378
+ return visitor.visitLiteralExpr(this, context);
379
+ }
380
+ }
381
+ exports.LiteralExpr = LiteralExpr;
382
+ class TemplateLiteral {
383
+ constructor(elements, expressions) {
384
+ this.elements = elements;
385
+ this.expressions = expressions;
386
+ }
387
+ }
388
+ exports.TemplateLiteral = TemplateLiteral;
389
+ class TemplateLiteralElement {
390
+ constructor(text, sourceSpan, rawText) {
391
+ var _a;
392
+ this.text = text;
393
+ this.sourceSpan = sourceSpan;
394
+ // If `rawText` is not provided, try to extract the raw string from its
395
+ // associated `sourceSpan`. If that is also not available, "fake" the raw
396
+ // string instead by escaping the following control sequences:
397
+ // - "\" would otherwise indicate that the next character is a control character.
398
+ // - "`" and "${" are template string control sequences that would otherwise prematurely
399
+ // indicate the end of the template literal element.
400
+ this.rawText =
401
+ (_a = rawText !== null && rawText !== void 0 ? rawText : sourceSpan === null || sourceSpan === void 0 ? void 0 : sourceSpan.toString()) !== null && _a !== void 0 ? _a : escapeForTemplateLiteral(escapeSlashes(text));
402
+ }
403
+ }
404
+ exports.TemplateLiteralElement = TemplateLiteralElement;
405
+ class MessagePiece {
406
+ constructor(text, sourceSpan) {
407
+ this.text = text;
408
+ this.sourceSpan = sourceSpan;
409
+ }
410
+ }
411
+ exports.MessagePiece = MessagePiece;
412
+ class LiteralPiece extends MessagePiece {
413
+ }
414
+ exports.LiteralPiece = LiteralPiece;
415
+ class PlaceholderPiece extends MessagePiece {
416
+ }
417
+ exports.PlaceholderPiece = PlaceholderPiece;
418
+ const escapeSlashes = (str) => str.replace(/\\/g, '\\\\');
419
+ const escapeStartingColon = (str) => str.replace(/^:/, '\\:');
420
+ const escapeColons = (str) => str.replace(/:/g, '\\:');
421
+ const escapeForTemplateLiteral = (str) => str.replace(/`/g, '\\`').replace(/\${/g, '$\\{');
422
+ class ExternalExpr extends Expression {
423
+ constructor(value, type, typeParams = null, sourceSpan) {
424
+ super(type, sourceSpan);
425
+ this.value = value;
426
+ this.typeParams = typeParams;
427
+ }
428
+ isEquivalent(e) {
429
+ return (e instanceof ExternalExpr &&
430
+ this.value.name === e.value.name &&
431
+ this.value.moduleName === e.value.moduleName &&
432
+ this.value.runtime === e.value.runtime);
433
+ }
434
+ isConstant() {
435
+ return false;
436
+ }
437
+ visitExpression(visitor, context) {
438
+ return visitor.visitExternalExpr(this, context);
439
+ }
440
+ }
441
+ exports.ExternalExpr = ExternalExpr;
442
+ class ExternalReference {
443
+ constructor(moduleName, name, runtime) {
444
+ this.moduleName = moduleName;
445
+ this.name = name;
446
+ this.runtime = runtime;
447
+ }
448
+ }
449
+ exports.ExternalReference = ExternalReference;
450
+ class ConditionalExpr extends Expression {
451
+ constructor(condition, trueCase, falseCase = null, type, sourceSpan) {
452
+ super(type || trueCase.type, sourceSpan);
453
+ this.condition = condition;
454
+ this.falseCase = falseCase;
455
+ this.trueCase = trueCase;
456
+ }
457
+ isEquivalent(e) {
458
+ return (e instanceof ConditionalExpr &&
459
+ this.condition.isEquivalent(e.condition) &&
460
+ this.trueCase.isEquivalent(e.trueCase) &&
461
+ nullSafeIsEquivalent(this.falseCase, e.falseCase));
462
+ }
463
+ isConstant() {
464
+ return false;
465
+ }
466
+ visitExpression(visitor, context) {
467
+ return visitor.visitConditionalExpr(this, context);
468
+ }
469
+ }
470
+ exports.ConditionalExpr = ConditionalExpr;
471
+ class NotExpr extends Expression {
472
+ constructor(condition, sourceSpan) {
473
+ super(exports.BOOL_TYPE, sourceSpan);
474
+ this.condition = condition;
475
+ }
476
+ isEquivalent(e) {
477
+ return e instanceof NotExpr && this.condition.isEquivalent(e.condition);
478
+ }
479
+ isConstant() {
480
+ return false;
481
+ }
482
+ visitExpression(visitor, context) {
483
+ return visitor.visitNotExpr(this, context);
484
+ }
485
+ }
486
+ exports.NotExpr = NotExpr;
487
+ class AssertNotNull extends Expression {
488
+ constructor(condition, sourceSpan) {
489
+ super(condition.type, sourceSpan);
490
+ this.condition = condition;
491
+ }
492
+ isEquivalent(e) {
493
+ return (e instanceof AssertNotNull && this.condition.isEquivalent(e.condition));
494
+ }
495
+ isConstant() {
496
+ return false;
497
+ }
498
+ visitExpression(visitor, context) {
499
+ return visitor.visitAssertNotNullExpr(this, context);
500
+ }
501
+ }
502
+ exports.AssertNotNull = AssertNotNull;
503
+ class CastExpr extends Expression {
504
+ constructor(value, type, sourceSpan) {
505
+ super(type, sourceSpan);
506
+ this.value = value;
507
+ }
508
+ isEquivalent(e) {
509
+ return e instanceof CastExpr && this.value.isEquivalent(e.value);
510
+ }
511
+ isConstant() {
512
+ return false;
513
+ }
514
+ visitExpression(visitor, context) {
515
+ return visitor.visitCastExpr(this, context);
516
+ }
517
+ }
518
+ exports.CastExpr = CastExpr;
519
+ class FnParam {
520
+ constructor(name, type = null) {
521
+ this.name = name;
522
+ this.type = type;
523
+ }
524
+ isEquivalent(param) {
525
+ return this.name === param.name;
526
+ }
527
+ }
528
+ exports.FnParam = FnParam;
529
+ class FunctionExpr extends Expression {
530
+ constructor(params, statements, type, sourceSpan, name) {
531
+ super(type, sourceSpan);
532
+ this.params = params;
533
+ this.statements = statements;
534
+ this.name = name;
535
+ }
536
+ isEquivalent(e) {
537
+ return (e instanceof FunctionExpr &&
538
+ areAllEquivalent(this.params, e.params) &&
539
+ areAllEquivalent(this.statements, e.statements));
540
+ }
541
+ isConstant() {
542
+ return false;
543
+ }
544
+ visitExpression(visitor, context) {
545
+ return visitor.visitFunctionExpr(this, context);
546
+ }
547
+ toDeclStmt(name, modifiers) {
548
+ return new DeclareFunctionStmt(name, this.params, this.statements, this.type, modifiers, this.sourceSpan);
549
+ }
550
+ }
551
+ exports.FunctionExpr = FunctionExpr;
552
+ class UnaryOperatorExpr extends Expression {
553
+ constructor(operator, expr, type, sourceSpan, parens = true) {
554
+ super(type || exports.NUMBER_TYPE, sourceSpan);
555
+ this.operator = operator;
556
+ this.expr = expr;
557
+ this.parens = parens;
558
+ }
559
+ isEquivalent(e) {
560
+ return (e instanceof UnaryOperatorExpr &&
561
+ this.operator === e.operator &&
562
+ this.expr.isEquivalent(e.expr));
563
+ }
564
+ isConstant() {
565
+ return false;
566
+ }
567
+ visitExpression(visitor, context) {
568
+ return visitor.visitUnaryOperatorExpr(this, context);
569
+ }
570
+ }
571
+ exports.UnaryOperatorExpr = UnaryOperatorExpr;
572
+ class BinaryOperatorExpr extends Expression {
573
+ constructor(operator, lhs, rhs, type, sourceSpan, parens = true) {
574
+ super(type || lhs.type, sourceSpan);
575
+ this.operator = operator;
576
+ this.rhs = rhs;
577
+ this.parens = parens;
578
+ this.lhs = lhs;
579
+ }
580
+ isEquivalent(e) {
581
+ return (e instanceof BinaryOperatorExpr &&
582
+ this.operator === e.operator &&
583
+ this.lhs.isEquivalent(e.lhs) &&
584
+ this.rhs.isEquivalent(e.rhs));
585
+ }
586
+ isConstant() {
587
+ return false;
588
+ }
589
+ visitExpression(visitor, context) {
590
+ return visitor.visitBinaryOperatorExpr(this, context);
591
+ }
592
+ }
593
+ exports.BinaryOperatorExpr = BinaryOperatorExpr;
594
+ class ReadPropExpr extends Expression {
595
+ constructor(receiver, name, type, sourceSpan) {
596
+ super(type, sourceSpan);
597
+ this.receiver = receiver;
598
+ this.name = name;
599
+ }
600
+ isEquivalent(e) {
601
+ return (e instanceof ReadPropExpr &&
602
+ this.receiver.isEquivalent(e.receiver) &&
603
+ this.name === e.name);
604
+ }
605
+ isConstant() {
606
+ return false;
607
+ }
608
+ visitExpression(visitor, context) {
609
+ return visitor.visitReadPropExpr(this, context);
610
+ }
611
+ set(value) {
612
+ return new WritePropExpr(this.receiver, this.name, value, null, this.sourceSpan);
613
+ }
614
+ }
615
+ exports.ReadPropExpr = ReadPropExpr;
616
+ class ReadKeyExpr extends Expression {
617
+ constructor(receiver, index, type, sourceSpan) {
618
+ super(type, sourceSpan);
619
+ this.receiver = receiver;
620
+ this.index = index;
621
+ }
622
+ isEquivalent(e) {
623
+ return (e instanceof ReadKeyExpr &&
624
+ this.receiver.isEquivalent(e.receiver) &&
625
+ this.index.isEquivalent(e.index));
626
+ }
627
+ isConstant() {
628
+ return false;
629
+ }
630
+ visitExpression(visitor, context) {
631
+ return visitor.visitReadKeyExpr(this, context);
632
+ }
633
+ set(value) {
634
+ return new WriteKeyExpr(this.receiver, this.index, value, null, this.sourceSpan);
635
+ }
636
+ }
637
+ exports.ReadKeyExpr = ReadKeyExpr;
638
+ class LiteralArrayExpr extends Expression {
639
+ constructor(entries, type, sourceSpan) {
640
+ super(type, sourceSpan);
641
+ this.entries = entries;
642
+ }
643
+ isConstant() {
644
+ return this.entries.every((e) => e.isConstant());
645
+ }
646
+ isEquivalent(e) {
647
+ return (e instanceof LiteralArrayExpr && areAllEquivalent(this.entries, e.entries));
648
+ }
649
+ visitExpression(visitor, context) {
650
+ return visitor.visitLiteralArrayExpr(this, context);
651
+ }
652
+ }
653
+ exports.LiteralArrayExpr = LiteralArrayExpr;
654
+ class LiteralMapEntry {
655
+ constructor(key, value, quoted) {
656
+ this.key = key;
657
+ this.value = value;
658
+ this.quoted = quoted;
659
+ }
660
+ isEquivalent(e) {
661
+ return this.key === e.key && this.value.isEquivalent(e.value);
662
+ }
663
+ }
664
+ exports.LiteralMapEntry = LiteralMapEntry;
665
+ class LiteralMapExpr extends Expression {
666
+ constructor(entries, type, sourceSpan) {
667
+ super(type, sourceSpan);
668
+ this.entries = entries;
669
+ this.valueType = null;
670
+ if (type) {
671
+ this.valueType = type.valueType;
672
+ }
673
+ }
674
+ isEquivalent(e) {
675
+ return (e instanceof LiteralMapExpr && areAllEquivalent(this.entries, e.entries));
676
+ }
677
+ isConstant() {
678
+ return this.entries.every((e) => e.value.isConstant());
679
+ }
680
+ visitExpression(visitor, context) {
681
+ return visitor.visitLiteralMapExpr(this, context);
682
+ }
683
+ }
684
+ exports.LiteralMapExpr = LiteralMapExpr;
685
+ class CommaExpr extends Expression {
686
+ constructor(parts, sourceSpan) {
687
+ super(parts[parts.length - 1].type, sourceSpan);
688
+ this.parts = parts;
689
+ }
690
+ isEquivalent(e) {
691
+ return e instanceof CommaExpr && areAllEquivalent(this.parts, e.parts);
692
+ }
693
+ isConstant() {
694
+ return false;
695
+ }
696
+ visitExpression(visitor, context) {
697
+ return visitor.visitCommaExpr(this, context);
698
+ }
699
+ }
700
+ exports.CommaExpr = CommaExpr;
701
+ exports.THIS_EXPR = new ReadVarExpr(BuiltinVar.This, null, null);
702
+ exports.SUPER_EXPR = new ReadVarExpr(BuiltinVar.Super, null, null);
703
+ exports.CATCH_ERROR_VAR = new ReadVarExpr(BuiltinVar.CatchError, null, null);
704
+ exports.CATCH_STACK_VAR = new ReadVarExpr(BuiltinVar.CatchStack, null, null);
705
+ exports.NULL_EXPR = new LiteralExpr(null, null, null);
706
+ exports.TYPED_NULL_EXPR = new LiteralExpr(null, exports.INFERRED_TYPE, null);
707
+ //// Statements
708
+ var StmtModifier;
709
+ (function (StmtModifier) {
710
+ StmtModifier[StmtModifier["Final"] = 0] = "Final";
711
+ StmtModifier[StmtModifier["Private"] = 1] = "Private";
712
+ StmtModifier[StmtModifier["Exported"] = 2] = "Exported";
713
+ StmtModifier[StmtModifier["Static"] = 3] = "Static";
714
+ })(StmtModifier = exports.StmtModifier || (exports.StmtModifier = {}));
715
+ class LeadingComment {
716
+ constructor(text, multiline, trailingNewline) {
717
+ this.text = text;
718
+ this.multiline = multiline;
719
+ this.trailingNewline = trailingNewline;
720
+ }
721
+ toString() {
722
+ return this.multiline ? ` ${this.text} ` : this.text;
723
+ }
724
+ }
725
+ exports.LeadingComment = LeadingComment;
726
+ class JSDocComment extends LeadingComment {
727
+ constructor(tags) {
728
+ super('', /* multiline */ true, /* trailingNewline */ true);
729
+ this.tags = tags;
730
+ }
731
+ toString() {
732
+ return serializeTags(this.tags);
733
+ }
734
+ }
735
+ exports.JSDocComment = JSDocComment;
736
+ class Statement {
737
+ constructor(modifiers = [], sourceSpan = null, leadingComments) {
738
+ this.modifiers = modifiers;
739
+ this.sourceSpan = sourceSpan;
740
+ this.leadingComments = leadingComments;
741
+ }
742
+ hasModifier(modifier) {
743
+ return this.modifiers.indexOf(modifier) !== -1;
744
+ }
745
+ addLeadingComment(leadingComment) {
746
+ var _a;
747
+ this.leadingComments = (_a = this.leadingComments) !== null && _a !== void 0 ? _a : [];
748
+ this.leadingComments.push(leadingComment);
749
+ }
750
+ }
751
+ exports.Statement = Statement;
752
+ class DeclareVarStmt extends Statement {
753
+ constructor(name, value, type, modifiers, sourceSpan, leadingComments) {
754
+ super(modifiers, sourceSpan, leadingComments);
755
+ this.name = name;
756
+ this.value = value;
757
+ this.type = type || (value && value.type) || null;
758
+ }
759
+ isEquivalent(stmt) {
760
+ return (stmt instanceof DeclareVarStmt &&
761
+ this.name === stmt.name &&
762
+ (this.value
763
+ ? !!stmt.value && this.value.isEquivalent(stmt.value)
764
+ : !stmt.value));
765
+ }
766
+ visitStatement(visitor, context) {
767
+ return visitor.visitDeclareVarStmt(this, context);
768
+ }
769
+ }
770
+ exports.DeclareVarStmt = DeclareVarStmt;
771
+ class DeclareFunctionStmt extends Statement {
772
+ constructor(name, params, statements, type, modifiers, sourceSpan, leadingComments) {
773
+ super(modifiers, sourceSpan, leadingComments);
774
+ this.name = name;
775
+ this.params = params;
776
+ this.statements = statements;
777
+ this.type = type || null;
778
+ }
779
+ isEquivalent(stmt) {
780
+ return (stmt instanceof DeclareFunctionStmt &&
781
+ areAllEquivalent(this.params, stmt.params) &&
782
+ areAllEquivalent(this.statements, stmt.statements));
783
+ }
784
+ visitStatement(visitor, context) {
785
+ return visitor.visitDeclareFunctionStmt(this, context);
786
+ }
787
+ }
788
+ exports.DeclareFunctionStmt = DeclareFunctionStmt;
789
+ class ExpressionStatement extends Statement {
790
+ constructor(expr, sourceSpan, leadingComments) {
791
+ super([], sourceSpan, leadingComments);
792
+ this.expr = expr;
793
+ }
794
+ isEquivalent(stmt) {
795
+ return (stmt instanceof ExpressionStatement && this.expr.isEquivalent(stmt.expr));
796
+ }
797
+ visitStatement(visitor, context) {
798
+ return visitor.visitExpressionStmt(this, context);
799
+ }
800
+ }
801
+ exports.ExpressionStatement = ExpressionStatement;
802
+ class ReturnStatement extends Statement {
803
+ constructor(value, sourceSpan = null, leadingComments) {
804
+ super([], sourceSpan, leadingComments);
805
+ this.value = value;
806
+ }
807
+ isEquivalent(stmt) {
808
+ return (stmt instanceof ReturnStatement && this.value.isEquivalent(stmt.value));
809
+ }
810
+ visitStatement(visitor, context) {
811
+ return visitor.visitReturnStmt(this, context);
812
+ }
813
+ }
814
+ exports.ReturnStatement = ReturnStatement;
815
+ class AbstractClassPart {
816
+ constructor(type = null, modifiers = []) {
817
+ this.type = type;
818
+ this.modifiers = modifiers;
819
+ }
820
+ hasModifier(modifier) {
821
+ return this.modifiers.indexOf(modifier) !== -1;
822
+ }
823
+ }
824
+ exports.AbstractClassPart = AbstractClassPart;
825
+ class ClassField extends AbstractClassPart {
826
+ constructor(name, type, modifiers, initializer) {
827
+ super(type, modifiers);
828
+ this.name = name;
829
+ this.initializer = initializer;
830
+ }
831
+ isEquivalent(f) {
832
+ return this.name === f.name;
833
+ }
834
+ }
835
+ exports.ClassField = ClassField;
836
+ class ClassMethod extends AbstractClassPart {
837
+ constructor(name, params, body, type, modifiers) {
838
+ super(type, modifiers);
839
+ this.name = name;
840
+ this.params = params;
841
+ this.body = body;
842
+ }
843
+ isEquivalent(m) {
844
+ return this.name === m.name && areAllEquivalent(this.body, m.body);
845
+ }
846
+ }
847
+ exports.ClassMethod = ClassMethod;
848
+ class ClassGetter extends AbstractClassPart {
849
+ constructor(name, body, type, modifiers) {
850
+ super(type, modifiers);
851
+ this.name = name;
852
+ this.body = body;
853
+ }
854
+ isEquivalent(m) {
855
+ return this.name === m.name && areAllEquivalent(this.body, m.body);
856
+ }
857
+ }
858
+ exports.ClassGetter = ClassGetter;
859
+ class ClassStmt extends Statement {
860
+ constructor(name, parent, fields, getters, constructorMethod, methods, modifiers, sourceSpan, leadingComments) {
861
+ super(modifiers, sourceSpan, leadingComments);
862
+ this.name = name;
863
+ this.parent = parent;
864
+ this.fields = fields;
865
+ this.getters = getters;
866
+ this.constructorMethod = constructorMethod;
867
+ this.methods = methods;
868
+ }
869
+ isEquivalent(stmt) {
870
+ return (stmt instanceof ClassStmt &&
871
+ this.name === stmt.name &&
872
+ nullSafeIsEquivalent(this.parent, stmt.parent) &&
873
+ areAllEquivalent(this.fields, stmt.fields) &&
874
+ areAllEquivalent(this.getters, stmt.getters) &&
875
+ this.constructorMethod.isEquivalent(stmt.constructorMethod) &&
876
+ areAllEquivalent(this.methods, stmt.methods));
877
+ }
878
+ visitStatement(visitor, context) {
879
+ return visitor.visitDeclareClassStmt(this, context);
880
+ }
881
+ }
882
+ exports.ClassStmt = ClassStmt;
883
+ class IfStmt extends Statement {
884
+ constructor(condition, trueCase, falseCase = [], sourceSpan, leadingComments) {
885
+ super([], sourceSpan, leadingComments);
886
+ this.condition = condition;
887
+ this.trueCase = trueCase;
888
+ this.falseCase = falseCase;
889
+ }
890
+ isEquivalent(stmt) {
891
+ return (stmt instanceof IfStmt &&
892
+ this.condition.isEquivalent(stmt.condition) &&
893
+ areAllEquivalent(this.trueCase, stmt.trueCase) &&
894
+ areAllEquivalent(this.falseCase, stmt.falseCase));
895
+ }
896
+ visitStatement(visitor, context) {
897
+ return visitor.visitIfStmt(this, context);
898
+ }
899
+ }
900
+ exports.IfStmt = IfStmt;
901
+ function variable(name, type, sourceSpan) {
902
+ return new ReadVarExpr(name, type, sourceSpan);
903
+ }
904
+ exports.variable = variable;
905
+ function importExpr(id, typeParams = null, sourceSpan) {
906
+ return new ExternalExpr(id, null, typeParams, sourceSpan);
907
+ }
908
+ exports.importExpr = importExpr;
909
+ function expressionType(expr, typeModifiers, typeParams) {
910
+ return new ExpressionType(expr, typeModifiers, typeParams);
911
+ }
912
+ exports.expressionType = expressionType;
913
+ function typeofExpr(expr) {
914
+ return new TypeofExpr(expr);
915
+ }
916
+ exports.typeofExpr = typeofExpr;
917
+ function literalArr(values, type, sourceSpan) {
918
+ return new LiteralArrayExpr(values, type, sourceSpan);
919
+ }
920
+ exports.literalArr = literalArr;
921
+ function literalMap(values, type = null) {
922
+ return new LiteralMapExpr(values.map((e) => new LiteralMapEntry(e.key, e.value, e.quoted)), type, null);
923
+ }
924
+ exports.literalMap = literalMap;
925
+ function unary(operator, expr, type, sourceSpan) {
926
+ return new UnaryOperatorExpr(operator, expr, type, sourceSpan);
927
+ }
928
+ exports.unary = unary;
929
+ function not(expr, sourceSpan) {
930
+ return new NotExpr(expr, sourceSpan);
931
+ }
932
+ exports.not = not;
933
+ function assertNotNull(expr, sourceSpan) {
934
+ return new AssertNotNull(expr, sourceSpan);
935
+ }
936
+ exports.assertNotNull = assertNotNull;
937
+ function fn(params, body, type, sourceSpan, name) {
938
+ return new FunctionExpr(params, body, type, sourceSpan, name);
939
+ }
940
+ exports.fn = fn;
941
+ function ifStmt(condition, thenClause, elseClause, sourceSpan, leadingComments) {
942
+ return new IfStmt(condition, thenClause, elseClause, sourceSpan, leadingComments);
943
+ }
944
+ exports.ifStmt = ifStmt;
945
+ function literal(value, type, sourceSpan) {
946
+ return new LiteralExpr(value, type, sourceSpan);
947
+ }
948
+ exports.literal = literal;
949
+ function isNull(exp) {
950
+ return exp instanceof LiteralExpr && exp.value === null;
951
+ }
952
+ exports.isNull = isNull;
953
+ /*
954
+ * Serializes a `Tag` into a string.
955
+ * Returns a string like " @foo {bar} baz" (note the leading whitespace before `@foo`).
956
+ */
957
+ function tagToString(tag) {
958
+ let out = '';
959
+ if (tag.tagName) {
960
+ out += ` @${tag.tagName}`;
961
+ }
962
+ if (tag.text) {
963
+ if (tag.text.match(/\/\*|\*\//)) {
964
+ throw new Error('JSDoc text cannot contain "/*" and "*/"');
965
+ }
966
+ out += ' ' + tag.text.replace(/@/g, '\\@');
967
+ }
968
+ return out;
969
+ }
970
+ function serializeTags(tags) {
971
+ if (tags.length === 0)
972
+ return '';
973
+ if (tags.length === 1 && tags[0].tagName && !tags[0].text) {
974
+ // The JSDOC comment is a single simple tag: e.g `/** @tagname */`.
975
+ return `*${tagToString(tags[0])} `;
976
+ }
977
+ let out = '*\n';
978
+ for (const tag of tags) {
979
+ out += ' *';
980
+ // If the tagToString is multi-line, insert " * " prefixes on lines.
981
+ out += tagToString(tag).replace(/\n/g, '\n * ');
982
+ out += '\n';
983
+ }
984
+ out += ' ';
985
+ return out;
986
+ }