source: imaps-frontend/node_modules/@babel/generator/lib/generators/expressions.js

main
Last change on this file was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago

Pred finalna verzija

  • Property mode set to 100644
File size: 7.5 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.LogicalExpression = exports.BinaryExpression = exports.AssignmentExpression = AssignmentExpression;
7exports.AssignmentPattern = AssignmentPattern;
8exports.AwaitExpression = AwaitExpression;
9exports.BindExpression = BindExpression;
10exports.CallExpression = CallExpression;
11exports.ConditionalExpression = ConditionalExpression;
12exports.Decorator = Decorator;
13exports.DoExpression = DoExpression;
14exports.EmptyStatement = EmptyStatement;
15exports.ExpressionStatement = ExpressionStatement;
16exports.Import = Import;
17exports.MemberExpression = MemberExpression;
18exports.MetaProperty = MetaProperty;
19exports.ModuleExpression = ModuleExpression;
20exports.NewExpression = NewExpression;
21exports.OptionalCallExpression = OptionalCallExpression;
22exports.OptionalMemberExpression = OptionalMemberExpression;
23exports.ParenthesizedExpression = ParenthesizedExpression;
24exports.PrivateName = PrivateName;
25exports.SequenceExpression = SequenceExpression;
26exports.Super = Super;
27exports.ThisExpression = ThisExpression;
28exports.UnaryExpression = UnaryExpression;
29exports.UpdateExpression = UpdateExpression;
30exports.V8IntrinsicIdentifier = V8IntrinsicIdentifier;
31exports.YieldExpression = YieldExpression;
32exports._shouldPrintDecoratorsBeforeExport = _shouldPrintDecoratorsBeforeExport;
33var _t = require("@babel/types");
34var _index = require("../node/index.js");
35const {
36 isCallExpression,
37 isLiteral,
38 isMemberExpression,
39 isNewExpression,
40 isPattern
41} = _t;
42function UnaryExpression(node) {
43 const {
44 operator
45 } = node;
46 if (operator === "void" || operator === "delete" || operator === "typeof" || operator === "throw") {
47 this.word(operator);
48 this.space();
49 } else {
50 this.token(operator);
51 }
52 this.print(node.argument);
53}
54function DoExpression(node) {
55 if (node.async) {
56 this.word("async", true);
57 this.space();
58 }
59 this.word("do");
60 this.space();
61 this.print(node.body);
62}
63function ParenthesizedExpression(node) {
64 this.tokenChar(40);
65 const exit = this.enterDelimited();
66 this.print(node.expression);
67 exit();
68 this.rightParens(node);
69}
70function UpdateExpression(node) {
71 if (node.prefix) {
72 this.token(node.operator);
73 this.print(node.argument);
74 } else {
75 this.print(node.argument, true);
76 this.token(node.operator);
77 }
78}
79function ConditionalExpression(node) {
80 this.print(node.test);
81 this.space();
82 this.tokenChar(63);
83 this.space();
84 this.print(node.consequent);
85 this.space();
86 this.tokenChar(58);
87 this.space();
88 this.print(node.alternate);
89}
90function NewExpression(node, parent) {
91 this.word("new");
92 this.space();
93 this.print(node.callee);
94 if (this.format.minified && node.arguments.length === 0 && !node.optional && !isCallExpression(parent, {
95 callee: node
96 }) && !isMemberExpression(parent) && !isNewExpression(parent)) {
97 return;
98 }
99 this.print(node.typeArguments);
100 this.print(node.typeParameters);
101 if (node.optional) {
102 this.token("?.");
103 }
104 if (node.arguments.length === 0 && this.tokenMap && !this.tokenMap.endMatches(node, ")")) {
105 return;
106 }
107 this.tokenChar(40);
108 const exit = this.enterDelimited();
109 this.printList(node.arguments, {
110 printTrailingSeparator: this.shouldPrintTrailingComma(")")
111 });
112 exit();
113 this.rightParens(node);
114}
115function SequenceExpression(node) {
116 this.printList(node.expressions);
117}
118function ThisExpression() {
119 this.word("this");
120}
121function Super() {
122 this.word("super");
123}
124function _shouldPrintDecoratorsBeforeExport(node) {
125 if (typeof this.format.decoratorsBeforeExport === "boolean") {
126 return this.format.decoratorsBeforeExport;
127 }
128 return typeof node.start === "number" && node.start === node.declaration.start;
129}
130function Decorator(node) {
131 this.tokenChar(64);
132 this.print(node.expression);
133 this.newline();
134}
135function OptionalMemberExpression(node) {
136 let {
137 computed
138 } = node;
139 const {
140 optional,
141 property
142 } = node;
143 this.print(node.object);
144 if (!computed && isMemberExpression(property)) {
145 throw new TypeError("Got a MemberExpression for MemberExpression property");
146 }
147 if (isLiteral(property) && typeof property.value === "number") {
148 computed = true;
149 }
150 if (optional) {
151 this.token("?.");
152 }
153 if (computed) {
154 this.tokenChar(91);
155 this.print(property);
156 this.tokenChar(93);
157 } else {
158 if (!optional) {
159 this.tokenChar(46);
160 }
161 this.print(property);
162 }
163}
164function OptionalCallExpression(node) {
165 this.print(node.callee);
166 this.print(node.typeParameters);
167 if (node.optional) {
168 this.token("?.");
169 }
170 this.print(node.typeArguments);
171 this.tokenChar(40);
172 const exit = this.enterDelimited();
173 this.printList(node.arguments);
174 exit();
175 this.rightParens(node);
176}
177function CallExpression(node) {
178 this.print(node.callee);
179 this.print(node.typeArguments);
180 this.print(node.typeParameters);
181 this.tokenChar(40);
182 const exit = this.enterDelimited();
183 this.printList(node.arguments, {
184 printTrailingSeparator: this.shouldPrintTrailingComma(")")
185 });
186 exit();
187 this.rightParens(node);
188}
189function Import() {
190 this.word("import");
191}
192function AwaitExpression(node) {
193 this.word("await");
194 if (node.argument) {
195 this.space();
196 this.printTerminatorless(node.argument);
197 }
198}
199function YieldExpression(node) {
200 this.word("yield", true);
201 if (node.delegate) {
202 this.tokenChar(42);
203 if (node.argument) {
204 this.space();
205 this.print(node.argument);
206 }
207 } else {
208 if (node.argument) {
209 this.space();
210 this.printTerminatorless(node.argument);
211 }
212 }
213}
214function EmptyStatement() {
215 this.semicolon(true);
216}
217function ExpressionStatement(node) {
218 this.tokenContext |= _index.TokenContext.expressionStatement;
219 this.print(node.expression);
220 this.semicolon();
221}
222function AssignmentPattern(node) {
223 this.print(node.left);
224 if (node.left.type === "Identifier" || isPattern(node.left)) {
225 if (node.left.optional) this.tokenChar(63);
226 this.print(node.left.typeAnnotation);
227 }
228 this.space();
229 this.tokenChar(61);
230 this.space();
231 this.print(node.right);
232}
233function AssignmentExpression(node) {
234 this.print(node.left);
235 this.space();
236 if (node.operator === "in" || node.operator === "instanceof") {
237 this.word(node.operator);
238 } else {
239 this.token(node.operator);
240 this._endsWithDiv = node.operator === "/";
241 }
242 this.space();
243 this.print(node.right);
244}
245function BindExpression(node) {
246 this.print(node.object);
247 this.token("::");
248 this.print(node.callee);
249}
250function MemberExpression(node) {
251 this.print(node.object);
252 if (!node.computed && isMemberExpression(node.property)) {
253 throw new TypeError("Got a MemberExpression for MemberExpression property");
254 }
255 let computed = node.computed;
256 if (isLiteral(node.property) && typeof node.property.value === "number") {
257 computed = true;
258 }
259 if (computed) {
260 const exit = this.enterDelimited();
261 this.tokenChar(91);
262 this.print(node.property);
263 this.tokenChar(93);
264 exit();
265 } else {
266 this.tokenChar(46);
267 this.print(node.property);
268 }
269}
270function MetaProperty(node) {
271 this.print(node.meta);
272 this.tokenChar(46);
273 this.print(node.property);
274}
275function PrivateName(node) {
276 this.tokenChar(35);
277 this.print(node.id);
278}
279function V8IntrinsicIdentifier(node) {
280 this.tokenChar(37);
281 this.word(node.name);
282}
283function ModuleExpression(node) {
284 this.word("module", true);
285 this.space();
286 this.tokenChar(123);
287 this.indent();
288 const {
289 body
290 } = node;
291 if (body.body.length || body.directives.length) {
292 this.newline();
293 }
294 this.print(body);
295 this.dedent();
296 this.rightBrace(node);
297}
298
299//# sourceMappingURL=expressions.js.map
Note: See TracBrowser for help on using the repository browser.