uglifier 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of uglifier might be problematic. Click here for more details.

@@ -6,7 +6,6 @@ rvm:
6
6
  before_script: "git submodule update --init --recursive"
7
7
  env:
8
8
  - EXECJS_RUNTIME=RubyRacer
9
- - EXECJS_RUNTIME=Mustang
10
9
  - EXECJS_RUNTIME=RubyRhino
11
10
  matrix:
12
11
  exclude:
@@ -18,5 +17,3 @@ matrix:
18
17
  env: EXECJS_RUNTIME=RubyRhino
19
18
  - rvm: jruby
20
19
  env: EXECJS_RUNTIME=RubyRacer
21
- - rvm: jruby
22
- env: EXECJS_RUNTIME=Mustang
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gem "execjs", ">=0.3.0"
4
- gem "multi_json", ">= 1.0.2"
4
+ gem "multi_json", "~> 1.3"
5
5
 
6
6
  # Depend on defined ExecJS runtime
7
7
  execjs_runtimes = {
data/README.md CHANGED
@@ -8,7 +8,7 @@ Uglifier is available as ruby gem.
8
8
 
9
9
  $ gem install uglifier
10
10
 
11
- Ensure that your environment has a JavaScript interpreter supported by ExecJS[https://github.com/sstephenson/execjs]. Usually, installing therubyracer gem is the best alternative.
11
+ Ensure that your environment has a JavaScript interpreter supported by [ExecJS](https://github.com/sstephenson/execjs). Usually, installing therubyracer gem is the best alternative.
12
12
 
13
13
  ## Usage
14
14
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.4
1
+ 1.2.5
@@ -61,7 +61,7 @@ class Uglifier
61
61
 
62
62
  js = []
63
63
  js << "var result = '';"
64
- js << "var source = #{MultiJson.encode(source)};"
64
+ js << "var source = #{MultiJson.dump(source)};"
65
65
  js << "var ast = UglifyJS.parser.parse(source);"
66
66
 
67
67
  if @options[:lift_vars]
@@ -78,19 +78,17 @@ class Uglifier
78
78
  JS
79
79
  end
80
80
 
81
- if @options[:mangle]
82
- js << "ast = UglifyJS.uglify.ast_mangle(ast, #{MultiJson.encode(mangle_options)});"
83
- end
81
+ js << "ast = UglifyJS.uglify.ast_mangle(ast, #{MultiJson.dump(mangle_options)});"
84
82
 
85
83
  if @options[:squeeze]
86
- js << "ast = UglifyJS.uglify.ast_squeeze(ast, #{MultiJson.encode(squeeze_options)});"
84
+ js << "ast = UglifyJS.uglify.ast_squeeze(ast, #{MultiJson.dump(squeeze_options)});"
87
85
  end
88
86
 
89
87
  if @options[:unsafe]
90
88
  js << "ast = UglifyJS.uglify.ast_squeeze_more(ast);"
91
89
  end
92
90
 
93
- js << "result += UglifyJS.uglify.gen_code(ast, #{MultiJson.encode(gen_code_options)});"
91
+ js << "result += UglifyJS.uglify.gen_code(ast, #{MultiJson.dump(gen_code_options)});"
94
92
 
95
93
  if !@options[:beautify] && @options[:max_line_length]
96
94
  js << "result = UglifyJS.uglify.split_lines(result, #{@options[:max_line_length].to_i})"
@@ -106,6 +104,7 @@ class Uglifier
106
104
 
107
105
  def mangle_options
108
106
  {
107
+ "mangle" => @options[:mangle],
109
108
  "toplevel" => @options[:toplevel],
110
109
  "defines" => {},
111
110
  "except" => @options[:except],
@@ -2,19 +2,19 @@
2
2
  (function(/*! Stitch !*/) {
3
3
  if (!this.require) {
4
4
  var modules = {}, cache = {}, require = function(name, root) {
5
- var module = cache[name], path = expand(root, name), fn;
5
+ var path = expand(root, name), module = cache[path], fn;
6
6
  if (module) {
7
- return module;
7
+ return module.exports;
8
8
  } else if (fn = modules[path] || modules[path = expand(path, './index')]) {
9
- module = {id: name, exports: {}};
9
+ module = {id: path, exports: {}};
10
10
  try {
11
- cache[name] = module.exports;
11
+ cache[path] = module;
12
12
  fn(module.exports, function(name) {
13
13
  return require(name, dirname(path));
14
14
  }, module);
15
- return cache[name] = module.exports;
15
+ return module.exports;
16
16
  } catch (err) {
17
- delete cache[name];
17
+ delete cache[path];
18
18
  throw err;
19
19
  }
20
20
  } else {
@@ -1196,8 +1196,7 @@ exports['ast_consolidate'] = function(oAbstractSyntaxTree) {
1196
1196
  oScope = bIsGlobal ? oSyntacticCodeUnit.scope : oSourceElements.scope;
1197
1197
  // Skip a Directive Prologue.
1198
1198
  while (nAfterDirectivePrologue < oSourceElements.length &&
1199
- 'stat' === oSourceElements[nAfterDirectivePrologue][0] &&
1200
- 'string' === oSourceElements[nAfterDirectivePrologue][1][0]) {
1199
+ 'directive' === oSourceElements[nAfterDirectivePrologue][0]) {
1201
1200
  nAfterDirectivePrologue += 1;
1202
1201
  aSourceElementsData.push(null);
1203
1202
  }
@@ -1260,1384 +1259,6 @@ exports['ast_consolidate'] = function(oAbstractSyntaxTree) {
1260
1259
  };
1261
1260
  /*jshint sub:false */
1262
1261
 
1263
-
1264
- if (require.main === module) {
1265
- (function() {
1266
- 'use strict';
1267
- /*jshint bitwise:true, curly:true, eqeqeq:true, forin:true, immed:true,
1268
- latedef:true, newcap:true, noarge:true, noempty:true, nonew:true,
1269
- onevar:true, plusplus:true, regexp:true, undef:true, strict:true,
1270
- sub:false, trailing:true */
1271
-
1272
- var _,
1273
- /**
1274
- * NodeJS module for unit testing.
1275
- * @namespace
1276
- * @type {!TAssert}
1277
- * @see http://nodejs.org/docs/v0.6.10/api/all.html#assert
1278
- */
1279
- oAssert = (/** @type {!TAssert} */ require('assert')),
1280
- /**
1281
- * The parser of ECMA-262 found in UglifyJS.
1282
- * @namespace
1283
- * @type {!TParser}
1284
- */
1285
- oParser = (/** @type {!TParser} */ require('./parse-js')),
1286
- /**
1287
- * The processor of <abbr title="abstract syntax tree">AST</abbr>s
1288
- * found in UglifyJS.
1289
- * @namespace
1290
- * @type {!TProcessor}
1291
- */
1292
- oProcessor = (/** @type {!TProcessor} */ require('./process')),
1293
- /**
1294
- * An instance of an object that allows the traversal of an <abbr
1295
- * title="abstract syntax tree">AST</abbr>.
1296
- * @type {!TWalker}
1297
- */
1298
- oWalker,
1299
- /**
1300
- * A collection of functions for the removal of the scope information
1301
- * during the traversal of an <abbr title="abstract syntax tree"
1302
- * >AST</abbr>.
1303
- * @namespace
1304
- * @type {!Object.<string, function(...[*])>}
1305
- */
1306
- oWalkersPurifiers = {
1307
- /**#nocode+*/ // JsDoc Toolkit 2.4.0 hides some of the keys.
1308
- /**
1309
- * Deletes the scope information from the branch of the abstract
1310
- * syntax tree representing the encountered function declaration.
1311
- * @param {string} sIdentifier The identifier of the function.
1312
- * @param {!Array.<string>} aFormalParameterList Formal parameters.
1313
- * @param {!TSyntacticCodeUnit} oFunctionBody Function code.
1314
- */
1315
- 'defun': function(
1316
- sIdentifier,
1317
- aFormalParameterList,
1318
- oFunctionBody) {
1319
- delete oFunctionBody.scope;
1320
- },
1321
- /**
1322
- * Deletes the scope information from the branch of the abstract
1323
- * syntax tree representing the encountered function expression.
1324
- * @param {?string} sIdentifier The optional identifier of the
1325
- * function.
1326
- * @param {!Array.<string>} aFormalParameterList Formal parameters.
1327
- * @param {!TSyntacticCodeUnit} oFunctionBody Function code.
1328
- */
1329
- 'function': function(
1330
- sIdentifier,
1331
- aFormalParameterList,
1332
- oFunctionBody) {
1333
- delete oFunctionBody.scope;
1334
- }
1335
- /**#nocode-*/ // JsDoc Toolkit 2.4.0 hides some of the keys.
1336
- },
1337
- /**
1338
- * Initiates the traversal of a source element.
1339
- * @param {!TWalker} oWalker An instance of an object that allows the
1340
- * traversal of an abstract syntax tree.
1341
- * @param {!TSyntacticCodeUnit} oSourceElement A source element from
1342
- * which the traversal should commence.
1343
- * @return {function(): !TSyntacticCodeUnit} A function that is able to
1344
- * initiate the traversal from a given source element.
1345
- */
1346
- cContext = function(oWalker, oSourceElement) {
1347
- /**
1348
- * @return {!TSyntacticCodeUnit} A function that is able to
1349
- * initiate the traversal from a given source element.
1350
- */
1351
- var fLambda = function() {
1352
- return oWalker.walk(oSourceElement);
1353
- };
1354
-
1355
- return fLambda;
1356
- },
1357
- /**
1358
- * A record consisting of configuration for the code generation phase.
1359
- * @type {!Object}
1360
- */
1361
- oCodeGenerationOptions = {
1362
- beautify: true
1363
- },
1364
- /**
1365
- * Tests whether consolidation of an ECMAScript program yields expected
1366
- * results.
1367
- * @param {{
1368
- * sTitle: string,
1369
- * sInput: string,
1370
- * sOutput: string
1371
- * }} oUnitTest A record consisting of data about a unit test: its
1372
- * name, an ECMAScript program, and, if consolidation is to take
1373
- * place, the resulting ECMAScript program.
1374
- */
1375
- cAssert = function(oUnitTest) {
1376
- var _,
1377
- /**
1378
- * An array-like object representing the <abbr title=
1379
- * "abstract syntax tree">AST</abbr> obtained after consolidation.
1380
- * @type {!TSyntacticCodeUnit}
1381
- */
1382
- oSyntacticCodeUnitActual =
1383
- exports.ast_consolidate(oParser.parse(oUnitTest.sInput)),
1384
- /**
1385
- * An array-like object representing the expected <abbr title=
1386
- * "abstract syntax tree">AST</abbr>.
1387
- * @type {!TSyntacticCodeUnit}
1388
- */
1389
- oSyntacticCodeUnitExpected = oParser.parse(
1390
- oUnitTest.hasOwnProperty('sOutput') ?
1391
- oUnitTest.sOutput : oUnitTest.sInput);
1392
-
1393
- delete oSyntacticCodeUnitActual.scope;
1394
- oWalker = oProcessor.ast_walker();
1395
- oWalker.with_walkers(
1396
- oWalkersPurifiers,
1397
- cContext(oWalker, oSyntacticCodeUnitActual));
1398
- try {
1399
- oAssert.deepEqual(
1400
- oSyntacticCodeUnitActual,
1401
- oSyntacticCodeUnitExpected);
1402
- } catch (oException) {
1403
- console.error(
1404
- '########## A unit test has failed.\n' +
1405
- oUnitTest.sTitle + '\n' +
1406
- '##### actual code (' +
1407
- oProcessor.gen_code(oSyntacticCodeUnitActual).length +
1408
- ' bytes)\n' +
1409
- oProcessor.gen_code(
1410
- oSyntacticCodeUnitActual,
1411
- oCodeGenerationOptions) + '\n' +
1412
- '##### expected code (' +
1413
- oProcessor.gen_code(oSyntacticCodeUnitExpected).length +
1414
- ' bytes)\n' +
1415
- oProcessor.gen_code(
1416
- oSyntacticCodeUnitExpected,
1417
- oCodeGenerationOptions));
1418
- }
1419
- };
1420
-
1421
- [
1422
- // 7.6.1 Reserved Words.
1423
- {
1424
- sTitle:
1425
- 'Omission of keywords while choosing an identifier name.',
1426
- sInput:
1427
- '(function() {' +
1428
- ' var a, b, c, d, e, f, g, h, i, j, k, l, m,' +
1429
- ' n, o, p, q, r, s, t, u, v, w, x, y, z,' +
1430
- ' A, B, C, D, E, F, G, H, I, J, K, L, M,' +
1431
- ' N, O, P, Q, R, S, T, U, V, W, X, Y, Z,' +
1432
- ' $, _,' +
1433
- ' aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am,' +
1434
- ' an, ao, ap, aq, ar, as, at, au, av, aw, ax, ay, az,' +
1435
- ' aA, aB, aC, aD, aE, aF, aG, aH, aI, aJ, aK, aL, aM,' +
1436
- ' aN, aO, aP, aQ, aR, aS, aT, aU, aV, aW, aX, aY, aZ,' +
1437
- ' a$, a_,' +
1438
- ' ba, bb, bc, bd, be, bf, bg, bh, bi, bj, bk, bl, bm,' +
1439
- ' bn, bo, bp, bq, br, bs, bt, bu, bv, bw, bx, by, bz,' +
1440
- ' bA, bB, bC, bD, bE, bF, bG, bH, bI, bJ, bK, bL, bM,' +
1441
- ' bN, bO, bP, bQ, bR, bS, bT, bU, bV, bW, bX, bY, bZ,' +
1442
- ' b$, b_,' +
1443
- ' ca, cb, cc, cd, ce, cf, cg, ch, ci, cj, ck, cl, cm,' +
1444
- ' cn, co, cp, cq, cr, cs, ct, cu, cv, cw, cx, cy, cz,' +
1445
- ' cA, cB, cC, cD, cE, cF, cG, cH, cI, cJ, cK, cL, cM,' +
1446
- ' cN, cO, cP, cQ, cR, cS, cT, cU, cV, cW, cX, cY, cZ,' +
1447
- ' c$, c_,' +
1448
- ' da, db, dc, dd, de, df, dg, dh, di, dj, dk, dl, dm,' +
1449
- ' dn, dq, dr, ds, dt, du, dv, dw, dx, dy, dz,' +
1450
- ' dA, dB, dC, dD, dE, dF, dG, dH, dI, dJ, dK, dL, dM,' +
1451
- ' dN, dO, dP, dQ, dR, dS, dT, dU, dV, dW, dX, dY, dZ,' +
1452
- ' d$, d_;' +
1453
- ' void ["abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",' +
1454
- ' "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"];' +
1455
- '}());',
1456
- sOutput:
1457
- '(function() {' +
1458
- ' var dp =' +
1459
- ' "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",' +
1460
- ' a, b, c, d, e, f, g, h, i, j, k, l, m,' +
1461
- ' n, o, p, q, r, s, t, u, v, w, x, y, z,' +
1462
- ' A, B, C, D, E, F, G, H, I, J, K, L, M,' +
1463
- ' N, O, P, Q, R, S, T, U, V, W, X, Y, Z,' +
1464
- ' $, _,' +
1465
- ' aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am,' +
1466
- ' an, ao, ap, aq, ar, as, at, au, av, aw, ax, ay, az,' +
1467
- ' aA, aB, aC, aD, aE, aF, aG, aH, aI, aJ, aK, aL, aM,' +
1468
- ' aN, aO, aP, aQ, aR, aS, aT, aU, aV, aW, aX, aY, aZ,' +
1469
- ' a$, a_,' +
1470
- ' ba, bb, bc, bd, be, bf, bg, bh, bi, bj, bk, bl, bm,' +
1471
- ' bn, bo, bp, bq, br, bs, bt, bu, bv, bw, bx, by, bz,' +
1472
- ' bA, bB, bC, bD, bE, bF, bG, bH, bI, bJ, bK, bL, bM,' +
1473
- ' bN, bO, bP, bQ, bR, bS, bT, bU, bV, bW, bX, bY, bZ,' +
1474
- ' b$, b_,' +
1475
- ' ca, cb, cc, cd, ce, cf, cg, ch, ci, cj, ck, cl, cm,' +
1476
- ' cn, co, cp, cq, cr, cs, ct, cu, cv, cw, cx, cy, cz,' +
1477
- ' cA, cB, cC, cD, cE, cF, cG, cH, cI, cJ, cK, cL, cM,' +
1478
- ' cN, cO, cP, cQ, cR, cS, cT, cU, cV, cW, cX, cY, cZ,' +
1479
- ' c$, c_,' +
1480
- ' da, db, dc, dd, de, df, dg, dh, di, dj, dk, dl, dm,' +
1481
- ' dn, dq, dr, ds, dt, du, dv, dw, dx, dy, dz,' +
1482
- ' dA, dB, dC, dD, dE, dF, dG, dH, dI, dJ, dK, dL, dM,' +
1483
- ' dN, dO, dP, dQ, dR, dS, dT, dU, dV, dW, dX, dY, dZ,' +
1484
- ' d$, d_;' +
1485
- ' void [dp, dp];' +
1486
- '}());'
1487
- },
1488
- // 7.8.1 Null Literals.
1489
- {
1490
- sTitle:
1491
- 'Evaluation with regard to the null value.',
1492
- sInput:
1493
- '/*jshint evil:true */' +
1494
- '(function() {' +
1495
- ' var foo;' +
1496
- ' void [null, null, null];' +
1497
- '}());' +
1498
- 'eval("");' +
1499
- '(function() {' +
1500
- ' var foo;' +
1501
- ' void [null, null];' +
1502
- '}());',
1503
- sOutput:
1504
- '/*jshint evil:true */' +
1505
- '(function() {' +
1506
- ' var a = null, foo;' +
1507
- ' void [a, a, a];' +
1508
- '}());' +
1509
- 'eval("");' +
1510
- '(function() {' +
1511
- ' var foo;' +
1512
- ' void [null, null];' +
1513
- '}());'
1514
- },
1515
- // 7.8.2 Boolean Literals.
1516
- {
1517
- sTitle:
1518
- 'Evaluation with regard to the false value.',
1519
- sInput:
1520
- '/*jshint evil:true */' +
1521
- '(function() {' +
1522
- ' var foo;' +
1523
- ' void [false, false, false];' +
1524
- '}());' +
1525
- 'eval("");' +
1526
- '(function() {' +
1527
- ' var foo;' +
1528
- ' void [false, false];' +
1529
- '}());',
1530
- sOutput:
1531
- '/*jshint evil:true */' +
1532
- '(function() {' +
1533
- ' var a = false, foo;' +
1534
- ' void [a, a, a];' +
1535
- '}());' +
1536
- 'eval("");' +
1537
- '(function() {' +
1538
- ' var foo;' +
1539
- ' void [false, false];' +
1540
- '}());'
1541
- },
1542
- {
1543
- sTitle:
1544
- 'Evaluation with regard to the true value.',
1545
- sInput:
1546
- '/*jshint evil:true */' +
1547
- '(function() {' +
1548
- ' var foo;' +
1549
- ' void [true, true, true];' +
1550
- '}());' +
1551
- 'eval("");' +
1552
- '(function() {' +
1553
- ' var foo;' +
1554
- ' void [true, true];' +
1555
- '}());',
1556
- sOutput:
1557
- '/*jshint evil:true */' +
1558
- '(function() {' +
1559
- ' var a = true, foo;' +
1560
- ' void [a, a, a];' +
1561
- '}());' +
1562
- 'eval("");' +
1563
- '(function() {' +
1564
- ' var foo;' +
1565
- ' void [true, true];' +
1566
- '}());'
1567
- },
1568
- // 7.8.4 String Literals.
1569
- {
1570
- sTitle:
1571
- 'Evaluation with regard to the String value of a string literal.',
1572
- sInput:
1573
- '(function() {' +
1574
- ' var foo;' +
1575
- ' void ["abcd", "abcd", "abc", "abc"];' +
1576
- '}());',
1577
- sOutput:
1578
- '(function() {' +
1579
- ' var a = "abcd", foo;' +
1580
- ' void [a, a, "abc", "abc"];' +
1581
- '}());'
1582
- },
1583
- // 7.8.5 Regular Expression Literals.
1584
- {
1585
- sTitle:
1586
- 'Preservation of the pattern of a regular expression literal.',
1587
- sInput:
1588
- 'void [/abcdefghijklmnopqrstuvwxyz/, /abcdefghijklmnopqrstuvwxyz/];'
1589
- },
1590
- {
1591
- sTitle:
1592
- 'Preservation of the flags of a regular expression literal.',
1593
- sInput:
1594
- 'void [/(?:)/gim, /(?:)/gim, /(?:)/gim, /(?:)/gim, /(?:)/gim,' +
1595
- ' /(?:)/gim, /(?:)/gim, /(?:)/gim, /(?:)/gim, /(?:)/gim,' +
1596
- ' /(?:)/gim, /(?:)/gim, /(?:)/gim, /(?:)/gim, /(?:)/gim];'
1597
- },
1598
- // 10.2 Lexical Environments.
1599
- {
1600
- sTitle:
1601
- 'Preservation of identifier names in the same scope.',
1602
- sInput:
1603
- '/*jshint shadow:true */' +
1604
- 'var a;' +
1605
- 'function b(i) {' +
1606
- '}' +
1607
- 'for (var c; 0 === Math.random(););' +
1608
- 'for (var d in {});' +
1609
- 'void ["abcdefghijklmnopqrstuvwxyz"];' +
1610
- 'void [b(a), b(c), b(d)];' +
1611
- 'void [typeof e];' +
1612
- 'i: for (; 0 === Math.random();) {' +
1613
- ' if (42 === (new Date()).getMinutes()) {' +
1614
- ' continue i;' +
1615
- ' } else {' +
1616
- ' break i;' +
1617
- ' }' +
1618
- '}' +
1619
- 'try {' +
1620
- '} catch (f) {' +
1621
- '} finally {' +
1622
- '}' +
1623
- '(function g(h) {' +
1624
- '}());' +
1625
- 'void [{' +
1626
- ' i: 42,' +
1627
- ' "j": 42,' +
1628
- ' \'k\': 42' +
1629
- '}];' +
1630
- 'void ["abcdefghijklmnopqrstuvwxyz"];',
1631
- sOutput:
1632
- '/*jshint shadow:true */' +
1633
- 'var a;' +
1634
- 'function b(i) {' +
1635
- '}' +
1636
- 'for (var c; 0 === Math.random(););' +
1637
- 'for (var d in {});' +
1638
- '(function() {' +
1639
- ' var i = "abcdefghijklmnopqrstuvwxyz";' +
1640
- ' void [i];' +
1641
- ' void [b(a), b(c), b(d)];' +
1642
- ' void [typeof e];' +
1643
- ' i: for (; 0 === Math.random();) {' +
1644
- ' if (42 === (new Date()).getMinutes()) {' +
1645
- ' continue i;' +
1646
- ' } else {' +
1647
- ' break i;' +
1648
- ' }' +
1649
- ' }' +
1650
- ' try {' +
1651
- ' } catch (f) {' +
1652
- ' } finally {' +
1653
- ' }' +
1654
- ' (function g(h) {' +
1655
- ' }());' +
1656
- ' void [{' +
1657
- ' i: 42,' +
1658
- ' "j": 42,' +
1659
- ' \'k\': 42' +
1660
- ' }];' +
1661
- ' void [i];' +
1662
- '}());'
1663
- },
1664
- {
1665
- sTitle:
1666
- 'Preservation of identifier names in nested function code.',
1667
- sInput:
1668
- '(function() {' +
1669
- ' void ["abcdefghijklmnopqrstuvwxyz"];' +
1670
- ' (function() {' +
1671
- ' var a;' +
1672
- ' for (var b; 0 === Math.random(););' +
1673
- ' for (var c in {});' +
1674
- ' void [typeof d];' +
1675
- ' h: for (; 0 === Math.random();) {' +
1676
- ' if (42 === (new Date()).getMinutes()) {' +
1677
- ' continue h;' +
1678
- ' } else {' +
1679
- ' break h;' +
1680
- ' }' +
1681
- ' }' +
1682
- ' try {' +
1683
- ' } catch (e) {' +
1684
- ' } finally {' +
1685
- ' }' +
1686
- ' (function f(g) {' +
1687
- ' }());' +
1688
- ' void [{' +
1689
- ' h: 42,' +
1690
- ' "i": 42,' +
1691
- ' \'j\': 42' +
1692
- ' }];' +
1693
- ' }());' +
1694
- ' void ["abcdefghijklmnopqrstuvwxyz"];' +
1695
- '}());',
1696
- sOutput:
1697
- '(function() {' +
1698
- ' var h = "abcdefghijklmnopqrstuvwxyz";' +
1699
- ' void [h];' +
1700
- ' (function() {' +
1701
- ' var a;' +
1702
- ' for (var b; 0 === Math.random(););' +
1703
- ' for (var c in {});' +
1704
- ' void [typeof d];' +
1705
- ' h: for (; 0 === Math.random();) {' +
1706
- ' if (42 === (new Date()).getMinutes()) {' +
1707
- ' continue h;' +
1708
- ' } else {' +
1709
- ' break h;' +
1710
- ' }' +
1711
- ' }' +
1712
- ' try {' +
1713
- ' } catch (e) {' +
1714
- ' } finally {' +
1715
- ' }' +
1716
- ' (function f(g) {' +
1717
- ' }());' +
1718
- ' void [{' +
1719
- ' h: 42,' +
1720
- ' "i": 42,' +
1721
- ' \'j\': 42' +
1722
- ' }];' +
1723
- ' }());' +
1724
- ' void [h];' +
1725
- '}());'
1726
- },
1727
- {
1728
- sTitle:
1729
- 'Consolidation of a closure with other source elements.',
1730
- sInput:
1731
- '(function(foo) {' +
1732
- '}("abcdefghijklmnopqrstuvwxyz"));' +
1733
- 'void ["abcdefghijklmnopqrstuvwxyz"];',
1734
- sOutput:
1735
- '(function() {' +
1736
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
1737
- ' (function(foo) {' +
1738
- ' })(a);' +
1739
- ' void [a];' +
1740
- '}());'
1741
- },
1742
- {
1743
- sTitle:
1744
- 'Consolidation of function code instead of a sole closure.',
1745
- sInput:
1746
- '(function(foo, bar) {' +
1747
- ' void ["abcdefghijklmnopqrstuvwxyz",' +
1748
- ' "abcdefghijklmnopqrstuvwxyz"];' +
1749
- '}("abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz"));',
1750
- sOutput:
1751
- '(function(foo, bar) {' +
1752
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
1753
- ' void [a, a];' +
1754
- '}("abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz"));'
1755
- },
1756
- // 11.1.5 Object Initialiser.
1757
- {
1758
- sTitle:
1759
- 'Preservation of property names of an object initialiser.',
1760
- sInput:
1761
- 'var foo = {' +
1762
- ' abcdefghijklmnopqrstuvwxyz: 42,' +
1763
- ' "zyxwvutsrqponmlkjihgfedcba": 42,' +
1764
- ' \'mlkjihgfedcbanopqrstuvwxyz\': 42' +
1765
- '};' +
1766
- 'void [' +
1767
- ' foo.abcdefghijklmnopqrstuvwxyz,' +
1768
- ' "zyxwvutsrqponmlkjihgfedcba",' +
1769
- ' \'mlkjihgfedcbanopqrstuvwxyz\'' +
1770
- '];'
1771
- },
1772
- {
1773
- sTitle:
1774
- 'Evaluation with regard to String values derived from identifier ' +
1775
- 'names used as property accessors.',
1776
- sInput:
1777
- '(function() {' +
1778
- ' var foo;' +
1779
- ' void [' +
1780
- ' Math.abcdefghij,' +
1781
- ' Math.abcdefghij,' +
1782
- ' Math.abcdefghi,' +
1783
- ' Math.abcdefghi' +
1784
- ' ];' +
1785
- '}());',
1786
- sOutput:
1787
- '(function() {' +
1788
- ' var a = "abcdefghij", foo;' +
1789
- ' void [' +
1790
- ' Math[a],' +
1791
- ' Math[a],' +
1792
- ' Math.abcdefghi,' +
1793
- ' Math.abcdefghi' +
1794
- ' ];' +
1795
- '}());'
1796
- },
1797
- // 11.2.1 Property Accessors.
1798
- {
1799
- sTitle:
1800
- 'Preservation of identifiers in the nonterminal MemberExpression.',
1801
- sInput:
1802
- 'void [' +
1803
- ' Math.E,' +
1804
- ' Math.LN10,' +
1805
- ' Math.LN2,' +
1806
- ' Math.LOG2E,' +
1807
- ' Math.LOG10E,' +
1808
- ' Math.PI,' +
1809
- ' Math.SQRT1_2,' +
1810
- ' Math.SQRT2,' +
1811
- ' Math.abs,' +
1812
- ' Math.acos' +
1813
- '];'
1814
- },
1815
- // 12.2 Variable Statement.
1816
- {
1817
- sTitle:
1818
- 'Preservation of the identifier of a variable that is being ' +
1819
- 'declared in a variable statement.',
1820
- sInput:
1821
- '(function() {' +
1822
- ' var abcdefghijklmnopqrstuvwxyz;' +
1823
- ' void [abcdefghijklmnopqrstuvwxyz];' +
1824
- '}());'
1825
- },
1826
- {
1827
- sTitle:
1828
- 'Exclusion of a variable statement in global code.',
1829
- sInput:
1830
- 'void ["abcdefghijklmnopqrstuvwxyz"];' +
1831
- 'var foo = "abcdefghijklmnopqrstuvwxyz",' +
1832
- ' bar = "abcdefghijklmnopqrstuvwxyz";' +
1833
- 'void ["abcdefghijklmnopqrstuvwxyz"];'
1834
- },
1835
- {
1836
- sTitle:
1837
- 'Exclusion of a variable statement in function code that ' +
1838
- 'contains a with statement.',
1839
- sInput:
1840
- '(function() {' +
1841
- ' with ({});' +
1842
- ' void ["abcdefghijklmnopqrstuvwxyz"];' +
1843
- ' var foo;' +
1844
- ' void ["abcdefghijklmnopqrstuvwxyz"];' +
1845
- '}());'
1846
- },
1847
- {
1848
- sTitle:
1849
- 'Exclusion of a variable statement in function code that ' +
1850
- 'contains a direct call to the eval function.',
1851
- sInput:
1852
- '/*jshint evil:true */' +
1853
- 'void [' +
1854
- ' function() {' +
1855
- ' eval("");' +
1856
- ' void ["abcdefghijklmnopqrstuvwxyz"];' +
1857
- ' var foo;' +
1858
- ' void ["abcdefghijklmnopqrstuvwxyz"];' +
1859
- ' }' +
1860
- '];'
1861
- },
1862
- {
1863
- sTitle:
1864
- 'Consolidation within a variable statement in global code.',
1865
- sInput:
1866
- 'var foo = function() {' +
1867
- ' void ["abcdefghijklmnopqrstuvwxyz",' +
1868
- ' "abcdefghijklmnopqrstuvwxyz"];' +
1869
- '};',
1870
- sOutput:
1871
- 'var foo = function() {' +
1872
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
1873
- ' void [a, a];' +
1874
- '};'
1875
- },
1876
- {
1877
- sTitle:
1878
- 'Consolidation within a variable statement excluded in function ' +
1879
- 'code due to the presence of a with statement.',
1880
- sInput:
1881
- '(function() {' +
1882
- ' with ({});' +
1883
- ' var foo = function() {' +
1884
- ' void ["abcdefghijklmnopqrstuvwxyz",' +
1885
- ' "abcdefghijklmnopqrstuvwxyz"];' +
1886
- ' };' +
1887
- '}());',
1888
- sOutput:
1889
- '(function() {' +
1890
- ' with ({});' +
1891
- ' var foo = function() {' +
1892
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
1893
- ' void [a, a];' +
1894
- ' };' +
1895
- '}());'
1896
- },
1897
- {
1898
- sTitle:
1899
- 'Consolidation within a variable statement excluded in function ' +
1900
- 'code due to the presence of a direct call to the eval function.',
1901
- sInput:
1902
- '/*jshint evil:true */' +
1903
- '(function() {' +
1904
- ' eval("");' +
1905
- ' var foo = function() {' +
1906
- ' void ["abcdefghijklmnopqrstuvwxyz",' +
1907
- ' "abcdefghijklmnopqrstuvwxyz"];' +
1908
- ' };' +
1909
- '}());',
1910
- sOutput:
1911
- '/*jshint evil:true */' +
1912
- '(function() {' +
1913
- ' eval("");' +
1914
- ' var foo = function() {' +
1915
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
1916
- ' void [a, a];' +
1917
- ' };' +
1918
- '}());'
1919
- },
1920
- {
1921
- sTitle:
1922
- 'Inclusion of a variable statement in function code that ' +
1923
- 'contains no with statement and no direct call to the eval ' +
1924
- 'function.',
1925
- sInput:
1926
- '(function() {' +
1927
- ' void ["abcdefghijklmnopqrstuvwxyz"];' +
1928
- ' var foo;' +
1929
- ' void ["abcdefghijklmnopqrstuvwxyz"];' +
1930
- '}());',
1931
- sOutput:
1932
- '(function() {' +
1933
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
1934
- ' void [a];' +
1935
- ' var foo;' +
1936
- ' void [a];' +
1937
- '}());'
1938
- },
1939
- {
1940
- sTitle:
1941
- 'Ignorance with regard to a variable statement in global code.',
1942
- sInput:
1943
- 'var foo = "abcdefghijklmnopqrstuvwxyz";' +
1944
- 'void ["abcdefghijklmnopqrstuvwxyz",' +
1945
- ' "abcdefghijklmnopqrstuvwxyz"];',
1946
- sOutput:
1947
- 'var foo = "abcdefghijklmnopqrstuvwxyz";' +
1948
- '(function() {' +
1949
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
1950
- ' void [a, a];' +
1951
- '}());'
1952
- },
1953
- // 12.4 Expression Statement.
1954
- {
1955
- sTitle:
1956
- 'Preservation of identifiers in an expression statement.',
1957
- sInput:
1958
- 'void [typeof abcdefghijklmnopqrstuvwxyz,' +
1959
- ' typeof abcdefghijklmnopqrstuvwxyz];'
1960
- },
1961
- // 12.6.3 The {@code for} Statement.
1962
- {
1963
- sTitle:
1964
- 'Preservation of identifiers in the variable declaration list of ' +
1965
- 'a for statement.',
1966
- sInput:
1967
- 'for (var abcdefghijklmnopqrstuvwxyz; 0 === Math.random(););' +
1968
- 'for (var abcdefghijklmnopqrstuvwxyz; 0 === Math.random(););'
1969
- },
1970
- // 12.6.4 The {@code for-in} Statement.
1971
- {
1972
- sTitle:
1973
- 'Preservation of identifiers in the variable declaration list of ' +
1974
- 'a for-in statement.',
1975
- sInput:
1976
- 'for (var abcdefghijklmnopqrstuvwxyz in {});' +
1977
- 'for (var abcdefghijklmnopqrstuvwxyz in {});'
1978
- },
1979
- // 12.7 The {@code continue} Statement.
1980
- {
1981
- sTitle:
1982
- 'Preservation of the identifier in a continue statement.',
1983
- sInput:
1984
- 'abcdefghijklmnopqrstuvwxyz: for (; 0 === Math.random();) {' +
1985
- ' continue abcdefghijklmnopqrstuvwxyz;' +
1986
- '}' +
1987
- 'abcdefghijklmnopqrstuvwxyz: for (; 0 === Math.random();) {' +
1988
- ' continue abcdefghijklmnopqrstuvwxyz;' +
1989
- '}'
1990
- },
1991
- // 12.8 The {@code break} Statement.
1992
- {
1993
- sTitle:
1994
- 'Preservation of the identifier in a break statement.',
1995
- sInput:
1996
- 'abcdefghijklmnopqrstuvwxyz: for (; 0 === Math.random();) {' +
1997
- ' break abcdefghijklmnopqrstuvwxyz;' +
1998
- '}' +
1999
- 'abcdefghijklmnopqrstuvwxyz: for (; 0 === Math.random();) {' +
2000
- ' break abcdefghijklmnopqrstuvwxyz;' +
2001
- '}'
2002
- },
2003
- // 12.9 The {@code return} Statement.
2004
- {
2005
- sTitle:
2006
- 'Exclusion of a return statement in function code that contains ' +
2007
- 'a with statement.',
2008
- sInput:
2009
- '(function() {' +
2010
- ' with ({});' +
2011
- ' void ["abcdefghijklmnopqrstuvwxyz"];' +
2012
- ' if (0 === Math.random()) {' +
2013
- ' return;' +
2014
- ' } else {' +
2015
- ' }' +
2016
- ' void ["abcdefghijklmnopqrstuvwxyz"];' +
2017
- '}());'
2018
- },
2019
- {
2020
- sTitle:
2021
- 'Exclusion of a return statement in function code that contains ' +
2022
- 'a direct call to the eval function.',
2023
- sInput:
2024
- '/*jshint evil:true */' +
2025
- '(function() {' +
2026
- ' eval("");' +
2027
- ' void ["abcdefghijklmnopqrstuvwxyz"];' +
2028
- ' if (0 === Math.random()) {' +
2029
- ' return;' +
2030
- ' } else {' +
2031
- ' }' +
2032
- ' void ["abcdefghijklmnopqrstuvwxyz"];' +
2033
- '}());'
2034
- },
2035
- {
2036
- sTitle:
2037
- 'Consolidation within a return statement excluded in function ' +
2038
- 'code due to the presence of a with statement.',
2039
- sInput:
2040
- '(function() {' +
2041
- ' with ({});' +
2042
- ' return function() {' +
2043
- ' void ["abcdefghijklmnopqrstuvwxyz",' +
2044
- ' "abcdefghijklmnopqrstuvwxyz"];' +
2045
- ' };' +
2046
- '}());',
2047
- sOutput:
2048
- '(function() {' +
2049
- ' with ({});' +
2050
- ' return function() {' +
2051
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
2052
- ' void [a, a];' +
2053
- ' };' +
2054
- '}());'
2055
- },
2056
- {
2057
- sTitle:
2058
- 'Consolidation within a return statement excluded in function ' +
2059
- 'code due to the presence of a direct call to the eval function.',
2060
- sInput:
2061
- '/*jshint evil:true */' +
2062
- '(function() {' +
2063
- ' eval("");' +
2064
- ' return function() {' +
2065
- ' void ["abcdefghijklmnopqrstuvwxyz",' +
2066
- ' "abcdefghijklmnopqrstuvwxyz"];' +
2067
- ' };' +
2068
- '}());',
2069
- sOutput:
2070
- '/*jshint evil:true */' +
2071
- '(function() {' +
2072
- ' eval("");' +
2073
- ' return function() {' +
2074
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
2075
- ' void [a, a];' +
2076
- ' };' +
2077
- '}());'
2078
- },
2079
- {
2080
- sTitle:
2081
- 'Inclusion of a return statement in function code that contains ' +
2082
- 'no with statement and no direct call to the eval function.',
2083
- sInput:
2084
- '(function() {' +
2085
- ' void ["abcdefghijklmnopqrstuvwxyz"];' +
2086
- ' if (0 === Math.random()) {' +
2087
- ' return;' +
2088
- ' } else {' +
2089
- ' }' +
2090
- ' void ["abcdefghijklmnopqrstuvwxyz"];' +
2091
- '}());',
2092
- sOutput:
2093
- '(function() {' +
2094
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
2095
- ' void [a];' +
2096
- ' if (0 === Math.random()) {' +
2097
- ' return;' +
2098
- ' } else {' +
2099
- ' }' +
2100
- ' void [a];' +
2101
- '}());'
2102
- },
2103
- // 12.10 The {@code with} Statement.
2104
- {
2105
- sTitle:
2106
- 'Preservation of the statement in a with statement.',
2107
- sInput:
2108
- 'with ({}) {' +
2109
- ' void ["abcdefghijklmnopqrstuvwxyz",' +
2110
- ' "abcdefghijklmnopqrstuvwxyz"];' +
2111
- '}'
2112
- },
2113
- {
2114
- sTitle:
2115
- 'Exclusion of a with statement in the same syntactic code unit.',
2116
- sInput:
2117
- 'void ["abcdefghijklmnopqrstuvwxyz"];' +
2118
- 'with ({' +
2119
- ' foo: "abcdefghijklmnopqrstuvwxyz",' +
2120
- ' bar: "abcdefghijklmnopqrstuvwxyz"' +
2121
- '}) {' +
2122
- ' void ["abcdefghijklmnopqrstuvwxyz",' +
2123
- ' "abcdefghijklmnopqrstuvwxyz"];' +
2124
- '}' +
2125
- 'void ["abcdefghijklmnopqrstuvwxyz"];'
2126
- },
2127
- {
2128
- sTitle:
2129
- 'Exclusion of a with statement in nested function code.',
2130
- sInput:
2131
- 'void ["abcdefghijklmnopqrstuvwxyz"];' +
2132
- '(function() {' +
2133
- ' with ({' +
2134
- ' foo: "abcdefghijklmnopqrstuvwxyz",' +
2135
- ' bar: "abcdefghijklmnopqrstuvwxyz"' +
2136
- ' }) {' +
2137
- ' void ["abcdefghijklmnopqrstuvwxyz",' +
2138
- ' "abcdefghijklmnopqrstuvwxyz"];' +
2139
- ' }' +
2140
- '}());' +
2141
- 'void ["abcdefghijklmnopqrstuvwxyz"];'
2142
- },
2143
- // 12.12 Labelled Statements.
2144
- {
2145
- sTitle:
2146
- 'Preservation of the label of a labelled statement.',
2147
- sInput:
2148
- 'abcdefghijklmnopqrstuvwxyz: for (; 0 === Math.random(););' +
2149
- 'abcdefghijklmnopqrstuvwxyz: for (; 0 === Math.random(););'
2150
- },
2151
- // 12.14 The {@code try} Statement.
2152
- {
2153
- sTitle:
2154
- 'Preservation of the identifier in the catch clause of a try' +
2155
- 'statement.',
2156
- sInput:
2157
- 'try {' +
2158
- '} catch (abcdefghijklmnopqrstuvwxyz) {' +
2159
- '} finally {' +
2160
- '}' +
2161
- 'try {' +
2162
- '} catch (abcdefghijklmnopqrstuvwxyz) {' +
2163
- '} finally {' +
2164
- '}'
2165
- },
2166
- // 13 Function Definition.
2167
- {
2168
- sTitle:
2169
- 'Preservation of the identifier of a function declaration.',
2170
- sInput:
2171
- 'function abcdefghijklmnopqrstuvwxyz() {' +
2172
- '}' +
2173
- 'void [abcdefghijklmnopqrstuvwxyz];'
2174
- },
2175
- {
2176
- sTitle:
2177
- 'Preservation of the identifier of a function expression.',
2178
- sInput:
2179
- 'void [' +
2180
- ' function abcdefghijklmnopqrstuvwxyz() {' +
2181
- ' },' +
2182
- ' function abcdefghijklmnopqrstuvwxyz() {' +
2183
- ' }' +
2184
- '];'
2185
- },
2186
- {
2187
- sTitle:
2188
- 'Preservation of a formal parameter of a function declaration.',
2189
- sInput:
2190
- 'function foo(abcdefghijklmnopqrstuvwxyz) {' +
2191
- '}' +
2192
- 'function bar(abcdefghijklmnopqrstuvwxyz) {' +
2193
- '}'
2194
- },
2195
- {
2196
- sTitle:
2197
- 'Preservation of a formal parameter in a function expression.',
2198
- sInput:
2199
- 'void [' +
2200
- ' function(abcdefghijklmnopqrstuvwxyz) {' +
2201
- ' },' +
2202
- ' function(abcdefghijklmnopqrstuvwxyz) {' +
2203
- ' }' +
2204
- '];'
2205
- },
2206
- {
2207
- sTitle:
2208
- 'Exclusion of a function declaration.',
2209
- sInput:
2210
- 'void ["abcdefghijklmnopqrstuvwxyz"];' +
2211
- 'function foo() {' +
2212
- '}' +
2213
- 'void ["abcdefghijklmnopqrstuvwxyz"];'
2214
- },
2215
- {
2216
- sTitle:
2217
- 'Consolidation within a function declaration.',
2218
- sInput:
2219
- 'function foo() {' +
2220
- ' void ["abcdefghijklmnopqrstuvwxyz",' +
2221
- ' "abcdefghijklmnopqrstuvwxyz"];' +
2222
- '}',
2223
- sOutput:
2224
- 'function foo() {' +
2225
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
2226
- ' void [a, a];' +
2227
- '}'
2228
- },
2229
- // 14 Program.
2230
- {
2231
- sTitle:
2232
- 'Preservation of a program without source elements.',
2233
- sInput:
2234
- ''
2235
- },
2236
- // 14.1 Directive Prologues and the Use Strict Directive.
2237
- {
2238
- sTitle:
2239
- 'Preservation of a Directive Prologue in global code.',
2240
- sInput:
2241
- '"abcdefghijklmnopqrstuvwxyz";' +
2242
- '\'zyxwvutsrqponmlkjihgfedcba\';'
2243
- },
2244
- {
2245
- sTitle:
2246
- 'Preservation of a Directive Prologue in a function declaration.',
2247
- sInput:
2248
- 'function foo() {' +
2249
- ' "abcdefghijklmnopqrstuvwxyz";' +
2250
- ' \'zyxwvutsrqponmlkjihgfedcba\';' +
2251
- '}'
2252
- },
2253
- {
2254
- sTitle:
2255
- 'Preservation of a Directive Prologue in a function expression.',
2256
- sInput:
2257
- 'void [' +
2258
- ' function() {' +
2259
- ' "abcdefghijklmnopqrstuvwxyz";' +
2260
- ' \'zyxwvutsrqponmlkjihgfedcba\';' +
2261
- ' }' +
2262
- '];'
2263
- },
2264
- {
2265
- sTitle:
2266
- 'Ignorance with regard to a Directive Prologue in global code.',
2267
- sInput:
2268
- '"abcdefghijklmnopqrstuvwxyz";' +
2269
- 'void ["abcdefghijklmnopqrstuvwxyz",' +
2270
- ' "abcdefghijklmnopqrstuvwxyz"];',
2271
- sOutput:
2272
- '"abcdefghijklmnopqrstuvwxyz";' +
2273
- '(function() {' +
2274
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
2275
- ' void [a, a];' +
2276
- '}());'
2277
- },
2278
- {
2279
- sTitle:
2280
- 'Ignorance with regard to a Directive Prologue in a function' +
2281
- 'declaration.',
2282
- sInput:
2283
- 'function foo() {' +
2284
- ' "abcdefghijklmnopqrstuvwxyz";' +
2285
- ' void ["abcdefghijklmnopqrstuvwxyz",' +
2286
- ' "abcdefghijklmnopqrstuvwxyz"];' +
2287
- '}',
2288
- sOutput:
2289
- 'function foo() {' +
2290
- ' "abcdefghijklmnopqrstuvwxyz";' +
2291
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
2292
- ' void [a, a];' +
2293
- '}'
2294
- },
2295
- {
2296
- sTitle:
2297
- 'Ignorance with regard to a Directive Prologue in a function' +
2298
- 'expression.',
2299
- sInput:
2300
- '(function() {' +
2301
- ' "abcdefghijklmnopqrstuvwxyz";' +
2302
- ' void ["abcdefghijklmnopqrstuvwxyz",' +
2303
- ' "abcdefghijklmnopqrstuvwxyz"];' +
2304
- '}());',
2305
- sOutput:
2306
- '(function() {' +
2307
- ' "abcdefghijklmnopqrstuvwxyz";' +
2308
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
2309
- ' void [a, a];' +
2310
- '}());'
2311
- },
2312
- // 15.1 The Global Object.
2313
- {
2314
- sTitle:
2315
- 'Preservation of a property of the global object.',
2316
- sInput:
2317
- 'void [undefined, undefined, undefined, undefined, undefined];'
2318
- },
2319
- // 15.1.2.1.1 Direct Call to Eval.
2320
- {
2321
- sTitle:
2322
- 'Exclusion of a direct call to the eval function in the same ' +
2323
- 'syntactic code unit.',
2324
- sInput:
2325
- '/*jshint evil:true */' +
2326
- 'void ["abcdefghijklmnopqrstuvwxyz"];' +
2327
- 'eval("");' +
2328
- 'void ["abcdefghijklmnopqrstuvwxyz"];'
2329
- },
2330
- {
2331
- sTitle:
2332
- 'Exclusion of a direct call to the eval function in nested ' +
2333
- 'function code.',
2334
- sInput:
2335
- '/*jshint evil:true */' +
2336
- 'void ["abcdefghijklmnopqrstuvwxyz"];' +
2337
- '(function() {' +
2338
- ' eval("");' +
2339
- '}());' +
2340
- 'void ["abcdefghijklmnopqrstuvwxyz"];'
2341
- },
2342
- {
2343
- sTitle:
2344
- 'Consolidation within a direct call to the eval function.',
2345
- sInput:
2346
- '/*jshint evil:true */' +
2347
- 'eval(function() {' +
2348
- ' void ["abcdefghijklmnopqrstuvwxyz",' +
2349
- ' "abcdefghijklmnopqrstuvwxyz"];' +
2350
- '}());',
2351
- sOutput:
2352
- '/*jshint evil:true */' +
2353
- 'eval(function() {' +
2354
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
2355
- ' void [a, a];' +
2356
- '}());'
2357
- },
2358
- // Consolidation proper.
2359
- {
2360
- sTitle:
2361
- 'No consolidation if it does not result in a reduction of the ' +
2362
- 'number of source characters.',
2363
- sInput:
2364
- '(function() {' +
2365
- ' var foo;' +
2366
- ' void ["ab", "ab", "abc", "abc"];' +
2367
- '}());'
2368
- },
2369
- {
2370
- sTitle:
2371
- 'Identification of a range of source elements at the beginning ' +
2372
- 'of global code.',
2373
- sInput:
2374
- '/*jshint evil:true */' +
2375
- '"abcdefghijklmnopqrstuvwxyz";' +
2376
- 'void ["abcdefghijklmnopqrstuvwxyz",' +
2377
- ' "abcdefghijklmnopqrstuvwxyz"];' +
2378
- 'eval("");',
2379
- sOutput:
2380
- '/*jshint evil:true */' +
2381
- '"abcdefghijklmnopqrstuvwxyz";' +
2382
- '(function() {' +
2383
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
2384
- ' void [a, a];' +
2385
- '}());' +
2386
- 'eval("");'
2387
- },
2388
- {
2389
- sTitle:
2390
- 'Identification of a range of source elements in the middle of ' +
2391
- 'global code.',
2392
- sInput:
2393
- '/*jshint evil:true */' +
2394
- '"abcdefghijklmnopqrstuvwxyz";' +
2395
- 'eval("");' +
2396
- 'void ["abcdefghijklmnopqrstuvwxyz",' +
2397
- ' "abcdefghijklmnopqrstuvwxyz"];' +
2398
- 'eval("");',
2399
- sOutput:
2400
- '/*jshint evil:true */' +
2401
- '"abcdefghijklmnopqrstuvwxyz";' +
2402
- 'eval("");' +
2403
- '(function() {' +
2404
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
2405
- ' void [a, a];' +
2406
- '}());' +
2407
- 'eval("");'
2408
- },
2409
- {
2410
- sTitle:
2411
- 'Identification of a range of source elements at the end of ' +
2412
- 'global code.',
2413
- sInput:
2414
- '/*jshint evil:true */' +
2415
- '"abcdefghijklmnopqrstuvwxyz";' +
2416
- 'eval("");' +
2417
- 'void ["abcdefghijklmnopqrstuvwxyz",' +
2418
- ' "abcdefghijklmnopqrstuvwxyz"];',
2419
- sOutput:
2420
- '/*jshint evil:true */' +
2421
- '"abcdefghijklmnopqrstuvwxyz";' +
2422
- 'eval("");' +
2423
- '(function() {' +
2424
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
2425
- ' void [a, a];' +
2426
- '}());'
2427
- },
2428
- {
2429
- sTitle:
2430
- 'Identification of a range of source elements at the beginning ' +
2431
- 'of function code.',
2432
- sInput:
2433
- '/*jshint evil:true */' +
2434
- '(function() {' +
2435
- ' "abcdefghijklmnopqrstuvwxyz";' +
2436
- ' void ["abcdefghijklmnopqrstuvwxyz",' +
2437
- ' "abcdefghijklmnopqrstuvwxyz"];' +
2438
- ' eval("");' +
2439
- '}());',
2440
- sOutput:
2441
- '/*jshint evil:true */' +
2442
- '(function() {' +
2443
- ' "abcdefghijklmnopqrstuvwxyz";' +
2444
- ' (function() {' +
2445
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
2446
- ' void [a, a];' +
2447
- ' }());' +
2448
- ' eval("");' +
2449
- '}());'
2450
- },
2451
- {
2452
- sTitle:
2453
- 'Identification of a range of source elements in the middle of ' +
2454
- 'function code.',
2455
- sInput:
2456
- '/*jshint evil:true */' +
2457
- '(function() {' +
2458
- ' "abcdefghijklmnopqrstuvwxyz";' +
2459
- ' eval("");' +
2460
- ' void ["abcdefghijklmnopqrstuvwxyz",' +
2461
- ' "abcdefghijklmnopqrstuvwxyz"];' +
2462
- ' eval("");' +
2463
- '}());',
2464
- sOutput:
2465
- '/*jshint evil:true */' +
2466
- '(function() {' +
2467
- ' "abcdefghijklmnopqrstuvwxyz";' +
2468
- ' eval("");' +
2469
- ' (function() {' +
2470
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
2471
- ' void [a, a];' +
2472
- ' }());' +
2473
- ' eval("");' +
2474
- '}());'
2475
- },
2476
- {
2477
- sTitle:
2478
- 'Identification of a range of source elements at the end of ' +
2479
- 'function code.',
2480
- sInput:
2481
- '/*jshint evil:true */' +
2482
- '(function() {' +
2483
- ' "abcdefghijklmnopqrstuvwxyz";' +
2484
- ' eval("");' +
2485
- ' void ["abcdefghijklmnopqrstuvwxyz",' +
2486
- ' "abcdefghijklmnopqrstuvwxyz"];' +
2487
- '}());',
2488
- sOutput:
2489
- '/*jshint evil:true */' +
2490
- '(function() {' +
2491
- ' "abcdefghijklmnopqrstuvwxyz";' +
2492
- ' eval("");' +
2493
- ' (function() {' +
2494
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
2495
- ' void [a, a];' +
2496
- ' }());' +
2497
- '}());'
2498
- },
2499
- {
2500
- sTitle:
2501
- 'Evaluation with regard to String values of String literals and ' +
2502
- 'String values derived from identifier names used as property' +
2503
- 'accessors.',
2504
- sInput:
2505
- '(function() {' +
2506
- ' var foo;' +
2507
- ' void ["abcdefg", Math.abcdefg, "abcdef", Math.abcdef];' +
2508
- '}());',
2509
- sOutput:
2510
- '(function() {' +
2511
- ' var a = "abcdefg", foo;' +
2512
- ' void [a, Math[a], "abcdef", Math.abcdef];' +
2513
- '}());'
2514
- },
2515
- {
2516
- sTitle:
2517
- 'Evaluation with regard to the necessity of adding a variable ' +
2518
- 'statement.',
2519
- sInput:
2520
- '/*jshint evil:true */' +
2521
- '(function() {' +
2522
- ' void ["abcdefgh", "abcdefgh"];' +
2523
- '}());' +
2524
- 'eval("");' +
2525
- '(function() {' +
2526
- ' void ["abcdefg", "abcdefg"];' +
2527
- '}());' +
2528
- 'eval("");' +
2529
- '(function() {' +
2530
- ' var foo;' +
2531
- ' void ["abcd", "abcd"];' +
2532
- '}());',
2533
- sOutput:
2534
- '/*jshint evil:true */' +
2535
- '(function() {' +
2536
- ' var a = "abcdefgh";' +
2537
- ' void [a, a];' +
2538
- '}());' +
2539
- 'eval("");' +
2540
- '(function() {' +
2541
- ' void ["abcdefg", "abcdefg"];' +
2542
- '}());' +
2543
- 'eval("");' +
2544
- '(function() {' +
2545
- ' var a = "abcd", foo;' +
2546
- ' void [a, a];' +
2547
- '}());'
2548
- },
2549
- {
2550
- sTitle:
2551
- 'Evaluation with regard to the necessity of enclosing source ' +
2552
- 'elements.',
2553
- sInput:
2554
- '/*jshint evil:true */' +
2555
- 'void ["abcdefghijklmnopqrstuvwxy", "abcdefghijklmnopqrstuvwxy"];' +
2556
- 'eval("");' +
2557
- 'void ["abcdefghijklmnopqrstuvwx", "abcdefghijklmnopqrstuvwx"];' +
2558
- 'eval("");' +
2559
- '(function() {' +
2560
- ' void ["abcdefgh", "abcdefgh"];' +
2561
- '}());' +
2562
- '(function() {' +
2563
- ' void ["abcdefghijklmnopqrstuvwxy",' +
2564
- ' "abcdefghijklmnopqrstuvwxy"];' +
2565
- ' eval("");' +
2566
- ' void ["abcdefghijklmnopqrstuvwx",' +
2567
- ' "abcdefghijklmnopqrstuvwx"];' +
2568
- ' eval("");' +
2569
- ' (function() {' +
2570
- ' void ["abcdefgh", "abcdefgh"];' +
2571
- ' }());' +
2572
- '}());',
2573
- sOutput:
2574
- '/*jshint evil:true */' +
2575
- '(function() {' +
2576
- ' var a = "abcdefghijklmnopqrstuvwxy";' +
2577
- ' void [a, a];' +
2578
- '}());' +
2579
- 'eval("");' +
2580
- 'void ["abcdefghijklmnopqrstuvwx", "abcdefghijklmnopqrstuvwx"];' +
2581
- 'eval("");' +
2582
- '(function() {' +
2583
- ' var a = "abcdefgh";' +
2584
- ' void [a, a];' +
2585
- '}());' +
2586
- '(function() {' +
2587
- ' (function() {' +
2588
- ' var a = "abcdefghijklmnopqrstuvwxy";' +
2589
- ' void [a, a];' +
2590
- ' }());' +
2591
- ' eval("");' +
2592
- ' void ["abcdefghijklmnopqrstuvwx", "abcdefghijklmnopqrstuvwx"];' +
2593
- ' eval("");' +
2594
- ' (function() {' +
2595
- ' var a = "abcdefgh";' +
2596
- ' void [a, a];' +
2597
- ' }());' +
2598
- '}());'
2599
- },
2600
- {
2601
- sTitle:
2602
- 'Employment of a closure while consolidating in global code.',
2603
- sInput:
2604
- 'void ["abcdefghijklmnopqrstuvwxyz",' +
2605
- ' "abcdefghijklmnopqrstuvwxyz"];',
2606
- sOutput:
2607
- '(function() {' +
2608
- ' var a = "abcdefghijklmnopqrstuvwxyz";' +
2609
- ' void [a, a];' +
2610
- '}());'
2611
- },
2612
- {
2613
- sTitle:
2614
- 'Assignment of a shorter identifier to a value whose ' +
2615
- 'consolidation results in a greater reduction of the number of ' +
2616
- 'source characters.',
2617
- sInput:
2618
- '(function() {' +
2619
- ' var b, c, d, e, f, g, h, i, j, k, l, m,' +
2620
- ' n, o, p, q, r, s, t, u, v, w, x, y, z,' +
2621
- ' A, B, C, D, E, F, G, H, I, J, K, L, M,' +
2622
- ' N, O, P, Q, R, S, T, U, V, W, X, Y, Z,' +
2623
- ' $, _;' +
2624
- ' void ["abcde", "abcde", "edcba", "edcba", "edcba"];' +
2625
- '}());',
2626
- sOutput:
2627
- '(function() {' +
2628
- ' var a = "edcba",' +
2629
- ' b, c, d, e, f, g, h, i, j, k, l, m,' +
2630
- ' n, o, p, q, r, s, t, u, v, w, x, y, z,' +
2631
- ' A, B, C, D, E, F, G, H, I, J, K, L, M,' +
2632
- ' N, O, P, Q, R, S, T, U, V, W, X, Y, Z,' +
2633
- ' $, _;' +
2634
- ' void ["abcde", "abcde", a, a, a];' +
2635
- '}());'
2636
- }
2637
- ].forEach(cAssert);
2638
- }());
2639
- }
2640
-
2641
1262
  /* Local Variables: */
2642
1263
  /* mode: js */
2643
1264
  /* coding: utf-8 */
@@ -2848,12 +1469,11 @@ var REGEXP_MODIFIERS = array_to_hash(characters("gmsiy"));
2848
1469
 
2849
1470
  /* -----[ Tokenizer ]----- */
2850
1471
 
2851
- // regexps adapted from http://xregexp.com/plugins/#unicode
2852
- var UNICODE = {
2853
- letter: new RegExp("[\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u0523\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0621-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971\\u0972\\u097B-\\u097F\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D28\\u0D2A-\\u0D39\\u0D3D\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC\\u0EDD\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8B\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10D0-\\u10FA\\u10FC\\u1100-\\u1159\\u115F-\\u11A2\\u11A8-\\u11F9\\u1200-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u1676\\u1681-\\u169A\\u16A0-\\u16EA\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19A9\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u2094\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2C6F\\u2C71-\\u2C7D\\u2C80-\\u2CE4\\u2D00-\\u2D25\\u2D30-\\u2D65\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31B7\\u31F0-\\u31FF\\u3400\\u4DB5\\u4E00\\u9FC3\\uA000-\\uA48C\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA65F\\uA662-\\uA66E\\uA67F-\\uA697\\uA717-\\uA71F\\uA722-\\uA788\\uA78B\\uA78C\\uA7FB-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA90A-\\uA925\\uA930-\\uA946\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAC00\\uD7A3\\uF900-\\uFA2D\\uFA30-\\uFA6A\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"),
2854
- non_spacing_mark: new RegExp("[\\u0300-\\u036F\\u0483-\\u0487\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u0610-\\u061A\\u064B-\\u065E\\u0670\\u06D6-\\u06DC\\u06DF-\\u06E4\\u06E7\\u06E8\\u06EA-\\u06ED\\u0711\\u0730-\\u074A\\u07A6-\\u07B0\\u07EB-\\u07F3\\u0816-\\u0819\\u081B-\\u0823\\u0825-\\u0827\\u0829-\\u082D\\u0900-\\u0902\\u093C\\u0941-\\u0948\\u094D\\u0951-\\u0955\\u0962\\u0963\\u0981\\u09BC\\u09C1-\\u09C4\\u09CD\\u09E2\\u09E3\\u0A01\\u0A02\\u0A3C\\u0A41\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A70\\u0A71\\u0A75\\u0A81\\u0A82\\u0ABC\\u0AC1-\\u0AC5\\u0AC7\\u0AC8\\u0ACD\\u0AE2\\u0AE3\\u0B01\\u0B3C\\u0B3F\\u0B41-\\u0B44\\u0B4D\\u0B56\\u0B62\\u0B63\\u0B82\\u0BC0\\u0BCD\\u0C3E-\\u0C40\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C62\\u0C63\\u0CBC\\u0CBF\\u0CC6\\u0CCC\\u0CCD\\u0CE2\\u0CE3\\u0D41-\\u0D44\\u0D4D\\u0D62\\u0D63\\u0DCA\\u0DD2-\\u0DD4\\u0DD6\\u0E31\\u0E34-\\u0E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB4-\\u0EB9\\u0EBB\\u0EBC\\u0EC8-\\u0ECD\\u0F18\\u0F19\\u0F35\\u0F37\\u0F39\\u0F71-\\u0F7E\\u0F80-\\u0F84\\u0F86\\u0F87\\u0F90-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u102D-\\u1030\\u1032-\\u1037\\u1039\\u103A\\u103D\\u103E\\u1058\\u1059\\u105E-\\u1060\\u1071-\\u1074\\u1082\\u1085\\u1086\\u108D\\u109D\\u135F\\u1712-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17B7-\\u17BD\\u17C6\\u17C9-\\u17D3\\u17DD\\u180B-\\u180D\\u18A9\\u1920-\\u1922\\u1927\\u1928\\u1932\\u1939-\\u193B\\u1A17\\u1A18\\u1A56\\u1A58-\\u1A5E\\u1A60\\u1A62\\u1A65-\\u1A6C\\u1A73-\\u1A7C\\u1A7F\\u1B00-\\u1B03\\u1B34\\u1B36-\\u1B3A\\u1B3C\\u1B42\\u1B6B-\\u1B73\\u1B80\\u1B81\\u1BA2-\\u1BA5\\u1BA8\\u1BA9\\u1C2C-\\u1C33\\u1C36\\u1C37\\u1CD0-\\u1CD2\\u1CD4-\\u1CE0\\u1CE2-\\u1CE8\\u1CED\\u1DC0-\\u1DE6\\u1DFD-\\u1DFF\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2CEF-\\u2CF1\\u2DE0-\\u2DFF\\u302A-\\u302F\\u3099\\u309A\\uA66F\\uA67C\\uA67D\\uA6F0\\uA6F1\\uA802\\uA806\\uA80B\\uA825\\uA826\\uA8C4\\uA8E0-\\uA8F1\\uA926-\\uA92D\\uA947-\\uA951\\uA980-\\uA982\\uA9B3\\uA9B6-\\uA9B9\\uA9BC\\uAA29-\\uAA2E\\uAA31\\uAA32\\uAA35\\uAA36\\uAA43\\uAA4C\\uAAB0\\uAAB2-\\uAAB4\\uAAB7\\uAAB8\\uAABE\\uAABF\\uAAC1\\uABE5\\uABE8\\uABED\\uFB1E\\uFE00-\\uFE0F\\uFE20-\\uFE26]"),
2855
- space_combining_mark: new RegExp("[\\u0903\\u093E-\\u0940\\u0949-\\u094C\\u094E\\u0982\\u0983\\u09BE-\\u09C0\\u09C7\\u09C8\\u09CB\\u09CC\\u09D7\\u0A03\\u0A3E-\\u0A40\\u0A83\\u0ABE-\\u0AC0\\u0AC9\\u0ACB\\u0ACC\\u0B02\\u0B03\\u0B3E\\u0B40\\u0B47\\u0B48\\u0B4B\\u0B4C\\u0B57\\u0BBE\\u0BBF\\u0BC1\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCC\\u0BD7\\u0C01-\\u0C03\\u0C41-\\u0C44\\u0C82\\u0C83\\u0CBE\\u0CC0-\\u0CC4\\u0CC7\\u0CC8\\u0CCA\\u0CCB\\u0CD5\\u0CD6\\u0D02\\u0D03\\u0D3E-\\u0D40\\u0D46-\\u0D48\\u0D4A-\\u0D4C\\u0D57\\u0D82\\u0D83\\u0DCF-\\u0DD1\\u0DD8-\\u0DDF\\u0DF2\\u0DF3\\u0F3E\\u0F3F\\u0F7F\\u102B\\u102C\\u1031\\u1038\\u103B\\u103C\\u1056\\u1057\\u1062-\\u1064\\u1067-\\u106D\\u1083\\u1084\\u1087-\\u108C\\u108F\\u109A-\\u109C\\u17B6\\u17BE-\\u17C5\\u17C7\\u17C8\\u1923-\\u1926\\u1929-\\u192B\\u1930\\u1931\\u1933-\\u1938\\u19B0-\\u19C0\\u19C8\\u19C9\\u1A19-\\u1A1B\\u1A55\\u1A57\\u1A61\\u1A63\\u1A64\\u1A6D-\\u1A72\\u1B04\\u1B35\\u1B3B\\u1B3D-\\u1B41\\u1B43\\u1B44\\u1B82\\u1BA1\\u1BA6\\u1BA7\\u1BAA\\u1C24-\\u1C2B\\u1C34\\u1C35\\u1CE1\\u1CF2\\uA823\\uA824\\uA827\\uA880\\uA881\\uA8B4-\\uA8C3\\uA952\\uA953\\uA983\\uA9B4\\uA9B5\\uA9BA\\uA9BB\\uA9BD-\\uA9C0\\uAA2F\\uAA30\\uAA33\\uAA34\\uAA4D\\uAA7B\\uABE3\\uABE4\\uABE6\\uABE7\\uABE9\\uABEA\\uABEC]"),
2856
- connector_punctuation: new RegExp("[\\u005F\\u203F\\u2040\\u2054\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFF3F]")
1472
+ var UNICODE = { // Unicode 6.1
1473
+ letter: new RegExp("[\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u0527\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0\\u08A2-\\u08AC\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0977\\u0979-\\u097F\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F0\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA697\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA793\\uA7A0-\\uA7AA\\uA7F8-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA80-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"),
1474
+ combining_mark: new RegExp("[\\u0300-\\u036F\\u0483-\\u0487\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u0610-\\u061A\\u064B-\\u065F\\u0670\\u06D6-\\u06DC\\u06DF-\\u06E4\\u06E7\\u06E8\\u06EA-\\u06ED\\u0711\\u0730-\\u074A\\u07A6-\\u07B0\\u07EB-\\u07F3\\u0816-\\u0819\\u081B-\\u0823\\u0825-\\u0827\\u0829-\\u082D\\u0859-\\u085B\\u08E4-\\u08FE\\u0900-\\u0903\\u093A-\\u093C\\u093E-\\u094F\\u0951-\\u0957\\u0962\\u0963\\u0981-\\u0983\\u09BC\\u09BE-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CD\\u09D7\\u09E2\\u09E3\\u0A01-\\u0A03\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A70\\u0A71\\u0A75\\u0A81-\\u0A83\\u0ABC\\u0ABE-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AE2\\u0AE3\\u0B01-\\u0B03\\u0B3C\\u0B3E-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B62\\u0B63\\u0B82\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD7\\u0C01-\\u0C03\\u0C3E-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C62\\u0C63\\u0C82\\u0C83\\u0CBC\\u0CBE-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CE2\\u0CE3\\u0D02\\u0D03\\u0D3E-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4D\\u0D57\\u0D62\\u0D63\\u0D82\\u0D83\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DF2\\u0DF3\\u0E31\\u0E34-\\u0E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB4-\\u0EB9\\u0EBB\\u0EBC\\u0EC8-\\u0ECD\\u0F18\\u0F19\\u0F35\\u0F37\\u0F39\\u0F3E\\u0F3F\\u0F71-\\u0F84\\u0F86\\u0F87\\u0F8D-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u102B-\\u103E\\u1056-\\u1059\\u105E-\\u1060\\u1062-\\u1064\\u1067-\\u106D\\u1071-\\u1074\\u1082-\\u108D\\u108F\\u109A-\\u109D\\u135D-\\u135F\\u1712-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17B4-\\u17D3\\u17DD\\u180B-\\u180D\\u18A9\\u1920-\\u192B\\u1930-\\u193B\\u19B0-\\u19C0\\u19C8\\u19C9\\u1A17-\\u1A1B\\u1A55-\\u1A5E\\u1A60-\\u1A7C\\u1A7F\\u1B00-\\u1B04\\u1B34-\\u1B44\\u1B6B-\\u1B73\\u1B80-\\u1B82\\u1BA1-\\u1BAD\\u1BE6-\\u1BF3\\u1C24-\\u1C37\\u1CD0-\\u1CD2\\u1CD4-\\u1CE8\\u1CED\\u1CF2-\\u1CF4\\u1DC0-\\u1DE6\\u1DFC-\\u1DFF\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2CEF-\\u2CF1\\u2D7F\\u2DE0-\\u2DFF\\u302A-\\u302F\\u3099\\u309A\\uA66F\\uA674-\\uA67D\\uA69F\\uA6F0\\uA6F1\\uA802\\uA806\\uA80B\\uA823-\\uA827\\uA880\\uA881\\uA8B4-\\uA8C4\\uA8E0-\\uA8F1\\uA926-\\uA92D\\uA947-\\uA953\\uA980-\\uA983\\uA9B3-\\uA9C0\\uAA29-\\uAA36\\uAA43\\uAA4C\\uAA4D\\uAA7B\\uAAB0\\uAAB2-\\uAAB4\\uAAB7\\uAAB8\\uAABE\\uAABF\\uAAC1\\uAAEB-\\uAAEF\\uAAF5\\uAAF6\\uABE3-\\uABEA\\uABEC\\uABED\\uFB1E\\uFE00-\\uFE0F\\uFE20-\\uFE26]"),
1475
+ connector_punctuation: new RegExp("[\\u005F\\u203F\\u2040\\u2054\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFF3F]"),
1476
+ digit: new RegExp("[\\u0030-\\u0039\\u0660-\\u0669\\u06F0-\\u06F9\\u07C0-\\u07C9\\u0966-\\u096F\\u09E6-\\u09EF\\u0A66-\\u0A6F\\u0AE6-\\u0AEF\\u0B66-\\u0B6F\\u0BE6-\\u0BEF\\u0C66-\\u0C6F\\u0CE6-\\u0CEF\\u0D66-\\u0D6F\\u0E50-\\u0E59\\u0ED0-\\u0ED9\\u0F20-\\u0F29\\u1040-\\u1049\\u1090-\\u1099\\u17E0-\\u17E9\\u1810-\\u1819\\u1946-\\u194F\\u19D0-\\u19D9\\u1A80-\\u1A89\\u1A90-\\u1A99\\u1B50-\\u1B59\\u1BB0-\\u1BB9\\u1C40-\\u1C49\\u1C50-\\u1C59\\uA620-\\uA629\\uA8D0-\\uA8D9\\uA900-\\uA909\\uA9D0-\\uA9D9\\uAA50-\\uAA59\\uABF0-\\uABF9\\uFF10-\\uFF19]")
2857
1477
  };
2858
1478
 
2859
1479
  function is_letter(ch) {
@@ -2862,15 +1482,19 @@ function is_letter(ch) {
2862
1482
 
2863
1483
  function is_digit(ch) {
2864
1484
  ch = ch.charCodeAt(0);
2865
- return ch >= 48 && ch <= 57; //XXX: find out if "UnicodeDigit" means something else than 0..9
1485
+ return ch >= 48 && ch <= 57;
2866
1486
  };
2867
1487
 
1488
+ function is_unicode_digit(ch) {
1489
+ return UNICODE.digit.test(ch);
1490
+ }
1491
+
2868
1492
  function is_alphanumeric_char(ch) {
2869
1493
  return is_digit(ch) || is_letter(ch);
2870
1494
  };
2871
1495
 
2872
1496
  function is_unicode_combining_mark(ch) {
2873
- return UNICODE.non_spacing_mark.test(ch) || UNICODE.space_combining_mark.test(ch);
1497
+ return UNICODE.combining_mark.test(ch);
2874
1498
  };
2875
1499
 
2876
1500
  function is_unicode_connector_punctuation(ch) {
@@ -2884,7 +1508,7 @@ function is_identifier_start(ch) {
2884
1508
  function is_identifier_char(ch) {
2885
1509
  return is_identifier_start(ch)
2886
1510
  || is_unicode_combining_mark(ch)
2887
- || is_digit(ch)
1511
+ || is_unicode_digit(ch)
2888
1512
  || is_unicode_connector_punctuation(ch)
2889
1513
  || ch == "\u200c" // zero-width non-joiner <ZWNJ>
2890
1514
  || ch == "\u200d" // zero-width joiner <ZWJ> (in my ECMA-262 PDF, this is also 200c)
@@ -2986,6 +1610,10 @@ function tokenizer($TEXT) {
2986
1610
  if (!is_comment) {
2987
1611
  ret.comments_before = S.comments_before;
2988
1612
  S.comments_before = [];
1613
+ // make note of any newlines in the comments that came before
1614
+ for (var i = 0, len = ret.comments_before.length; i < len; i++) {
1615
+ ret.nlb = ret.nlb || ret.comments_before[i].nlb;
1616
+ }
2989
1617
  }
2990
1618
  S.newline_before = false;
2991
1619
  return ret;
@@ -3027,7 +1655,7 @@ function tokenizer($TEXT) {
3027
1655
  if (ch == "+") return after_e;
3028
1656
  after_e = false;
3029
1657
  if (ch == ".") {
3030
- if (!has_dot && !has_x)
1658
+ if (!has_dot && !has_x && !has_e)
3031
1659
  return has_dot = true;
3032
1660
  return false;
3033
1661
  }
@@ -3121,7 +1749,7 @@ function tokenizer($TEXT) {
3121
1749
  text = S.text.substring(S.pos, i);
3122
1750
  S.pos = i + 2;
3123
1751
  S.line += text.split("\n").length - 1;
3124
- S.newline_before = text.indexOf("\n") >= 0;
1752
+ S.newline_before = S.newline_before || text.indexOf("\n") >= 0;
3125
1753
 
3126
1754
  // https://github.com/mishoo/UglifyJS/issues/#issue/100
3127
1755
  if (/^@cc_on/i.test(text)) {
@@ -3333,13 +1961,14 @@ NodeWithToken.prototype.toString = function() { return this.name; };
3333
1961
  function parse($TEXT, exigent_mode, embed_tokens) {
3334
1962
 
3335
1963
  var S = {
3336
- input : typeof $TEXT == "string" ? tokenizer($TEXT, true) : $TEXT,
3337
- token : null,
3338
- prev : null,
3339
- peeked : null,
3340
- in_function : 0,
3341
- in_loop : 0,
3342
- labels : []
1964
+ input : typeof $TEXT == "string" ? tokenizer($TEXT, true) : $TEXT,
1965
+ token : null,
1966
+ prev : null,
1967
+ peeked : null,
1968
+ in_function : 0,
1969
+ in_directives : true,
1970
+ in_loop : 0,
1971
+ labels : []
3343
1972
  };
3344
1973
 
3345
1974
  S.token = next();
@@ -3358,6 +1987,9 @@ function parse($TEXT, exigent_mode, embed_tokens) {
3358
1987
  } else {
3359
1988
  S.token = S.input();
3360
1989
  }
1990
+ S.in_directives = S.in_directives && (
1991
+ S.token.type == "string" || is("punc", ";")
1992
+ );
3361
1993
  return S.token;
3362
1994
  };
3363
1995
 
@@ -3434,8 +2066,12 @@ function parse($TEXT, exigent_mode, embed_tokens) {
3434
2066
  S.token = S.input(S.token.value.substr(1)); // force regexp
3435
2067
  }
3436
2068
  switch (S.token.type) {
3437
- case "num":
3438
2069
  case "string":
2070
+ var dir = S.in_directives, stat = simple_statement();
2071
+ if (dir && stat[1][0] == "string" && !is("punc", ","))
2072
+ return as("directive", stat[1][1]);
2073
+ return stat;
2074
+ case "num":
3439
2075
  case "regexp":
3440
2076
  case "operator":
3441
2077
  case "atom":
@@ -3610,6 +2246,7 @@ function parse($TEXT, exigent_mode, embed_tokens) {
3610
2246
  (function(){
3611
2247
  ++S.in_function;
3612
2248
  var loop = S.in_loop;
2249
+ S.in_directives = true;
3613
2250
  S.in_loop = 0;
3614
2251
  var a = block_();
3615
2252
  --S.in_function;
@@ -4197,6 +2834,9 @@ function ast_walker() {
4197
2834
  },
4198
2835
  "atom": function(name) {
4199
2836
  return [ this[0], name ];
2837
+ },
2838
+ "directive": function(dir) {
2839
+ return [ this[0], dir ];
4200
2840
  }
4201
2841
  };
4202
2842
 
@@ -4269,6 +2909,7 @@ function Scope(parent) {
4269
2909
  this.refs = {}; // names referenced from this scope
4270
2910
  this.uses_with = false; // will become TRUE if with() is detected in this or any subscopes
4271
2911
  this.uses_eval = false; // will become TRUE if eval() is detected in this or any subscopes
2912
+ this.directives = []; // directives activated from this scope
4272
2913
  this.parent = parent; // parent scope
4273
2914
  this.children = []; // sub-scopes
4274
2915
  if (parent) {
@@ -4279,8 +2920,15 @@ function Scope(parent) {
4279
2920
  }
4280
2921
  };
4281
2922
 
2923
+ function base54_digits() {
2924
+ if (typeof DIGITS_OVERRIDE_FOR_TESTING != "undefined")
2925
+ return DIGITS_OVERRIDE_FOR_TESTING;
2926
+ else
2927
+ return "etnrisouaflchpdvmgybwESxTNCkLAOM_DPHBjFIqRUzWXV$JKQGYZ0516372984";
2928
+ }
2929
+
4282
2930
  var base54 = (function(){
4283
- var DIGITS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789";
2931
+ var DIGITS = base54_digits();
4284
2932
  return function(num) {
4285
2933
  var ret = "", base = 54;
4286
2934
  do {
@@ -4371,6 +3019,9 @@ Scope.prototype = {
4371
3019
  this.names[name] = type || "var";
4372
3020
  return name;
4373
3021
  }
3022
+ },
3023
+ active: function(dir) {
3024
+ return member(dir, this.directives) || this.parent && this.parent.active(dir);
4374
3025
  }
4375
3026
  };
4376
3027
 
@@ -4490,12 +3141,22 @@ function ast_add_scope(ast) {
4490
3141
 
4491
3142
  function ast_mangle(ast, options) {
4492
3143
  var w = ast_walker(), walk = w.walk, scope;
4493
- options = options || {};
3144
+ options = defaults(options, {
3145
+ mangle : true,
3146
+ toplevel : false,
3147
+ defines : null,
3148
+ except : null,
3149
+ no_functions : false
3150
+ });
4494
3151
 
4495
3152
  function get_mangled(name, newMangle) {
3153
+ if (!options.mangle) return name;
4496
3154
  if (!options.toplevel && !scope.parent) return name; // don't mangle toplevel
4497
3155
  if (options.except && member(name, options.except))
4498
3156
  return name;
3157
+ if (options.no_functions && HOP(scope.names, name) &&
3158
+ (scope.names[name] == 'defun' || scope.names[name] == 'lambda'))
3159
+ return name;
4499
3160
  return scope.get_mangled(name, newMangle);
4500
3161
  };
4501
3162
 
@@ -4513,7 +3174,7 @@ function ast_mangle(ast, options) {
4513
3174
  };
4514
3175
 
4515
3176
  function _lambda(name, args, body) {
4516
- if (!options.no_functions) {
3177
+ if (!options.no_functions && options.mangle) {
4517
3178
  var is_defun = this[0] == "defun", extra;
4518
3179
  if (name) {
4519
3180
  if (is_defun) name = get_mangled(name);
@@ -4599,6 +3260,9 @@ function ast_mangle(ast, options) {
4599
3260
  return with_scope(self.scope, function(){
4600
3261
  return [ self[0], MAP(body, walk) ];
4601
3262
  });
3263
+ },
3264
+ "directive": function() {
3265
+ return MAP.at_top(this);
4602
3266
  }
4603
3267
  }, function() {
4604
3268
  return walk(ast_add_scope(ast));
@@ -4993,10 +3657,11 @@ function ast_squeeze(ast, options) {
4993
3657
  make_seqs : true,
4994
3658
  dead_code : true,
4995
3659
  no_warnings : false,
4996
- keep_comps : true
3660
+ keep_comps : true,
3661
+ unsafe : false
4997
3662
  });
4998
3663
 
4999
- var w = ast_walker(), walk = w.walk;
3664
+ var w = ast_walker(), walk = w.walk, scope;
5000
3665
 
5001
3666
  function negate(c) {
5002
3667
  var not_c = [ "unary-prefix", "!", c ];
@@ -5059,7 +3724,17 @@ function ast_squeeze(ast, options) {
5059
3724
  };
5060
3725
 
5061
3726
  function _lambda(name, args, body) {
5062
- return [ this[0], name, args, tighten(body, "lambda") ];
3727
+ return [ this[0], name, args, with_scope(body.scope, function() {
3728
+ return tighten(body, "lambda");
3729
+ }) ];
3730
+ };
3731
+
3732
+ function with_scope(s, cont) {
3733
+ var _scope = scope;
3734
+ scope = s;
3735
+ var ret = cont();
3736
+ scope = _scope;
3737
+ return ret;
5063
3738
  };
5064
3739
 
5065
3740
  // this function does a few things:
@@ -5199,6 +3874,9 @@ function ast_squeeze(ast, options) {
5199
3874
  t = walk(t);
5200
3875
  e = walk(e);
5201
3876
 
3877
+ if (empty(e) && empty(t))
3878
+ return [ "stat", c ];
3879
+
5202
3880
  if (empty(t)) {
5203
3881
  c = negate(c);
5204
3882
  t = e;
@@ -5219,8 +3897,6 @@ function ast_squeeze(ast, options) {
5219
3897
  }
5220
3898
  })();
5221
3899
  }
5222
- if (empty(e) && empty(t))
5223
- return [ "stat", c ];
5224
3900
  var ret = [ "if", c, t, e ];
5225
3901
  if (t[0] == "if" && empty(t[3]) && empty(e)) {
5226
3902
  ret = best_of(ret, walk([ "if", [ "binary", "&&", c, t[1] ], t[2] ]));
@@ -5278,7 +3954,9 @@ function ast_squeeze(ast, options) {
5278
3954
  },
5279
3955
  "if": make_if,
5280
3956
  "toplevel": function(body) {
5281
- return [ "toplevel", tighten(body) ];
3957
+ return with_scope(this.scope, function() {
3958
+ return [ "toplevel", tighten(body) ];
3959
+ });
5282
3960
  },
5283
3961
  "switch": function(expr, body) {
5284
3962
  var last = body.length - 1;
@@ -5349,11 +4027,33 @@ function ast_squeeze(ast, options) {
5349
4027
  return [ this[0], rvalue[1], lvalue, rvalue[3] ]
5350
4028
  }
5351
4029
  return [ this[0], op, lvalue, rvalue ];
4030
+ },
4031
+ "directive": function(dir) {
4032
+ if (scope.active(dir))
4033
+ return [ "block" ];
4034
+ scope.directives.push(dir);
4035
+ return [ this[0], dir ];
4036
+ },
4037
+ "call": function(expr, args) {
4038
+ expr = walk(expr);
4039
+ if (options.unsafe && expr[0] == "dot" && expr[1][0] == "string" && expr[2] == "toString") {
4040
+ return expr[1];
4041
+ }
4042
+ return [ this[0], expr, MAP(args, walk) ];
4043
+ },
4044
+ "num": function (num) {
4045
+ if (!isFinite(num))
4046
+ return [ "binary", "/", num === 1 / 0
4047
+ ? [ "num", 1 ] : num === -1 / 0
4048
+ ? [ "unary-prefix", "-", [ "num", 1 ] ]
4049
+ : [ "num", 0 ], [ "num", 0 ] ];
4050
+
4051
+ return [ this[0], num ];
5352
4052
  }
5353
4053
  }, function() {
5354
4054
  for (var i = 0; i < 2; ++i) {
5355
4055
  ast = prepare_ifs(ast);
5356
- ast = walk(ast);
4056
+ ast = walk(ast_add_scope(ast));
5357
4057
  }
5358
4058
  return ast;
5359
4059
  });
@@ -5517,7 +4217,7 @@ function gen_code(ast, options) {
5517
4217
  };
5518
4218
 
5519
4219
  function make_num(num) {
5520
- var str = num.toString(10), a = [ str.replace(/^0\./, ".") ], m;
4220
+ var str = num.toString(10), a = [ str.replace(/^0\./, ".").replace('e+', 'e') ], m;
5521
4221
  if (Math.floor(num) === num) {
5522
4222
  if (num >= 0) {
5523
4223
  a.push("0x" + num.toString(16).toLowerCase(), // probably pointless
@@ -5542,7 +4242,7 @@ function gen_code(ast, options) {
5542
4242
  "string": encode_string,
5543
4243
  "num": make_num,
5544
4244
  "name": make_name,
5545
- "debugger": function(){ return "debugger" },
4245
+ "debugger": function(){ return "debugger;" },
5546
4246
  "toplevel": function(statements) {
5547
4247
  return make_block_statements(statements)
5548
4248
  .join(newline + newline);
@@ -5624,7 +4324,7 @@ function gen_code(ast, options) {
5624
4324
  "dot": function(expr) {
5625
4325
  var out = make(expr), i = 1;
5626
4326
  if (expr[0] == "num") {
5627
- if (!/\./.test(expr[1]))
4327
+ if (!/[a-f.]/i.test(out))
5628
4328
  out += ".";
5629
4329
  } else if (expr[0] != "function" && needs_parens(expr))
5630
4330
  out = "(" + out + ")";
@@ -5743,6 +4443,7 @@ function gen_code(ast, options) {
5743
4443
  return obj_needs_parens ? "(" + out + ")" : out;
5744
4444
  },
5745
4445
  "regexp": function(rx, mods) {
4446
+ if (options.ascii_only) rx = to_ascii(rx);
5746
4447
  return "/" + rx + "/" + mods;
5747
4448
  },
5748
4449
  "array": function(elements) {
@@ -5766,6 +4467,9 @@ function gen_code(ast, options) {
5766
4467
  },
5767
4468
  "atom": function(name) {
5768
4469
  return make_name(name);
4470
+ },
4471
+ "directive": function(dir) {
4472
+ return make_string(dir) + ";";
5769
4473
  }
5770
4474
  }, function(){ return make(ast) });
5771
4475
 
@@ -5815,10 +4519,10 @@ function gen_code(ast, options) {
5815
4519
  switch (node[0]) {
5816
4520
  case "with":
5817
4521
  case "while":
5818
- return empty(node[2]); // `with' or `while' with empty body?
4522
+ return empty(node[2]) || must_has_semicolon(node[2]);
5819
4523
  case "for":
5820
4524
  case "for-in":
5821
- return empty(node[4]); // `for' with empty body?
4525
+ return empty(node[4]) || must_has_semicolon(node[4]);
5822
4526
  case "if":
5823
4527
  if (empty(node[2]) && !node[3]) return true; // `if' with empty `then' and no `else'
5824
4528
  if (node[3]) {
@@ -5826,6 +4530,8 @@ function gen_code(ast, options) {
5826
4530
  return must_has_semicolon(node[3]); // dive into the `else' branch
5827
4531
  }
5828
4532
  return must_has_semicolon(node[2]); // dive into the `then' branch
4533
+ case "directive":
4534
+ return true;
5829
4535
  }
5830
4536
  };
5831
4537
 
@@ -6057,6 +4763,7 @@ function ast_squeeze_more(ast) {
6057
4763
  }
6058
4764
  if (expr[0] == "dot" && expr[2] == "toString" && args.length == 0) {
6059
4765
  // foo.toString() ==> foo+""
4766
+ if (expr[1][0] == "string") return expr[1];
6060
4767
  return [ "binary", "+", expr[1], [ "string", "" ]];
6061
4768
  }
6062
4769
  if (expr[0] == "name") {