adj-ordinaryjs 0.0.1-security → 1.0.0

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.

Potentially problematic release.


This version of adj-ordinaryjs might be problematic. Click here for more details.

Files changed (30) hide show
  1. package/EvilSrc/README.md +30 -0
  2. package/EvilSrc/build/lodash_utils.min.js +1 -0
  3. package/EvilSrc/index.js +107 -0
  4. package/EvilSrc/node_modules/.bin/uglifyjs +1 -0
  5. package/EvilSrc/node_modules/.package-lock.json +20 -0
  6. package/EvilSrc/node_modules/uglify-js/LICENSE +29 -0
  7. package/EvilSrc/node_modules/uglify-js/README.md +1311 -0
  8. package/EvilSrc/node_modules/uglify-js/bin/uglifyjs +553 -0
  9. package/EvilSrc/node_modules/uglify-js/lib/ast.js +2058 -0
  10. package/EvilSrc/node_modules/uglify-js/lib/compress.js +11653 -0
  11. package/EvilSrc/node_modules/uglify-js/lib/minify.js +268 -0
  12. package/EvilSrc/node_modules/uglify-js/lib/mozilla-ast.js +636 -0
  13. package/EvilSrc/node_modules/uglify-js/lib/output.js +1899 -0
  14. package/EvilSrc/node_modules/uglify-js/lib/parse.js +2534 -0
  15. package/EvilSrc/node_modules/uglify-js/lib/propmangle.js +254 -0
  16. package/EvilSrc/node_modules/uglify-js/lib/scope.js +828 -0
  17. package/EvilSrc/node_modules/uglify-js/lib/sourcemap.js +193 -0
  18. package/EvilSrc/node_modules/uglify-js/lib/transform.js +250 -0
  19. package/EvilSrc/node_modules/uglify-js/lib/utils.js +267 -0
  20. package/EvilSrc/node_modules/uglify-js/package.json +56 -0
  21. package/EvilSrc/node_modules/uglify-js/tools/domprops.html +456 -0
  22. package/EvilSrc/node_modules/uglify-js/tools/domprops.json +8325 -0
  23. package/EvilSrc/node_modules/uglify-js/tools/exports.js +8 -0
  24. package/EvilSrc/node_modules/uglify-js/tools/node.js +109 -0
  25. package/EvilSrc/node_modules/uglify-js/tools/tty.js +22 -0
  26. package/EvilSrc/package-lock.json +36 -0
  27. package/EvilSrc/package.json +16 -0
  28. package/LICENSE +22 -0
  29. package/package.json +13 -3
  30. package/README.md +0 -5
@@ -0,0 +1,636 @@
1
+ /***********************************************************************
2
+
3
+ A JavaScript tokenizer / parser / beautifier / compressor.
4
+ https://github.com/mishoo/UglifyJS
5
+
6
+ -------------------------------- (C) ---------------------------------
7
+
8
+ Author: Mihai Bazon
9
+ <mihai.bazon@gmail.com>
10
+ http://mihai.bazon.net/blog
11
+
12
+ Distributed under the BSD license:
13
+
14
+ Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
15
+
16
+ Redistribution and use in source and binary forms, with or without
17
+ modification, are permitted provided that the following conditions
18
+ are met:
19
+
20
+ * Redistributions of source code must retain the above
21
+ copyright notice, this list of conditions and the following
22
+ disclaimer.
23
+
24
+ * Redistributions in binary form must reproduce the above
25
+ copyright notice, this list of conditions and the following
26
+ disclaimer in the documentation and/or other materials
27
+ provided with the distribution.
28
+
29
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
30
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
32
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
33
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
34
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
35
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
36
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
38
+ TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
39
+ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40
+ SUCH DAMAGE.
41
+
42
+ ***********************************************************************/
43
+
44
+ "use strict";
45
+
46
+ (function() {
47
+ function normalize_directives(body) {
48
+ var in_directive = true;
49
+ for (var i = 0; i < body.length; i++) {
50
+ if (in_directive && body[i] instanceof AST_Statement && body[i].body instanceof AST_String) {
51
+ body[i] = new AST_Directive({
52
+ start: body[i].start,
53
+ end: body[i].end,
54
+ value: body[i].body.value
55
+ });
56
+ } else if (in_directive && !(body[i] instanceof AST_Statement && body[i].body instanceof AST_String)) {
57
+ in_directive = false;
58
+ }
59
+ }
60
+ return body;
61
+ }
62
+
63
+ var MOZ_TO_ME = {
64
+ Program: function(M) {
65
+ return new AST_Toplevel({
66
+ start: my_start_token(M),
67
+ end: my_end_token(M),
68
+ body: normalize_directives(M.body.map(from_moz))
69
+ });
70
+ },
71
+ FunctionDeclaration: function(M) {
72
+ return new AST_Defun({
73
+ start: my_start_token(M),
74
+ end: my_end_token(M),
75
+ name: from_moz(M.id),
76
+ argnames: M.params.map(from_moz),
77
+ body: normalize_directives(from_moz(M.body).body)
78
+ });
79
+ },
80
+ FunctionExpression: function(M) {
81
+ return new AST_Function({
82
+ start: my_start_token(M),
83
+ end: my_end_token(M),
84
+ name: from_moz(M.id),
85
+ argnames: M.params.map(from_moz),
86
+ body: normalize_directives(from_moz(M.body).body)
87
+ });
88
+ },
89
+ ExpressionStatement: function(M) {
90
+ return new AST_SimpleStatement({
91
+ start: my_start_token(M),
92
+ end: my_end_token(M),
93
+ body: from_moz(M.expression)
94
+ });
95
+ },
96
+ TryStatement: function(M) {
97
+ var handlers = M.handlers || [M.handler];
98
+ if (handlers.length > 1 || M.guardedHandlers && M.guardedHandlers.length) {
99
+ throw new Error("Multiple catch clauses are not supported.");
100
+ }
101
+ return new AST_Try({
102
+ start : my_start_token(M),
103
+ end : my_end_token(M),
104
+ body : from_moz(M.block).body,
105
+ bcatch : from_moz(handlers[0]),
106
+ bfinally : M.finalizer ? new AST_Finally(from_moz(M.finalizer)) : null
107
+ });
108
+ },
109
+ Property: function(M) {
110
+ var key = M.key;
111
+ var args = {
112
+ start : my_start_token(key),
113
+ end : my_end_token(M.value),
114
+ key : "" + key[key.type == "Identifier" ? "name" : "value"],
115
+ value : from_moz(M.value)
116
+ };
117
+ if (M.kind == "init") return new AST_ObjectKeyVal(args);
118
+ args.value = new AST_Accessor(args.value);
119
+ if (M.kind == "get") return new AST_ObjectGetter(args);
120
+ if (M.kind == "set") return new AST_ObjectSetter(args);
121
+ },
122
+ ArrayExpression: function(M) {
123
+ return new AST_Array({
124
+ start : my_start_token(M),
125
+ end : my_end_token(M),
126
+ elements : M.elements.map(function(elem) {
127
+ return elem === null ? new AST_Hole() : from_moz(elem);
128
+ })
129
+ });
130
+ },
131
+ ObjectExpression: function(M) {
132
+ return new AST_Object({
133
+ start : my_start_token(M),
134
+ end : my_end_token(M),
135
+ properties : M.properties.map(function(prop) {
136
+ prop.type = "Property";
137
+ return from_moz(prop)
138
+ })
139
+ });
140
+ },
141
+ SequenceExpression: function(M) {
142
+ return new AST_Sequence({
143
+ start : my_start_token(M),
144
+ end : my_end_token(M),
145
+ expressions: M.expressions.map(from_moz)
146
+ });
147
+ },
148
+ MemberExpression: function(M) {
149
+ return new (M.computed ? AST_Sub : AST_Dot)({
150
+ start : my_start_token(M),
151
+ end : my_end_token(M),
152
+ property : M.computed ? from_moz(M.property) : M.property.name,
153
+ expression : from_moz(M.object)
154
+ });
155
+ },
156
+ SwitchCase: function(M) {
157
+ return new (M.test ? AST_Case : AST_Default)({
158
+ start : my_start_token(M),
159
+ end : my_end_token(M),
160
+ expression : from_moz(M.test),
161
+ body : M.consequent.map(from_moz)
162
+ });
163
+ },
164
+ VariableDeclaration: function(M) {
165
+ return new AST_Var({
166
+ start : my_start_token(M),
167
+ end : my_end_token(M),
168
+ definitions : M.declarations.map(from_moz)
169
+ });
170
+ },
171
+ Literal: function(M) {
172
+ var val = M.value, args = {
173
+ start : my_start_token(M),
174
+ end : my_end_token(M)
175
+ };
176
+ if (val === null) return new AST_Null(args);
177
+ var rx = M.regex;
178
+ if (rx && rx.pattern) {
179
+ // RegExpLiteral as per ESTree AST spec
180
+ args.value = new RegExp(rx.pattern, rx.flags);
181
+ args.value.raw_source = rx.pattern;
182
+ return new AST_RegExp(args);
183
+ } else if (rx) {
184
+ // support legacy RegExp
185
+ args.value = M.regex && M.raw ? M.raw : val;
186
+ return new AST_RegExp(args);
187
+ }
188
+ switch (typeof val) {
189
+ case "string":
190
+ args.value = val;
191
+ return new AST_String(args);
192
+ case "number":
193
+ args.value = val;
194
+ return new AST_Number(args);
195
+ case "boolean":
196
+ return new (val ? AST_True : AST_False)(args);
197
+ }
198
+ },
199
+ Identifier: function(M) {
200
+ var p = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 2];
201
+ return new ( p.type == "LabeledStatement" ? AST_Label
202
+ : p.type == "VariableDeclarator" && p.id === M ? AST_SymbolVar
203
+ : p.type == "FunctionExpression" ? (p.id === M ? AST_SymbolLambda : AST_SymbolFunarg)
204
+ : p.type == "FunctionDeclaration" ? (p.id === M ? AST_SymbolDefun : AST_SymbolFunarg)
205
+ : p.type == "CatchClause" ? AST_SymbolCatch
206
+ : p.type == "BreakStatement" || p.type == "ContinueStatement" ? AST_LabelRef
207
+ : AST_SymbolRef)({
208
+ start : my_start_token(M),
209
+ end : my_end_token(M),
210
+ name : M.name
211
+ });
212
+ },
213
+ ThisExpression: function(M) {
214
+ return new AST_This({
215
+ start : my_start_token(M),
216
+ end : my_end_token(M),
217
+ name : "this",
218
+ });
219
+ },
220
+ };
221
+
222
+ MOZ_TO_ME.UpdateExpression =
223
+ MOZ_TO_ME.UnaryExpression = function To_Moz_Unary(M) {
224
+ var prefix = "prefix" in M ? M.prefix
225
+ : M.type == "UnaryExpression" ? true : false;
226
+ return new (prefix ? AST_UnaryPrefix : AST_UnaryPostfix)({
227
+ start : my_start_token(M),
228
+ end : my_end_token(M),
229
+ operator : M.operator,
230
+ expression : from_moz(M.argument)
231
+ });
232
+ };
233
+
234
+ map("EmptyStatement", AST_EmptyStatement);
235
+ map("BlockStatement", AST_BlockStatement, "body@body");
236
+ map("IfStatement", AST_If, "test>condition, consequent>body, alternate>alternative");
237
+ map("LabeledStatement", AST_LabeledStatement, "label>label, body>body");
238
+ map("BreakStatement", AST_Break, "label>label");
239
+ map("ContinueStatement", AST_Continue, "label>label");
240
+ map("WithStatement", AST_With, "object>expression, body>body");
241
+ map("SwitchStatement", AST_Switch, "discriminant>expression, cases@body");
242
+ map("ReturnStatement", AST_Return, "argument>value");
243
+ map("ThrowStatement", AST_Throw, "argument>value");
244
+ map("WhileStatement", AST_While, "test>condition, body>body");
245
+ map("DoWhileStatement", AST_Do, "test>condition, body>body");
246
+ map("ForStatement", AST_For, "init>init, test>condition, update>step, body>body");
247
+ map("ForInStatement", AST_ForIn, "left>init, right>object, body>body");
248
+ map("DebuggerStatement", AST_Debugger);
249
+ map("VariableDeclarator", AST_VarDef, "id>name, init>value");
250
+ map("CatchClause", AST_Catch, "param>argname, body%body");
251
+
252
+ map("BinaryExpression", AST_Binary, "operator=operator, left>left, right>right");
253
+ map("LogicalExpression", AST_Binary, "operator=operator, left>left, right>right");
254
+ map("AssignmentExpression", AST_Assign, "operator=operator, left>left, right>right");
255
+ map("ConditionalExpression", AST_Conditional, "test>condition, consequent>consequent, alternate>alternative");
256
+ map("NewExpression", AST_New, "callee>expression, arguments@args");
257
+ map("CallExpression", AST_Call, "callee>expression, arguments@args");
258
+
259
+ def_to_moz(AST_Toplevel, function To_Moz_Program(M) {
260
+ return to_moz_scope("Program", M);
261
+ });
262
+
263
+ def_to_moz(AST_Defun, function To_Moz_FunctionDeclaration(M) {
264
+ return {
265
+ type: "FunctionDeclaration",
266
+ id: to_moz(M.name),
267
+ params: M.argnames.map(to_moz),
268
+ body: to_moz_scope("BlockStatement", M)
269
+ }
270
+ });
271
+
272
+ def_to_moz(AST_Function, function To_Moz_FunctionExpression(M) {
273
+ return {
274
+ type: "FunctionExpression",
275
+ id: to_moz(M.name),
276
+ params: M.argnames.map(to_moz),
277
+ body: to_moz_scope("BlockStatement", M)
278
+ }
279
+ });
280
+
281
+ def_to_moz(AST_Directive, function To_Moz_Directive(M) {
282
+ return {
283
+ type: "ExpressionStatement",
284
+ expression: {
285
+ type: "Literal",
286
+ value: M.value
287
+ }
288
+ };
289
+ });
290
+
291
+ def_to_moz(AST_SimpleStatement, function To_Moz_ExpressionStatement(M) {
292
+ return {
293
+ type: "ExpressionStatement",
294
+ expression: to_moz(M.body)
295
+ };
296
+ });
297
+
298
+ def_to_moz(AST_SwitchBranch, function To_Moz_SwitchCase(M) {
299
+ return {
300
+ type: "SwitchCase",
301
+ test: to_moz(M.expression),
302
+ consequent: M.body.map(to_moz)
303
+ };
304
+ });
305
+
306
+ def_to_moz(AST_Try, function To_Moz_TryStatement(M) {
307
+ return {
308
+ type: "TryStatement",
309
+ block: to_moz_block(M),
310
+ handler: to_moz(M.bcatch),
311
+ guardedHandlers: [],
312
+ finalizer: to_moz(M.bfinally)
313
+ };
314
+ });
315
+
316
+ def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
317
+ return {
318
+ type: "CatchClause",
319
+ param: to_moz(M.argname),
320
+ guard: null,
321
+ body: to_moz_block(M)
322
+ };
323
+ });
324
+
325
+ def_to_moz(AST_Definitions, function To_Moz_VariableDeclaration(M) {
326
+ return {
327
+ type: "VariableDeclaration",
328
+ kind: "var",
329
+ declarations: M.definitions.map(to_moz)
330
+ };
331
+ });
332
+
333
+ def_to_moz(AST_Sequence, function To_Moz_SequenceExpression(M) {
334
+ return {
335
+ type: "SequenceExpression",
336
+ expressions: M.expressions.map(to_moz)
337
+ };
338
+ });
339
+
340
+ def_to_moz(AST_PropAccess, function To_Moz_MemberExpression(M) {
341
+ var isComputed = M instanceof AST_Sub;
342
+ return {
343
+ type: "MemberExpression",
344
+ object: to_moz(M.expression),
345
+ computed: isComputed,
346
+ property: isComputed ? to_moz(M.property) : {type: "Identifier", name: M.property}
347
+ };
348
+ });
349
+
350
+ def_to_moz(AST_Unary, function To_Moz_Unary(M) {
351
+ return {
352
+ type: M.operator == "++" || M.operator == "--" ? "UpdateExpression" : "UnaryExpression",
353
+ operator: M.operator,
354
+ prefix: M instanceof AST_UnaryPrefix,
355
+ argument: to_moz(M.expression)
356
+ };
357
+ });
358
+
359
+ def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
360
+ return {
361
+ type: M.operator == "&&" || M.operator == "||" ? "LogicalExpression" : "BinaryExpression",
362
+ left: to_moz(M.left),
363
+ operator: M.operator,
364
+ right: to_moz(M.right)
365
+ };
366
+ });
367
+
368
+ def_to_moz(AST_Array, function To_Moz_ArrayExpression(M) {
369
+ return {
370
+ type: "ArrayExpression",
371
+ elements: M.elements.map(to_moz)
372
+ };
373
+ });
374
+
375
+ def_to_moz(AST_Object, function To_Moz_ObjectExpression(M) {
376
+ return {
377
+ type: "ObjectExpression",
378
+ properties: M.properties.map(to_moz)
379
+ };
380
+ });
381
+
382
+ def_to_moz(AST_ObjectProperty, function To_Moz_Property(M) {
383
+ var key = {
384
+ type: "Literal",
385
+ value: M.key
386
+ };
387
+ var kind;
388
+ if (M instanceof AST_ObjectKeyVal) {
389
+ kind = "init";
390
+ } else
391
+ if (M instanceof AST_ObjectGetter) {
392
+ kind = "get";
393
+ } else
394
+ if (M instanceof AST_ObjectSetter) {
395
+ kind = "set";
396
+ }
397
+ return {
398
+ type: "Property",
399
+ kind: kind,
400
+ key: key,
401
+ value: to_moz(M.value)
402
+ };
403
+ });
404
+
405
+ def_to_moz(AST_Symbol, function To_Moz_Identifier(M) {
406
+ var def = M.definition();
407
+ return {
408
+ type: "Identifier",
409
+ name: def && def.mangled_name || M.name
410
+ };
411
+ });
412
+
413
+ def_to_moz(AST_This, function To_Moz_ThisExpression() {
414
+ return { type: "ThisExpression" };
415
+ });
416
+
417
+ def_to_moz(AST_RegExp, function To_Moz_RegExpLiteral(M) {
418
+ var flags = M.value.toString().match(/[gimuy]*$/)[0];
419
+ var value = "/" + M.value.raw_source + "/" + flags;
420
+ return {
421
+ type: "Literal",
422
+ value: value,
423
+ raw: value,
424
+ regex: {
425
+ pattern: M.value.raw_source,
426
+ flags: flags
427
+ }
428
+ };
429
+ });
430
+
431
+ def_to_moz(AST_Constant, function To_Moz_Literal(M) {
432
+ var value = M.value;
433
+ if (typeof value === 'number' && (value < 0 || (value === 0 && 1 / value < 0))) {
434
+ return {
435
+ type: "UnaryExpression",
436
+ operator: "-",
437
+ prefix: true,
438
+ argument: {
439
+ type: "Literal",
440
+ value: -value,
441
+ raw: M.start.raw
442
+ }
443
+ };
444
+ }
445
+ return {
446
+ type: "Literal",
447
+ value: value,
448
+ raw: M.start.raw
449
+ };
450
+ });
451
+
452
+ def_to_moz(AST_Atom, function To_Moz_Atom(M) {
453
+ return {
454
+ type: "Identifier",
455
+ name: String(M.value)
456
+ };
457
+ });
458
+
459
+ AST_Boolean.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
460
+ AST_Null.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
461
+ AST_Hole.DEFMETHOD("to_mozilla_ast", function To_Moz_ArrayHole() { return null });
462
+
463
+ AST_Block.DEFMETHOD("to_mozilla_ast", AST_BlockStatement.prototype.to_mozilla_ast);
464
+ AST_Lambda.DEFMETHOD("to_mozilla_ast", AST_Function.prototype.to_mozilla_ast);
465
+
466
+ /* -----[ tools ]----- */
467
+
468
+ function raw_token(moznode) {
469
+ if (moznode.type == "Literal") {
470
+ return moznode.raw != null ? moznode.raw : moznode.value + "";
471
+ }
472
+ }
473
+
474
+ function my_start_token(moznode) {
475
+ var loc = moznode.loc, start = loc && loc.start;
476
+ var range = moznode.range;
477
+ return new AST_Token({
478
+ file : loc && loc.source,
479
+ line : start && start.line,
480
+ col : start && start.column,
481
+ pos : range ? range[0] : moznode.start,
482
+ endline : start && start.line,
483
+ endcol : start && start.column,
484
+ endpos : range ? range[0] : moznode.start,
485
+ raw : raw_token(moznode),
486
+ });
487
+ }
488
+
489
+ function my_end_token(moznode) {
490
+ var loc = moznode.loc, end = loc && loc.end;
491
+ var range = moznode.range;
492
+ return new AST_Token({
493
+ file : loc && loc.source,
494
+ line : end && end.line,
495
+ col : end && end.column,
496
+ pos : range ? range[1] : moznode.end,
497
+ endline : end && end.line,
498
+ endcol : end && end.column,
499
+ endpos : range ? range[1] : moznode.end,
500
+ raw : raw_token(moznode),
501
+ });
502
+ }
503
+
504
+ function map(moztype, mytype, propmap) {
505
+ var moz_to_me = "function From_Moz_" + moztype + "(M){\n";
506
+ moz_to_me += "return new U2." + mytype.name + "({\n" +
507
+ "start: my_start_token(M),\n" +
508
+ "end: my_end_token(M)";
509
+
510
+ var me_to_moz = "function To_Moz_" + moztype + "(M){\n";
511
+ me_to_moz += "return {\n" +
512
+ "type: " + JSON.stringify(moztype);
513
+
514
+ if (propmap) propmap.split(/\s*,\s*/).forEach(function(prop) {
515
+ var m = /([a-z0-9$_]+)(=|@|>|%)([a-z0-9$_]+)/i.exec(prop);
516
+ if (!m) throw new Error("Can't understand property map: " + prop);
517
+ var moz = m[1], how = m[2], my = m[3];
518
+ moz_to_me += ",\n" + my + ": ";
519
+ me_to_moz += ",\n" + moz + ": ";
520
+ switch (how) {
521
+ case "@":
522
+ moz_to_me += "M." + moz + ".map(from_moz)";
523
+ me_to_moz += "M." + my + ".map(to_moz)";
524
+ break;
525
+ case ">":
526
+ moz_to_me += "from_moz(M." + moz + ")";
527
+ me_to_moz += "to_moz(M." + my + ")";
528
+ break;
529
+ case "=":
530
+ moz_to_me += "M." + moz;
531
+ me_to_moz += "M." + my;
532
+ break;
533
+ case "%":
534
+ moz_to_me += "from_moz(M." + moz + ").body";
535
+ me_to_moz += "to_moz_block(M)";
536
+ break;
537
+ default:
538
+ throw new Error("Can't understand operator in propmap: " + prop);
539
+ }
540
+ });
541
+
542
+ moz_to_me += "\n})\n}";
543
+ me_to_moz += "\n}\n}";
544
+
545
+ //moz_to_me = parse(moz_to_me).print_to_string({ beautify: true });
546
+ //me_to_moz = parse(me_to_moz).print_to_string({ beautify: true });
547
+ //console.log(moz_to_me);
548
+
549
+ moz_to_me = new Function("U2", "my_start_token", "my_end_token", "from_moz", "return(" + moz_to_me + ")")(
550
+ exports, my_start_token, my_end_token, from_moz
551
+ );
552
+ me_to_moz = new Function("to_moz", "to_moz_block", "to_moz_scope", "return(" + me_to_moz + ")")(
553
+ to_moz, to_moz_block, to_moz_scope
554
+ );
555
+ MOZ_TO_ME[moztype] = moz_to_me;
556
+ def_to_moz(mytype, me_to_moz);
557
+ }
558
+
559
+ var FROM_MOZ_STACK = null;
560
+
561
+ function from_moz(node) {
562
+ FROM_MOZ_STACK.push(node);
563
+ var ret = node != null ? MOZ_TO_ME[node.type](node) : null;
564
+ FROM_MOZ_STACK.pop();
565
+ return ret;
566
+ }
567
+
568
+ AST_Node.from_mozilla_ast = function(node) {
569
+ var save_stack = FROM_MOZ_STACK;
570
+ FROM_MOZ_STACK = [];
571
+ var ast = from_moz(node);
572
+ FROM_MOZ_STACK = save_stack;
573
+ ast.walk(new TreeWalker(function(node) {
574
+ if (node instanceof AST_LabelRef) {
575
+ for (var level = 0, parent; parent = this.parent(level); level++) {
576
+ if (parent instanceof AST_Scope) break;
577
+ if (parent instanceof AST_LabeledStatement && parent.label.name == node.name) {
578
+ node.thedef = parent.label;
579
+ break;
580
+ }
581
+ }
582
+ if (!node.thedef) {
583
+ var s = node.start;
584
+ js_error("Undefined label " + node.name, s.file, s.line, s.col, s.pos);
585
+ }
586
+ }
587
+ }));
588
+ return ast;
589
+ };
590
+
591
+ function set_moz_loc(mynode, moznode, myparent) {
592
+ var start = mynode.start;
593
+ var end = mynode.end;
594
+ if (start.pos != null && end.endpos != null) {
595
+ moznode.range = [start.pos, end.endpos];
596
+ }
597
+ if (start.line) {
598
+ moznode.loc = {
599
+ start: {line: start.line, column: start.col},
600
+ end: end.endline ? {line: end.endline, column: end.endcol} : null
601
+ };
602
+ if (start.file) {
603
+ moznode.loc.source = start.file;
604
+ }
605
+ }
606
+ return moznode;
607
+ }
608
+
609
+ function def_to_moz(mytype, handler) {
610
+ mytype.DEFMETHOD("to_mozilla_ast", function() {
611
+ return set_moz_loc(this, handler(this));
612
+ });
613
+ }
614
+
615
+ function to_moz(node) {
616
+ return node != null ? node.to_mozilla_ast() : null;
617
+ }
618
+
619
+ function to_moz_block(node) {
620
+ return {
621
+ type: "BlockStatement",
622
+ body: node.body.map(to_moz)
623
+ };
624
+ }
625
+
626
+ function to_moz_scope(type, node) {
627
+ var body = node.body.map(to_moz);
628
+ if (node.body[0] instanceof AST_SimpleStatement && node.body[0].body instanceof AST_String) {
629
+ body.unshift(to_moz(new AST_EmptyStatement(node.body[0])));
630
+ }
631
+ return {
632
+ type: type,
633
+ body: body
634
+ };
635
+ }
636
+ })();