requirejs-rails 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 215e666fcb80a992bf5aab5f0204e8758caf9fd5
4
- data.tar.gz: a0cc4708683e1133a861904043e0021778782e63
3
+ metadata.gz: 164acbc04d1af8d41a62781a38bd12a79938d8af
4
+ data.tar.gz: bcd19769e40757d0d68d8d5fcd8ce9f8c0592cd0
5
5
  SHA512:
6
- metadata.gz: c40c97f588521948cf3142518d752094bd94f07acab7f4945a05c932427ae2c5cf7bb9fcafa8d8222a8d72a3466ff7305b705c7a84672a8585800a7cc6677443
7
- data.tar.gz: 9fb4030834836dfb4a31b25090f884ac904c42a79fe39c88d75af77b1350b722096db894377a0569b2d5d6f63801877b1730ae328f6daedfcab5832be51fe319
6
+ metadata.gz: 946512c5a0e1b7e3c7c53ab9d5881e47f2f3ed73617d8a7205ff5f5cca644b3e5c12d55027d6213b6d1fce48bb0d2217a0705fbba662f8443ec1057f5a33bc53
7
+ data.tar.gz: 3b6f1499207ecdbbf413f621c6b8fbeabea3a327fd3db4d49d092927a87cd022fb5d715c0c0d7d8ff9dcd2297c8f83456bf4ece6e53e5d4161dd4c4b87f82403
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## requirejs-rails changelog
4
4
 
5
+ ### v0.9.9
6
+
7
+ - Fix an asset digesting regression in #238 (credit @jonhyman).
8
+ - Update `require.js` and `r.js` to `2.1.19`.
9
+
5
10
  ### v0.9.8
6
11
 
7
12
  - Fix a bad regression and yank v0.9.7.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- requirejs-rails (0.9.7)
4
+ requirejs-rails (0.9.9)
5
5
  railties (>= 3.1.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -148,7 +148,7 @@ wrap: true
148
148
  The `requirejs-rails` build process uses the Asset Pipeline to assemble assets
149
149
  for the `r.js` build. By default, assets ending in `.js`, `.html`, and `.txt`
150
150
  will be made available to the build. If you have other asset suffixes to
151
- include, use the `logical_asset_filter` config setting to add them.
151
+ include, use the `logical_path_patterns` config setting to add them.
152
152
 
153
153
  For example, if your templates all end in `.templ` like so...
154
154
 
@@ -164,7 +164,7 @@ define(function (require) {
164
164
 
165
165
  ```ruby
166
166
  # in config/application.rb
167
- config.requirejs.logical_asset_filter += [/\.templ$/]
167
+ config.requirejs.logical_path_patterns += [/\.templ$/]
168
168
  ```
169
169
 
170
170
  ## Advanced features
data/bin/r.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license r.js 2.1.17 Copyright (c) 2010-2015, The Dojo Foundation All Rights Reserved.
2
+ * @license r.js 2.1.19 Copyright (c) 2010-2015, The Dojo Foundation All Rights Reserved.
3
3
  * Available via the MIT or new BSD license.
4
4
  * see: http://github.com/jrburke/requirejs for details
5
5
  */
@@ -20,7 +20,7 @@ var requirejs, require, define, xpcUtil;
20
20
  (function (console, args, readFileFunc) {
21
21
  var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
22
22
  nodeDefine, exists, reqMain, loadedOptimizedLib, existsForNode, Cc, Ci,
23
- version = '2.1.17',
23
+ version = '2.1.19',
24
24
  jsSuffixRegExp = /\.js$/,
25
25
  commandOption = '',
26
26
  useLibLoaded = {},
@@ -249,7 +249,7 @@ var requirejs, require, define, xpcUtil;
249
249
  }
250
250
 
251
251
  /** vim: et:ts=4:sw=4:sts=4
252
- * @license RequireJS 2.1.17 Copyright (c) 2010-2015, The Dojo Foundation All Rights Reserved.
252
+ * @license RequireJS 2.1.19 Copyright (c) 2010-2015, The Dojo Foundation All Rights Reserved.
253
253
  * Available via the MIT or new BSD license.
254
254
  * see: http://github.com/jrburke/requirejs for details
255
255
  */
@@ -262,7 +262,7 @@ var requirejs, require, define, xpcUtil;
262
262
  (function (global) {
263
263
  var req, s, head, baseElement, dataMain, src,
264
264
  interactiveScript, currentlyAddingScript, mainScript, subPath,
265
- version = '2.1.17',
265
+ version = '2.1.19',
266
266
  commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
267
267
  cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
268
268
  jsSuffixRegExp = /\.js$/,
@@ -839,7 +839,7 @@ var requirejs, require, define, xpcUtil;
839
839
  id: mod.map.id,
840
840
  uri: mod.map.url,
841
841
  config: function () {
842
- return getOwn(config.config, mod.map.id) || {};
842
+ return getOwn(config.config, mod.map.id) || {};
843
843
  },
844
844
  exports: mod.exports || (mod.exports = {})
845
845
  });
@@ -1367,6 +1367,9 @@ var requirejs, require, define, xpcUtil;
1367
1367
  this.depCount += 1;
1368
1368
 
1369
1369
  on(depMap, 'defined', bind(this, function (depExports) {
1370
+ if (this.undefed) {
1371
+ return;
1372
+ }
1370
1373
  this.defineDep(i, depExports);
1371
1374
  this.check();
1372
1375
  }));
@@ -1483,7 +1486,8 @@ var requirejs, require, define, xpcUtil;
1483
1486
  while (defQueue.length) {
1484
1487
  args = defQueue.shift();
1485
1488
  if (args[0] === null) {
1486
- return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1]));
1489
+ return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' +
1490
+ args[args.length - 1]));
1487
1491
  } else {
1488
1492
  //args are id, deps, factory. Should be normalized by the
1489
1493
  //define() function.
@@ -1570,7 +1574,7 @@ var requirejs, require, define, xpcUtil;
1570
1574
  each(cfg.packages, function (pkgObj) {
1571
1575
  var location, name;
1572
1576
 
1573
- pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj;
1577
+ pkgObj = typeof pkgObj === 'string' ? {name: pkgObj} : pkgObj;
1574
1578
 
1575
1579
  name = pkgObj.name;
1576
1580
  location = pkgObj.location;
@@ -1597,7 +1601,7 @@ var requirejs, require, define, xpcUtil;
1597
1601
  //late to modify them, and ignore unnormalized ones
1598
1602
  //since they are transient.
1599
1603
  if (!mod.inited && !mod.map.unnormalized) {
1600
- mod.map = makeModuleMap(id);
1604
+ mod.map = makeModuleMap(id, null, true);
1601
1605
  }
1602
1606
  });
1603
1607
 
@@ -1733,6 +1737,7 @@ var requirejs, require, define, xpcUtil;
1733
1737
  var map = makeModuleMap(id, relMap, true),
1734
1738
  mod = getOwn(registry, id);
1735
1739
 
1740
+ mod.undefed = true;
1736
1741
  removeScript(id);
1737
1742
 
1738
1743
  delete defined[id];
@@ -1743,7 +1748,7 @@ var requirejs, require, define, xpcUtil;
1743
1748
  //in array so that the splices do not
1744
1749
  //mess up the iteration.
1745
1750
  eachReverse(defQueue, function(args, i) {
1746
- if(args[0] === id) {
1751
+ if (args[0] === id) {
1747
1752
  defQueue.splice(i, 1);
1748
1753
  }
1749
1754
  });
@@ -2102,6 +2107,9 @@ var requirejs, require, define, xpcUtil;
2102
2107
  if (isBrowser) {
2103
2108
  //In the browser so use a script tag
2104
2109
  node = req.createNode(config, moduleName, url);
2110
+ if (config.onNodeCreated) {
2111
+ config.onNodeCreated(node, config, moduleName, url);
2112
+ }
2105
2113
 
2106
2114
  node.setAttribute('data-requirecontext', context.contextName);
2107
2115
  node.setAttribute('data-requiremodule', moduleName);
@@ -2230,7 +2238,7 @@ var requirejs, require, define, xpcUtil;
2230
2238
  //like a module name.
2231
2239
  mainScript = mainScript.replace(jsSuffixRegExp, '');
2232
2240
 
2233
- //If mainScript is still a path, fall back to dataMain
2241
+ //If mainScript is still a path, fall back to dataMain
2234
2242
  if (req.jsExtRegExp.test(mainScript)) {
2235
2243
  mainScript = dataMain;
2236
2244
  }
@@ -2316,7 +2324,6 @@ var requirejs, require, define, xpcUtil;
2316
2324
  jQuery: true
2317
2325
  };
2318
2326
 
2319
-
2320
2327
  /**
2321
2328
  * Executes the text. Normally just uses eval, but can be modified
2322
2329
  * to use a better, environment-specific call. Only used for transpiling
@@ -2929,7 +2936,8 @@ var prim;
2929
2936
  function check(p) {
2930
2937
  if (hasProp(p, 'e') || hasProp(p, 'v')) {
2931
2938
  if (!prim.hideResolutionConflict) {
2932
- throw new Error('nope');
2939
+ throw new Error('Prim promise already resolved: ' +
2940
+ JSON.stringify(p));
2933
2941
  }
2934
2942
  return false;
2935
2943
  }
@@ -4555,16 +4563,7 @@ define('logger', ['env!env/print'], function (print) {
4555
4563
  //like Node's fs and path.
4556
4564
 
4557
4565
  /*
4558
- Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
4559
- Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
4560
- Copyright (C) 2013 Mathias Bynens <mathias@qiwi.be>
4561
- Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
4562
- Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be>
4563
- Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
4564
- Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com>
4565
- Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
4566
- Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>
4567
- Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
4566
+ Copyright (c) jQuery Foundation, Inc. and Contributors, All Rights Reserved.
4568
4567
 
4569
4568
  Redistribution and use in source and binary forms, with or without
4570
4569
  modification, are permitted provided that the following conditions are met:
@@ -4613,6 +4612,7 @@ define('logger', ['env!env/print'], function (print) {
4613
4612
  Regex,
4614
4613
  source,
4615
4614
  strict,
4615
+ sourceType,
4616
4616
  index,
4617
4617
  lineNumber,
4618
4618
  lineStart,
@@ -4627,7 +4627,10 @@ define('logger', ['env!env/print'], function (print) {
4627
4627
  length,
4628
4628
  lookahead,
4629
4629
  state,
4630
- extra;
4630
+ extra,
4631
+ isBindingElement,
4632
+ isAssignmentTarget,
4633
+ firstCoverInitializedNameError;
4631
4634
 
4632
4635
  Token = {
4633
4636
  BooleanLiteral: 1,
@@ -4638,7 +4641,8 @@ define('logger', ['env!env/print'], function (print) {
4638
4641
  NumericLiteral: 6,
4639
4642
  Punctuator: 7,
4640
4643
  StringLiteral: 8,
4641
- RegularExpression: 9
4644
+ RegularExpression: 9,
4645
+ Template: 10
4642
4646
  };
4643
4647
 
4644
4648
  TokenName = {};
@@ -4651,6 +4655,7 @@ define('logger', ['env!env/print'], function (print) {
4651
4655
  TokenName[Token.Punctuator] = 'Punctuator';
4652
4656
  TokenName[Token.StringLiteral] = 'String';
4653
4657
  TokenName[Token.RegularExpression] = 'RegularExpression';
4658
+ TokenName[Token.Template] = 'Template';
4654
4659
 
4655
4660
  // A function following one of those tokens is an expression.
4656
4661
  FnExprTokens = ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new',
@@ -4665,7 +4670,9 @@ define('logger', ['env!env/print'], function (print) {
4665
4670
 
4666
4671
  Syntax = {
4667
4672
  AssignmentExpression: 'AssignmentExpression',
4673
+ AssignmentPattern: 'AssignmentPattern',
4668
4674
  ArrayExpression: 'ArrayExpression',
4675
+ ArrayPattern: 'ArrayPattern',
4669
4676
  ArrowFunctionExpression: 'ArrowFunctionExpression',
4670
4677
  BlockStatement: 'BlockStatement',
4671
4678
  BinaryExpression: 'BinaryExpression',
@@ -4680,13 +4687,22 @@ define('logger', ['env!env/print'], function (print) {
4680
4687
  DoWhileStatement: 'DoWhileStatement',
4681
4688
  DebuggerStatement: 'DebuggerStatement',
4682
4689
  EmptyStatement: 'EmptyStatement',
4690
+ ExportAllDeclaration: 'ExportAllDeclaration',
4691
+ ExportDefaultDeclaration: 'ExportDefaultDeclaration',
4692
+ ExportNamedDeclaration: 'ExportNamedDeclaration',
4693
+ ExportSpecifier: 'ExportSpecifier',
4683
4694
  ExpressionStatement: 'ExpressionStatement',
4684
4695
  ForStatement: 'ForStatement',
4696
+ ForOfStatement: 'ForOfStatement',
4685
4697
  ForInStatement: 'ForInStatement',
4686
4698
  FunctionDeclaration: 'FunctionDeclaration',
4687
4699
  FunctionExpression: 'FunctionExpression',
4688
4700
  Identifier: 'Identifier',
4689
4701
  IfStatement: 'IfStatement',
4702
+ ImportDeclaration: 'ImportDeclaration',
4703
+ ImportDefaultSpecifier: 'ImportDefaultSpecifier',
4704
+ ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
4705
+ ImportSpecifier: 'ImportSpecifier',
4690
4706
  Literal: 'Literal',
4691
4707
  LabeledStatement: 'LabeledStatement',
4692
4708
  LogicalExpression: 'LogicalExpression',
@@ -4694,13 +4710,19 @@ define('logger', ['env!env/print'], function (print) {
4694
4710
  MethodDefinition: 'MethodDefinition',
4695
4711
  NewExpression: 'NewExpression',
4696
4712
  ObjectExpression: 'ObjectExpression',
4713
+ ObjectPattern: 'ObjectPattern',
4697
4714
  Program: 'Program',
4698
4715
  Property: 'Property',
4699
4716
  RestElement: 'RestElement',
4700
4717
  ReturnStatement: 'ReturnStatement',
4701
4718
  SequenceExpression: 'SequenceExpression',
4702
- SwitchStatement: 'SwitchStatement',
4719
+ SpreadElement: 'SpreadElement',
4720
+ Super: 'Super',
4703
4721
  SwitchCase: 'SwitchCase',
4722
+ SwitchStatement: 'SwitchStatement',
4723
+ TaggedTemplateExpression: 'TaggedTemplateExpression',
4724
+ TemplateElement: 'TemplateElement',
4725
+ TemplateLiteral: 'TemplateLiteral',
4704
4726
  ThisExpression: 'ThisExpression',
4705
4727
  ThrowStatement: 'ThrowStatement',
4706
4728
  TryStatement: 'TryStatement',
@@ -4709,7 +4731,8 @@ define('logger', ['env!env/print'], function (print) {
4709
4731
  VariableDeclaration: 'VariableDeclaration',
4710
4732
  VariableDeclarator: 'VariableDeclarator',
4711
4733
  WhileStatement: 'WhileStatement',
4712
- WithStatement: 'WithStatement'
4734
+ WithStatement: 'WithStatement',
4735
+ YieldExpression: 'YieldExpression'
4713
4736
  };
4714
4737
 
4715
4738
  PlaceHolders = {
@@ -4723,12 +4746,14 @@ define('logger', ['env!env/print'], function (print) {
4723
4746
  UnexpectedString: 'Unexpected string',
4724
4747
  UnexpectedIdentifier: 'Unexpected identifier',
4725
4748
  UnexpectedReserved: 'Unexpected reserved word',
4749
+ UnexpectedTemplate: 'Unexpected quasi %0',
4726
4750
  UnexpectedEOS: 'Unexpected end of input',
4727
4751
  NewlineAfterThrow: 'Illegal newline after throw',
4728
4752
  InvalidRegExp: 'Invalid regular expression',
4729
4753
  UnterminatedRegExp: 'Invalid regular expression: missing /',
4730
4754
  InvalidLHSInAssignment: 'Invalid left-hand side in assignment',
4731
4755
  InvalidLHSInForIn: 'Invalid left-hand side in for-in',
4756
+ InvalidLHSInForLoop: 'Invalid left-hand side in for-loop',
4732
4757
  MultipleDefaultsInSwitch: 'More than one default clause in switch statement',
4733
4758
  NoCatchOrFinally: 'Missing catch or finally after try',
4734
4759
  UnknownLabel: 'Undefined label \'%0\'',
@@ -4736,6 +4761,7 @@ define('logger', ['env!env/print'], function (print) {
4736
4761
  IllegalContinue: 'Illegal continue statement',
4737
4762
  IllegalBreak: 'Illegal break statement',
4738
4763
  IllegalReturn: 'Illegal return statement',
4764
+ IllegalYield: 'Unexpected token yield',
4739
4765
  StrictModeWith: 'Strict mode code may not include a with statement',
4740
4766
  StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
4741
4767
  StrictVarName: 'Variable name may not be eval or arguments in strict mode',
@@ -4748,13 +4774,20 @@ define('logger', ['env!env/print'], function (print) {
4748
4774
  StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
4749
4775
  StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
4750
4776
  StrictReservedWord: 'Use of future reserved word in strict mode',
4777
+ TemplateOctalLiteral: 'Octal literals are not allowed in template strings.',
4751
4778
  ParameterAfterRestParameter: 'Rest parameter must be last formal parameter',
4752
4779
  DefaultRestParameter: 'Unexpected token =',
4753
4780
  ObjectPatternAsRestParameter: 'Unexpected token {',
4754
4781
  DuplicateProtoProperty: 'Duplicate __proto__ fields are not allowed in object literals',
4755
4782
  ConstructorSpecialMethod: 'Class constructor may not be an accessor',
4756
4783
  DuplicateConstructor: 'A class may only have one constructor',
4757
- StaticPrototype: 'Classes may not have static property named prototype'
4784
+ StaticPrototype: 'Classes may not have static property named prototype',
4785
+ MissingFromClause: 'Unexpected token',
4786
+ NoAsAfterImportNamespace: 'Unexpected token',
4787
+ InvalidModuleSpecifier: 'Unexpected token',
4788
+ IllegalImportDeclaration: 'Unexpected token',
4789
+ IllegalExportDeclaration: 'Unexpected token',
4790
+ DuplicateBinding: 'Duplicate binding %0'
4758
4791
  };
4759
4792
 
4760
4793
  // See also tools/generate-unicode-regex.py.
@@ -4787,6 +4820,28 @@ define('logger', ['env!env/print'], function (print) {
4787
4820
  return '01234567'.indexOf(ch) >= 0;
4788
4821
  }
4789
4822
 
4823
+ function octalToDecimal(ch) {
4824
+ // \0 is not octal escape sequence
4825
+ var octal = (ch !== '0'), code = '01234567'.indexOf(ch);
4826
+
4827
+ if (index < length && isOctalDigit(source[index])) {
4828
+ octal = true;
4829
+ code = code * 8 + '01234567'.indexOf(source[index++]);
4830
+
4831
+ // 3 digits are only allowed when string starts
4832
+ // with 0, 1, 2, 3
4833
+ if ('0123'.indexOf(ch) >= 0 &&
4834
+ index < length &&
4835
+ isOctalDigit(source[index])) {
4836
+ code = code * 8 + '01234567'.indexOf(source[index++]);
4837
+ }
4838
+ }
4839
+
4840
+ return {
4841
+ code: code,
4842
+ octal: octal
4843
+ };
4844
+ }
4790
4845
 
4791
4846
  // 7.2 White Space
4792
4847
 
@@ -4860,9 +4915,6 @@ define('logger', ['env!env/print'], function (print) {
4860
4915
  // 7.6.1.1 Keywords
4861
4916
 
4862
4917
  function isKeyword(id) {
4863
- if (strict && isStrictModeReservedWord(id)) {
4864
- return true;
4865
- }
4866
4918
 
4867
4919
  // 'const' is specialized as Keyword in V8.
4868
4920
  // 'yield' and 'let' are for compatibility with SpiderMonkey and ES.next.
@@ -5008,20 +5060,16 @@ define('logger', ['env!env/print'], function (print) {
5008
5060
  }
5009
5061
  }
5010
5062
 
5011
- if (extra.errors && index >= length) {
5012
- //ran off the end of the file - the whole thing is a comment
5013
- if (extra.comments) {
5014
- loc.end = {
5015
- line: lineNumber,
5016
- column: index - lineStart
5017
- };
5018
- comment = source.slice(start + 2, index);
5019
- addComment('Block', comment, start, index, loc);
5020
- }
5021
- tolerateUnexpectedToken();
5022
- } else {
5023
- throwUnexpectedToken();
5063
+ // Ran off the end of the file - the whole thing is a comment
5064
+ if (extra.comments) {
5065
+ loc.end = {
5066
+ line: lineNumber,
5067
+ column: index - lineStart
5068
+ };
5069
+ comment = source.slice(start + 2, index);
5070
+ addComment('Block', comment, start, index, loc);
5024
5071
  }
5072
+ tolerateUnexpectedToken();
5025
5073
  }
5026
5074
 
5027
5075
  function skipComment() {
@@ -5257,6 +5305,7 @@ define('logger', ['env!env/print'], function (print) {
5257
5305
  if (extra.tokenize) {
5258
5306
  extra.openCurlyToken = extra.tokens.length;
5259
5307
  }
5308
+ state.curlyStack.push('{');
5260
5309
  ++index;
5261
5310
  break;
5262
5311
 
@@ -5269,10 +5318,13 @@ define('logger', ['env!env/print'], function (print) {
5269
5318
  }
5270
5319
  break;
5271
5320
 
5321
+ case '}':
5322
+ ++index;
5323
+ state.curlyStack.pop();
5324
+ break;
5272
5325
  case ')':
5273
5326
  case ';':
5274
5327
  case ',':
5275
- case '}':
5276
5328
  case '[':
5277
5329
  case ']':
5278
5330
  case ':':
@@ -5531,7 +5583,7 @@ define('logger', ['env!env/print'], function (print) {
5531
5583
  // 7.8.4 String Literals
5532
5584
 
5533
5585
  function scanStringLiteral() {
5534
- var str = '', quote, start, ch, code, unescaped, restore, octal = false;
5586
+ var str = '', quote, start, ch, unescaped, octToDec, octal = false;
5535
5587
 
5536
5588
  quote = source[index];
5537
5589
  assert((quote === '\'' || quote === '"'),
@@ -5556,14 +5608,11 @@ define('logger', ['env!env/print'], function (print) {
5556
5608
  ++index;
5557
5609
  str += scanUnicodeCodePointEscape();
5558
5610
  } else {
5559
- restore = index;
5560
5611
  unescaped = scanHexEscape(ch);
5561
- if (unescaped) {
5562
- str += unescaped;
5563
- } else {
5564
- index = restore;
5565
- str += ch;
5612
+ if (!unescaped) {
5613
+ throw throwUnexpectedToken();
5566
5614
  }
5615
+ str += unescaped;
5567
5616
  }
5568
5617
  break;
5569
5618
  case 'n':
@@ -5584,29 +5633,16 @@ define('logger', ['env!env/print'], function (print) {
5584
5633
  case 'v':
5585
5634
  str += '\x0B';
5586
5635
  break;
5636
+ case '8':
5637
+ case '9':
5638
+ throw throwUnexpectedToken();
5587
5639
 
5588
5640
  default:
5589
5641
  if (isOctalDigit(ch)) {
5590
- code = '01234567'.indexOf(ch);
5591
-
5592
- // \0 is not octal escape sequence
5593
- if (code !== 0) {
5594
- octal = true;
5595
- }
5642
+ octToDec = octalToDecimal(ch);
5596
5643
 
5597
- if (index < length && isOctalDigit(source[index])) {
5598
- octal = true;
5599
- code = code * 8 + '01234567'.indexOf(source[index++]);
5600
-
5601
- // 3 digits are only allowed when string starts
5602
- // with 0, 1, 2, 3
5603
- if ('0123'.indexOf(ch) >= 0 &&
5604
- index < length &&
5605
- isOctalDigit(source[index])) {
5606
- code = code * 8 + '01234567'.indexOf(source[index++]);
5607
- }
5608
- }
5609
- str += String.fromCharCode(code);
5644
+ octal = octToDec.octal || octal;
5645
+ str += String.fromCharCode(octToDec.code);
5610
5646
  } else {
5611
5647
  str += ch;
5612
5648
  }
@@ -5641,26 +5677,161 @@ define('logger', ['env!env/print'], function (print) {
5641
5677
  };
5642
5678
  }
5643
5679
 
5680
+ function scanTemplate() {
5681
+ var cooked = '', ch, start, rawOffset, terminated, head, tail, restore, unescaped;
5682
+
5683
+ terminated = false;
5684
+ tail = false;
5685
+ start = index;
5686
+ head = (source[index] === '`');
5687
+ rawOffset = 2;
5688
+
5689
+ ++index;
5690
+
5691
+ while (index < length) {
5692
+ ch = source[index++];
5693
+ if (ch === '`') {
5694
+ rawOffset = 1;
5695
+ tail = true;
5696
+ terminated = true;
5697
+ break;
5698
+ } else if (ch === '$') {
5699
+ if (source[index] === '{') {
5700
+ state.curlyStack.push('${');
5701
+ ++index;
5702
+ terminated = true;
5703
+ break;
5704
+ }
5705
+ cooked += ch;
5706
+ } else if (ch === '\\') {
5707
+ ch = source[index++];
5708
+ if (!isLineTerminator(ch.charCodeAt(0))) {
5709
+ switch (ch) {
5710
+ case 'n':
5711
+ cooked += '\n';
5712
+ break;
5713
+ case 'r':
5714
+ cooked += '\r';
5715
+ break;
5716
+ case 't':
5717
+ cooked += '\t';
5718
+ break;
5719
+ case 'u':
5720
+ case 'x':
5721
+ if (source[index] === '{') {
5722
+ ++index;
5723
+ cooked += scanUnicodeCodePointEscape();
5724
+ } else {
5725
+ restore = index;
5726
+ unescaped = scanHexEscape(ch);
5727
+ if (unescaped) {
5728
+ cooked += unescaped;
5729
+ } else {
5730
+ index = restore;
5731
+ cooked += ch;
5732
+ }
5733
+ }
5734
+ break;
5735
+ case 'b':
5736
+ cooked += '\b';
5737
+ break;
5738
+ case 'f':
5739
+ cooked += '\f';
5740
+ break;
5741
+ case 'v':
5742
+ cooked += '\v';
5743
+ break;
5744
+
5745
+ default:
5746
+ if (ch === '0') {
5747
+ if (isDecimalDigit(source.charCodeAt(index))) {
5748
+ // Illegal: \01 \02 and so on
5749
+ throwError(Messages.TemplateOctalLiteral);
5750
+ }
5751
+ cooked += '\0';
5752
+ } else if (isOctalDigit(ch)) {
5753
+ // Illegal: \1 \2
5754
+ throwError(Messages.TemplateOctalLiteral);
5755
+ } else {
5756
+ cooked += ch;
5757
+ }
5758
+ break;
5759
+ }
5760
+ } else {
5761
+ ++lineNumber;
5762
+ if (ch === '\r' && source[index] === '\n') {
5763
+ ++index;
5764
+ }
5765
+ lineStart = index;
5766
+ }
5767
+ } else if (isLineTerminator(ch.charCodeAt(0))) {
5768
+ ++lineNumber;
5769
+ if (ch === '\r' && source[index] === '\n') {
5770
+ ++index;
5771
+ }
5772
+ lineStart = index;
5773
+ cooked += '\n';
5774
+ } else {
5775
+ cooked += ch;
5776
+ }
5777
+ }
5778
+
5779
+ if (!terminated) {
5780
+ throwUnexpectedToken();
5781
+ }
5782
+
5783
+ if (!head) {
5784
+ state.curlyStack.pop();
5785
+ }
5786
+
5787
+ return {
5788
+ type: Token.Template,
5789
+ value: {
5790
+ cooked: cooked,
5791
+ raw: source.slice(start + 1, index - rawOffset)
5792
+ },
5793
+ head: head,
5794
+ tail: tail,
5795
+ lineNumber: lineNumber,
5796
+ lineStart: lineStart,
5797
+ start: start,
5798
+ end: index
5799
+ };
5800
+ }
5801
+
5644
5802
  function testRegExp(pattern, flags) {
5645
- var tmp = pattern;
5803
+ // The BMP character to use as a replacement for astral symbols when
5804
+ // translating an ES6 "u"-flagged pattern to an ES5-compatible
5805
+ // approximation.
5806
+ // Note: replacing with '\uFFFF' enables false positives in unlikely
5807
+ // scenarios. For example, `[\u{1044f}-\u{10440}]` is an invalid
5808
+ // pattern that would not be detected by this substitution.
5809
+ var astralSubstitute = '\uFFFF',
5810
+ tmp = pattern;
5646
5811
 
5647
5812
  if (flags.indexOf('u') >= 0) {
5648
- // Replace each astral symbol and every Unicode code point
5649
- // escape sequence with a single ASCII symbol to avoid throwing on
5650
- // regular expressions that are only valid in combination with the
5651
- // `/u` flag.
5652
- // Note: replacing with the ASCII symbol `x` might cause false
5653
- // negatives in unlikely scenarios. For example, `[\u{61}-b]` is a
5654
- // perfectly valid pattern that is equivalent to `[a-b]`, but it
5655
- // would be replaced by `[x-b]` which throws an error.
5656
5813
  tmp = tmp
5657
- .replace(/\\u\{([0-9a-fA-F]+)\}/g, function ($0, $1) {
5658
- if (parseInt($1, 16) <= 0x10FFFF) {
5659
- return 'x';
5814
+ // Replace every Unicode escape sequence with the equivalent
5815
+ // BMP character or a constant ASCII code point in the case of
5816
+ // astral symbols. (See the above note on `astralSubstitute`
5817
+ // for more information.)
5818
+ .replace(/\\u\{([0-9a-fA-F]+)\}|\\u([a-fA-F0-9]{4})/g, function ($0, $1, $2) {
5819
+ var codePoint = parseInt($1 || $2, 16);
5820
+ if (codePoint > 0x10FFFF) {
5821
+ throwUnexpectedToken(null, Messages.InvalidRegExp);
5660
5822
  }
5661
- throwUnexpectedToken(null, Messages.InvalidRegExp);
5823
+ if (codePoint <= 0xFFFF) {
5824
+ return String.fromCharCode(codePoint);
5825
+ }
5826
+ return astralSubstitute;
5662
5827
  })
5663
- .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x');
5828
+ // Replace each paired surrogate with a single ASCII symbol to
5829
+ // avoid throwing on regular expressions that are only valid in
5830
+ // combination with the "u" flag.
5831
+ .replace(
5832
+ /[\uD800-\uDBFF][\uDC00-\uDFFF]/g,
5833
+ astralSubstitute
5834
+ );
5664
5835
  }
5665
5836
 
5666
5837
  // First, detect invalid regular expressions.
@@ -5926,7 +6097,7 @@ define('logger', ['env!env/print'], function (print) {
5926
6097
  }
5927
6098
 
5928
6099
  function advance() {
5929
- var ch;
6100
+ var ch, token;
5930
6101
 
5931
6102
  if (index >= length) {
5932
6103
  return {
@@ -5941,7 +6112,11 @@ define('logger', ['env!env/print'], function (print) {
5941
6112
  ch = source.charCodeAt(index);
5942
6113
 
5943
6114
  if (isIdentifierStart(ch)) {
5944
- return scanIdentifier();
6115
+ token = scanIdentifier();
6116
+ if (strict && isStrictModeReservedWord(token.value)) {
6117
+ token.type = Token.Keyword;
6118
+ }
6119
+ return token;
5945
6120
  }
5946
6121
 
5947
6122
  // Very common: ( and ) and ;
@@ -5954,7 +6129,6 @@ define('logger', ['env!env/print'], function (print) {
5954
6129
  return scanStringLiteral();
5955
6130
  }
5956
6131
 
5957
-
5958
6132
  // Dot (.) U+002E can also start a floating-point number, hence the need
5959
6133
  // to check the next character.
5960
6134
  if (ch === 0x2E) {
@@ -5973,6 +6147,12 @@ define('logger', ['env!env/print'], function (print) {
5973
6147
  return advanceSlash();
5974
6148
  }
5975
6149
 
6150
+ // Template literals start with ` (U+0060) for template head
6151
+ // or } (U+007D) for template middle or template tail.
6152
+ if (ch === 0x60 || (ch === 0x7D && state.curlyStack[state.curlyStack.length - 1] === '${')) {
6153
+ return scanTemplate();
6154
+ }
6155
+
5976
6156
  return scanPunctuator();
5977
6157
  }
5978
6158
 
@@ -6121,17 +6301,25 @@ define('logger', ['env!env/print'], function (print) {
6121
6301
  }
6122
6302
 
6123
6303
  // Eating the stack.
6124
- if (last) {
6125
- while (last && last.range[0] >= this.range[0]) {
6126
- lastChild = last;
6127
- last = bottomRight.pop();
6128
- }
6304
+ while (last && last.range[0] >= this.range[0]) {
6305
+ lastChild = bottomRight.pop();
6306
+ last = bottomRight[bottomRight.length - 1];
6129
6307
  }
6130
6308
 
6131
6309
  if (lastChild) {
6132
- if (lastChild.leadingComments && lastChild.leadingComments[lastChild.leadingComments.length - 1].range[1] <= this.range[0]) {
6133
- this.leadingComments = lastChild.leadingComments;
6134
- lastChild.leadingComments = undefined;
6310
+ if (lastChild.leadingComments) {
6311
+ leadingComments = [];
6312
+ for (i = lastChild.leadingComments.length - 1; i >= 0; --i) {
6313
+ comment = lastChild.leadingComments[i];
6314
+ if (comment.range[1] <= this.range[0]) {
6315
+ leadingComments.unshift(comment);
6316
+ lastChild.leadingComments.splice(i, 1);
6317
+ }
6318
+ }
6319
+
6320
+ if (!lastChild.leadingComments.length) {
6321
+ lastChild.leadingComments = undefined;
6322
+ }
6135
6323
  }
6136
6324
  } else if (extra.leadingComments.length > 0) {
6137
6325
  leadingComments = [];
@@ -6181,6 +6369,13 @@ define('logger', ['env!env/print'], function (print) {
6181
6369
  return this;
6182
6370
  },
6183
6371
 
6372
+ finishArrayPattern: function (elements) {
6373
+ this.type = Syntax.ArrayPattern;
6374
+ this.elements = elements;
6375
+ this.finish();
6376
+ return this;
6377
+ },
6378
+
6184
6379
  finishArrowFunctionExpression: function (params, defaults, body, expression) {
6185
6380
  this.type = Syntax.ArrowFunctionExpression;
6186
6381
  this.id = null;
@@ -6202,6 +6397,14 @@ define('logger', ['env!env/print'], function (print) {
6202
6397
  return this;
6203
6398
  },
6204
6399
 
6400
+ finishAssignmentPattern: function (left, right) {
6401
+ this.type = Syntax.AssignmentPattern;
6402
+ this.left = left;
6403
+ this.right = right;
6404
+ this.finish();
6405
+ return this;
6406
+ },
6407
+
6205
6408
  finishBinaryExpression: function (operator, left, right) {
6206
6409
  this.type = (operator === '||' || operator === '&&') ? Syntax.LogicalExpression : Syntax.BinaryExpression;
6207
6410
  this.operator = operator;
@@ -6319,6 +6522,15 @@ define('logger', ['env!env/print'], function (print) {
6319
6522
  return this;
6320
6523
  },
6321
6524
 
6525
+ finishForOfStatement: function (left, right, body) {
6526
+ this.type = Syntax.ForOfStatement;
6527
+ this.left = left;
6528
+ this.right = right;
6529
+ this.body = body;
6530
+ this.finish();
6531
+ return this;
6532
+ },
6533
+
6322
6534
  finishForInStatement: function (left, right, body) {
6323
6535
  this.type = Syntax.ForInStatement;
6324
6536
  this.left = left;
@@ -6329,25 +6541,25 @@ define('logger', ['env!env/print'], function (print) {
6329
6541
  return this;
6330
6542
  },
6331
6543
 
6332
- finishFunctionDeclaration: function (id, params, defaults, body) {
6544
+ finishFunctionDeclaration: function (id, params, defaults, body, generator) {
6333
6545
  this.type = Syntax.FunctionDeclaration;
6334
6546
  this.id = id;
6335
6547
  this.params = params;
6336
6548
  this.defaults = defaults;
6337
6549
  this.body = body;
6338
- this.generator = false;
6550
+ this.generator = generator;
6339
6551
  this.expression = false;
6340
6552
  this.finish();
6341
6553
  return this;
6342
6554
  },
6343
6555
 
6344
- finishFunctionExpression: function (id, params, defaults, body) {
6556
+ finishFunctionExpression: function (id, params, defaults, body, generator) {
6345
6557
  this.type = Syntax.FunctionExpression;
6346
6558
  this.id = id;
6347
6559
  this.params = params;
6348
6560
  this.defaults = defaults;
6349
6561
  this.body = body;
6350
- this.generator = false;
6562
+ this.generator = generator;
6351
6563
  this.expression = false;
6352
6564
  this.finish();
6353
6565
  return this;
@@ -6412,6 +6624,13 @@ define('logger', ['env!env/print'], function (print) {
6412
6624
  return this;
6413
6625
  },
6414
6626
 
6627
+ finishObjectPattern: function (properties) {
6628
+ this.type = Syntax.ObjectPattern;
6629
+ this.properties = properties;
6630
+ this.finish();
6631
+ return this;
6632
+ },
6633
+
6415
6634
  finishPostfixExpression: function (operator, argument) {
6416
6635
  this.type = Syntax.UpdateExpression;
6417
6636
  this.operator = operator;
@@ -6424,6 +6643,10 @@ define('logger', ['env!env/print'], function (print) {
6424
6643
  finishProgram: function (body) {
6425
6644
  this.type = Syntax.Program;
6426
6645
  this.body = body;
6646
+ if (sourceType === 'module') {
6647
+ // very restrictive for now
6648
+ this.sourceType = sourceType;
6649
+ }
6427
6650
  this.finish();
6428
6651
  return this;
6429
6652
  },
@@ -6461,6 +6684,13 @@ define('logger', ['env!env/print'], function (print) {
6461
6684
  return this;
6462
6685
  },
6463
6686
 
6687
+ finishSpreadElement: function (argument) {
6688
+ this.type = Syntax.SpreadElement;
6689
+ this.argument = argument;
6690
+ this.finish();
6691
+ return this;
6692
+ },
6693
+
6464
6694
  finishSwitchCase: function (test, consequent) {
6465
6695
  this.type = Syntax.SwitchCase;
6466
6696
  this.test = test;
@@ -6469,6 +6699,12 @@ define('logger', ['env!env/print'], function (print) {
6469
6699
  return this;
6470
6700
  },
6471
6701
 
6702
+ finishSuper: function () {
6703
+ this.type = Syntax.Super;
6704
+ this.finish();
6705
+ return this;
6706
+ },
6707
+
6472
6708
  finishSwitchStatement: function (discriminant, cases) {
6473
6709
  this.type = Syntax.SwitchStatement;
6474
6710
  this.discriminant = discriminant;
@@ -6477,6 +6713,30 @@ define('logger', ['env!env/print'], function (print) {
6477
6713
  return this;
6478
6714
  },
6479
6715
 
6716
+ finishTaggedTemplateExpression: function (tag, quasi) {
6717
+ this.type = Syntax.TaggedTemplateExpression;
6718
+ this.tag = tag;
6719
+ this.quasi = quasi;
6720
+ this.finish();
6721
+ return this;
6722
+ },
6723
+
6724
+ finishTemplateElement: function (value, tail) {
6725
+ this.type = Syntax.TemplateElement;
6726
+ this.value = value;
6727
+ this.tail = tail;
6728
+ this.finish();
6729
+ return this;
6730
+ },
6731
+
6732
+ finishTemplateLiteral: function (quasis, expressions) {
6733
+ this.type = Syntax.TemplateLiteral;
6734
+ this.quasis = quasis;
6735
+ this.expressions = expressions;
6736
+ this.finish();
6737
+ return this;
6738
+ },
6739
+
6480
6740
  finishThisExpression: function () {
6481
6741
  this.type = Syntax.ThisExpression;
6482
6742
  this.finish();
@@ -6548,6 +6808,75 @@ define('logger', ['env!env/print'], function (print) {
6548
6808
  this.body = body;
6549
6809
  this.finish();
6550
6810
  return this;
6811
+ },
6812
+
6813
+ finishExportSpecifier: function (local, exported) {
6814
+ this.type = Syntax.ExportSpecifier;
6815
+ this.exported = exported || local;
6816
+ this.local = local;
6817
+ this.finish();
6818
+ return this;
6819
+ },
6820
+
6821
+ finishImportDefaultSpecifier: function (local) {
6822
+ this.type = Syntax.ImportDefaultSpecifier;
6823
+ this.local = local;
6824
+ this.finish();
6825
+ return this;
6826
+ },
6827
+
6828
+ finishImportNamespaceSpecifier: function (local) {
6829
+ this.type = Syntax.ImportNamespaceSpecifier;
6830
+ this.local = local;
6831
+ this.finish();
6832
+ return this;
6833
+ },
6834
+
6835
+ finishExportNamedDeclaration: function (declaration, specifiers, src) {
6836
+ this.type = Syntax.ExportNamedDeclaration;
6837
+ this.declaration = declaration;
6838
+ this.specifiers = specifiers;
6839
+ this.source = src;
6840
+ this.finish();
6841
+ return this;
6842
+ },
6843
+
6844
+ finishExportDefaultDeclaration: function (declaration) {
6845
+ this.type = Syntax.ExportDefaultDeclaration;
6846
+ this.declaration = declaration;
6847
+ this.finish();
6848
+ return this;
6849
+ },
6850
+
6851
+ finishExportAllDeclaration: function (src) {
6852
+ this.type = Syntax.ExportAllDeclaration;
6853
+ this.source = src;
6854
+ this.finish();
6855
+ return this;
6856
+ },
6857
+
6858
+ finishImportSpecifier: function (local, imported) {
6859
+ this.type = Syntax.ImportSpecifier;
6860
+ this.local = local || imported;
6861
+ this.imported = imported;
6862
+ this.finish();
6863
+ return this;
6864
+ },
6865
+
6866
+ finishImportDeclaration: function (specifiers, src) {
6867
+ this.type = Syntax.ImportDeclaration;
6868
+ this.specifiers = specifiers;
6869
+ this.source = src;
6870
+ this.finish();
6871
+ return this;
6872
+ },
6873
+
6874
+ finishYieldExpression: function (argument, delegate) {
6875
+ this.type = Syntax.YieldExpression;
6876
+ this.argument = argument;
6877
+ this.delegate = delegate;
6878
+ this.finish();
6879
+ return this;
6551
6880
  }
6552
6881
  };
6553
6882
 
@@ -6615,25 +6944,32 @@ define('logger', ['env!env/print'], function (print) {
6615
6944
  // Throw an exception because of the token.
6616
6945
 
6617
6946
  function unexpectedTokenError(token, message) {
6618
- var msg = message || Messages.UnexpectedToken;
6619
-
6620
- if (token && !message) {
6621
- msg = (token.type === Token.EOF) ? Messages.UnexpectedEOS :
6622
- (token.type === Token.Identifier) ? Messages.UnexpectedIdentifier :
6623
- (token.type === Token.NumericLiteral) ? Messages.UnexpectedNumber :
6624
- (token.type === Token.StringLiteral) ? Messages.UnexpectedString :
6625
- Messages.UnexpectedToken;
6626
-
6627
- if (token.type === Token.Keyword) {
6628
- if (isFutureReservedWord(token.value)) {
6629
- msg = Messages.UnexpectedReserved;
6630
- } else if (strict && isStrictModeReservedWord(token.value)) {
6631
- msg = Messages.StrictReservedWord;
6947
+ var value, msg = message || Messages.UnexpectedToken;
6948
+
6949
+ if (token) {
6950
+ if (!message) {
6951
+ msg = (token.type === Token.EOF) ? Messages.UnexpectedEOS :
6952
+ (token.type === Token.Identifier) ? Messages.UnexpectedIdentifier :
6953
+ (token.type === Token.NumericLiteral) ? Messages.UnexpectedNumber :
6954
+ (token.type === Token.StringLiteral) ? Messages.UnexpectedString :
6955
+ (token.type === Token.Template) ? Messages.UnexpectedTemplate :
6956
+ Messages.UnexpectedToken;
6957
+
6958
+ if (token.type === Token.Keyword) {
6959
+ if (isFutureReservedWord(token.value)) {
6960
+ msg = Messages.UnexpectedReserved;
6961
+ } else if (strict && isStrictModeReservedWord(token.value)) {
6962
+ msg = Messages.StrictReservedWord;
6963
+ }
6632
6964
  }
6633
6965
  }
6966
+
6967
+ value = (token.type === Token.Template) ? token.value.raw : token.value;
6968
+ } else {
6969
+ value = 'ILLEGAL';
6634
6970
  }
6635
6971
 
6636
- msg = msg.replace('%0', token ? token.value : 'ILLEGAL');
6972
+ msg = msg.replace('%0', value);
6637
6973
 
6638
6974
  return (token && typeof token.lineNumber === 'number') ?
6639
6975
  createError(token.lineNumber, token.start, msg) :
@@ -6709,6 +7045,13 @@ define('logger', ['env!env/print'], function (print) {
6709
7045
  return lookahead.type === Token.Keyword && lookahead.value === keyword;
6710
7046
  }
6711
7047
 
7048
+ // Return true if the next token matches the specified contextual keyword
7049
+ // (where an identifier is sometimes a keyword depending on the context)
7050
+
7051
+ function matchContextualKeyword(keyword) {
7052
+ return lookahead.type === Token.Identifier && lookahead.value === keyword;
7053
+ }
7054
+
6712
7055
  // Return true if the next token is an assignment operator
6713
7056
 
6714
7057
  function matchAssign() {
@@ -6753,17 +7096,72 @@ define('logger', ['env!env/print'], function (print) {
6753
7096
  }
6754
7097
  }
6755
7098
 
6756
- // Return true if provided expression is LeftHandSideExpression
6757
-
6758
- function isLeftHandSide(expr) {
6759
- return expr.type === Syntax.Identifier || expr.type === Syntax.MemberExpression;
7099
+ // Cover grammar support.
7100
+ //
7101
+ // When an assignment expression position starts with an left parenthesis, the determination of the type
7102
+ // of the syntax is to be deferred arbitrarily long until the end of the parentheses pair (plus a lookahead)
7103
+ // or the first comma. This situation also defers the determination of all the expressions nested in the pair.
7104
+ //
7105
+ // There are three productions that can be parsed in a parentheses pair that needs to be determined
7106
+ // after the outermost pair is closed. They are:
7107
+ //
7108
+ // 1. AssignmentExpression
7109
+ // 2. BindingElements
7110
+ // 3. AssignmentTargets
7111
+ //
7112
+ // In order to avoid exponential backtracking, we use two flags to denote if the production can be
7113
+ // binding element or assignment target.
7114
+ //
7115
+ // The three productions have the relationship:
7116
+ //
7117
+ // BindingElements ⊆ AssignmentTargets ⊆ AssignmentExpression
7118
+ //
7119
+ // with a single exception that CoverInitializedName when used directly in an Expression, generates
7120
+ // an early error. Therefore, we need the third state, firstCoverInitializedNameError, to track the
7121
+ // first usage of CoverInitializedName and report it when we reached the end of the parentheses pair.
7122
+ //
7123
+ // isolateCoverGrammar function runs the given parser function with a new cover grammar context, and it does not
7124
+ // effect the current flags. This means the production the parser parses is only used as an expression. Therefore
7125
+ // the CoverInitializedName check is conducted.
7126
+ //
7127
+ // inheritCoverGrammar function runs the given parse function with a new cover grammar context, and it propagates
7128
+ // the flags outside of the parser. This means the production the parser parses is used as a part of a potential
7129
+ // pattern. The CoverInitializedName check is deferred.
7130
+ function isolateCoverGrammar(parser) {
7131
+ var oldIsBindingElement = isBindingElement,
7132
+ oldIsAssignmentTarget = isAssignmentTarget,
7133
+ oldFirstCoverInitializedNameError = firstCoverInitializedNameError,
7134
+ result;
7135
+ isBindingElement = true;
7136
+ isAssignmentTarget = true;
7137
+ firstCoverInitializedNameError = null;
7138
+ result = parser();
7139
+ if (firstCoverInitializedNameError !== null) {
7140
+ throwUnexpectedToken(firstCoverInitializedNameError);
7141
+ }
7142
+ isBindingElement = oldIsBindingElement;
7143
+ isAssignmentTarget = oldIsAssignmentTarget;
7144
+ firstCoverInitializedNameError = oldFirstCoverInitializedNameError;
7145
+ return result;
6760
7146
  }
6761
7147
 
6762
- // 11.1.4 Array Initialiser
6763
-
6764
- function parseArrayInitialiser() {
6765
- var elements = [], node = new Node();
7148
+ function inheritCoverGrammar(parser) {
7149
+ var oldIsBindingElement = isBindingElement,
7150
+ oldIsAssignmentTarget = isAssignmentTarget,
7151
+ oldFirstCoverInitializedNameError = firstCoverInitializedNameError,
7152
+ result;
7153
+ isBindingElement = true;
7154
+ isAssignmentTarget = true;
7155
+ firstCoverInitializedNameError = null;
7156
+ result = parser();
7157
+ isBindingElement = isBindingElement && oldIsBindingElement;
7158
+ isAssignmentTarget = isAssignmentTarget && oldIsAssignmentTarget;
7159
+ firstCoverInitializedNameError = oldFirstCoverInitializedNameError || firstCoverInitializedNameError;
7160
+ return result;
7161
+ }
6766
7162
 
7163
+ function parseArrayPattern(params) {
7164
+ var node = new Node(), elements = [], rest, restNode;
6767
7165
  expect('[');
6768
7166
 
6769
7167
  while (!match(']')) {
@@ -6771,26 +7169,139 @@ define('logger', ['env!env/print'], function (print) {
6771
7169
  lex();
6772
7170
  elements.push(null);
6773
7171
  } else {
6774
- elements.push(parseAssignmentExpression());
6775
-
7172
+ if (match('...')) {
7173
+ restNode = new Node();
7174
+ lex();
7175
+ params.push(lookahead);
7176
+ rest = parseVariableIdentifier(params);
7177
+ elements.push(restNode.finishRestElement(rest));
7178
+ break;
7179
+ } else {
7180
+ elements.push(parsePatternWithDefault(params));
7181
+ }
6776
7182
  if (!match(']')) {
6777
7183
  expect(',');
6778
7184
  }
6779
7185
  }
7186
+
6780
7187
  }
6781
7188
 
6782
- lex();
7189
+ expect(']');
6783
7190
 
6784
- return node.finishArrayExpression(elements);
7191
+ return node.finishArrayPattern(elements);
6785
7192
  }
6786
7193
 
6787
- // 11.1.5 Object Initialiser
6788
-
6789
- function parsePropertyFunction(node, paramInfo) {
6790
- var previousStrict, body;
7194
+ function parsePropertyPattern(params) {
7195
+ var node = new Node(), key, keyToken, computed = match('['), init;
7196
+ if (lookahead.type === Token.Identifier) {
7197
+ keyToken = lookahead;
7198
+ key = parseVariableIdentifier();
7199
+ if (match('=')) {
7200
+ params.push(keyToken);
7201
+ lex();
7202
+ init = parseAssignmentExpression();
7203
+
7204
+ return node.finishProperty(
7205
+ 'init', key, false,
7206
+ new WrappingNode(keyToken).finishAssignmentPattern(key, init), false, false);
7207
+ } else if (!match(':')) {
7208
+ params.push(keyToken);
7209
+ return node.finishProperty('init', key, false, key, false, true);
7210
+ }
7211
+ } else {
7212
+ key = parseObjectPropertyKey(params);
7213
+ }
7214
+ expect(':');
7215
+ init = parsePatternWithDefault(params);
7216
+ return node.finishProperty('init', key, computed, init, false, false);
7217
+ }
7218
+
7219
+ function parseObjectPattern(params) {
7220
+ var node = new Node(), properties = [];
7221
+
7222
+ expect('{');
7223
+
7224
+ while (!match('}')) {
7225
+ properties.push(parsePropertyPattern(params));
7226
+ if (!match('}')) {
7227
+ expect(',');
7228
+ }
7229
+ }
7230
+
7231
+ lex();
7232
+
7233
+ return node.finishObjectPattern(properties);
7234
+ }
7235
+
7236
+ function parsePattern(params) {
7237
+ var identifier;
7238
+ if (lookahead.type === Token.Identifier) {
7239
+ params.push(lookahead);
7240
+ identifier = parseVariableIdentifier();
7241
+ return identifier;
7242
+ } else if (match('[')) {
7243
+ return parseArrayPattern(params);
7244
+ } else if (match('{')) {
7245
+ return parseObjectPattern(params);
7246
+ }
7247
+ throwUnexpectedToken(lookahead);
7248
+ }
7249
+
7250
+ function parsePatternWithDefault(params) {
7251
+ var startToken = lookahead, pattern, right;
7252
+ pattern = parsePattern(params);
7253
+ if (match('=')) {
7254
+ lex();
7255
+ right = isolateCoverGrammar(parseAssignmentExpression);
7256
+ pattern = new WrappingNode(startToken).finishAssignmentPattern(pattern, right);
7257
+ }
7258
+ return pattern;
7259
+ }
7260
+
7261
+ // 11.1.4 Array Initialiser
7262
+
7263
+ function parseArrayInitialiser() {
7264
+ var elements = [], node = new Node(), restSpread;
7265
+
7266
+ expect('[');
7267
+
7268
+ while (!match(']')) {
7269
+ if (match(',')) {
7270
+ lex();
7271
+ elements.push(null);
7272
+ } else if (match('...')) {
7273
+ restSpread = new Node();
7274
+ lex();
7275
+ restSpread.finishSpreadElement(inheritCoverGrammar(parseAssignmentExpression));
7276
+
7277
+ if (!match(']')) {
7278
+ isAssignmentTarget = isBindingElement = false;
7279
+ expect(',');
7280
+ }
7281
+ elements.push(restSpread);
7282
+ } else {
7283
+ elements.push(inheritCoverGrammar(parseAssignmentExpression));
7284
+
7285
+ if (!match(']')) {
7286
+ expect(',');
7287
+ }
7288
+ }
7289
+ }
7290
+
7291
+ lex();
7292
+
7293
+ return node.finishArrayExpression(elements);
7294
+ }
7295
+
7296
+ // 11.1.5 Object Initialiser
7297
+
7298
+ function parsePropertyFunction(node, paramInfo, isGenerator) {
7299
+ var previousStrict, body;
7300
+
7301
+ isAssignmentTarget = isBindingElement = false;
6791
7302
 
6792
7303
  previousStrict = strict;
6793
- body = parseFunctionSourceElements();
7304
+ body = isolateCoverGrammar(parseFunctionSourceElements);
6794
7305
 
6795
7306
  if (strict && paramInfo.firstRestricted) {
6796
7307
  tolerateUnexpectedToken(paramInfo.firstRestricted, paramInfo.message);
@@ -6800,20 +7311,24 @@ define('logger', ['env!env/print'], function (print) {
6800
7311
  }
6801
7312
 
6802
7313
  strict = previousStrict;
6803
- return node.finishFunctionExpression(null, paramInfo.params, paramInfo.defaults, body);
7314
+ return node.finishFunctionExpression(null, paramInfo.params, paramInfo.defaults, body, isGenerator);
6804
7315
  }
6805
7316
 
6806
7317
  function parsePropertyMethodFunction() {
6807
- var params, method, node = new Node();
7318
+ var params, method, node = new Node(),
7319
+ previousAllowYield = state.allowYield;
6808
7320
 
7321
+ state.allowYield = false;
6809
7322
  params = parseParams();
6810
- method = parsePropertyFunction(node, params);
7323
+ state.allowYield = previousAllowYield;
7324
+
7325
+ state.allowYield = false;
7326
+ method = parsePropertyFunction(node, params, false);
7327
+ state.allowYield = previousAllowYield;
6811
7328
 
6812
7329
  return method;
6813
7330
  }
6814
7331
 
6815
- // This function returns a tuple `[PropertyName, boolean]` where the PropertyName is the key being consumed and the second
6816
- // element indicate whether its a computed PropertyName or a static PropertyName.
6817
7332
  function parseObjectPropertyKey() {
6818
7333
  var token, node = new Node(), expr;
6819
7334
 
@@ -6836,7 +7351,7 @@ define('logger', ['env!env/print'], function (print) {
6836
7351
  return node.finishIdentifier(token.value);
6837
7352
  case Token.Punctuator:
6838
7353
  if (token.value === '[') {
6839
- expr = parseAssignmentExpression();
7354
+ expr = isolateCoverGrammar(parseAssignmentExpression);
6840
7355
  expect(']');
6841
7356
  return expr;
6842
7357
  }
@@ -6867,7 +7382,8 @@ define('logger', ['env!env/print'], function (print) {
6867
7382
  // In order to avoid back tracking, it returns `null` if the position is not a MethodDefinition and the caller
6868
7383
  // is responsible to visit other options.
6869
7384
  function tryParseMethodDefinition(token, key, computed, node) {
6870
- var value, options, methodNode;
7385
+ var value, options, methodNode, params,
7386
+ previousAllowYield = state.allowYield;
6871
7387
 
6872
7388
  if (token.type === Token.Identifier) {
6873
7389
  // check for `get` and `set`;
@@ -6878,13 +7394,17 @@ define('logger', ['env!env/print'], function (print) {
6878
7394
  methodNode = new Node();
6879
7395
  expect('(');
6880
7396
  expect(')');
7397
+
7398
+ state.allowYield = false;
6881
7399
  value = parsePropertyFunction(methodNode, {
6882
7400
  params: [],
6883
7401
  defaults: [],
6884
7402
  stricted: null,
6885
7403
  firstRestricted: null,
6886
7404
  message: null
6887
- });
7405
+ }, false);
7406
+ state.allowYield = previousAllowYield;
7407
+
6888
7408
  return node.finishProperty('get', key, computed, value, false, false);
6889
7409
  } else if (token.value === 'set' && lookaheadPropertyName()) {
6890
7410
  computed = match('[');
@@ -6902,19 +7422,38 @@ define('logger', ['env!env/print'], function (print) {
6902
7422
  if (match(')')) {
6903
7423
  tolerateUnexpectedToken(lookahead);
6904
7424
  } else {
7425
+ state.allowYield = false;
6905
7426
  parseParam(options);
7427
+ state.allowYield = previousAllowYield;
6906
7428
  if (options.defaultCount === 0) {
6907
7429
  options.defaults = [];
6908
7430
  }
6909
7431
  }
6910
7432
  expect(')');
6911
7433
 
6912
- value = parsePropertyFunction(methodNode, options);
7434
+ state.allowYield = false;
7435
+ value = parsePropertyFunction(methodNode, options, false);
7436
+ state.allowYield = previousAllowYield;
7437
+
6913
7438
  return node.finishProperty('set', key, computed, value, false, false);
6914
7439
  }
7440
+ } else if (token.type === Token.Punctuator && token.value === '*' && lookaheadPropertyName()) {
7441
+ computed = match('[');
7442
+ key = parseObjectPropertyKey();
7443
+ methodNode = new Node();
7444
+
7445
+ state.allowYield = false;
7446
+ params = parseParams();
7447
+ state.allowYield = previousAllowYield;
7448
+
7449
+ state.allowYield = true;
7450
+ value = parsePropertyFunction(methodNode, params, true);
7451
+ state.allowYield = previousAllowYield;
7452
+
7453
+ return node.finishProperty('init', key, computed, value, true, false);
6915
7454
  }
6916
7455
 
6917
- if (match('(')) {
7456
+ if (key && match('(')) {
6918
7457
  value = parsePropertyMethodFunction();
6919
7458
  return node.finishProperty('init', key, computed, value, true, false);
6920
7459
  }
@@ -6938,7 +7477,11 @@ define('logger', ['env!env/print'], function (print) {
6938
7477
  var token = lookahead, node = new Node(), computed, key, maybeMethod, value;
6939
7478
 
6940
7479
  computed = match('[');
6941
- key = parseObjectPropertyKey();
7480
+ if (match('*')) {
7481
+ lex();
7482
+ } else {
7483
+ key = parseObjectPropertyKey();
7484
+ }
6942
7485
  maybeMethod = tryParseMethodDefinition(token, key, computed, node);
6943
7486
 
6944
7487
  if (maybeMethod) {
@@ -6947,16 +7490,27 @@ define('logger', ['env!env/print'], function (print) {
6947
7490
  return maybeMethod;
6948
7491
  }
6949
7492
 
7493
+ if (!key) {
7494
+ throwUnexpectedToken(lookahead);
7495
+ }
7496
+
6950
7497
  // init property or short hand property.
6951
7498
  checkProto(key, computed, hasProto);
6952
7499
 
6953
7500
  if (match(':')) {
6954
7501
  lex();
6955
- value = parseAssignmentExpression();
7502
+ value = inheritCoverGrammar(parseAssignmentExpression);
6956
7503
  return node.finishProperty('init', key, computed, value, false, false);
6957
7504
  }
6958
7505
 
6959
7506
  if (token.type === Token.Identifier) {
7507
+ if (match('=')) {
7508
+ firstCoverInitializedNameError = lookahead;
7509
+ lex();
7510
+ value = isolateCoverGrammar(parseAssignmentExpression);
7511
+ return node.finishProperty('init', key, computed,
7512
+ new WrappingNode(token).finishAssignmentPattern(key, value), false, true);
7513
+ }
6960
7514
  return node.finishProperty('init', key, computed, key, false, true);
6961
7515
  }
6962
7516
 
@@ -6981,10 +7535,75 @@ define('logger', ['env!env/print'], function (print) {
6981
7535
  return node.finishObjectExpression(properties);
6982
7536
  }
6983
7537
 
7538
+ function reinterpretExpressionAsPattern(expr) {
7539
+ var i;
7540
+ switch (expr.type) {
7541
+ case Syntax.Identifier:
7542
+ case Syntax.MemberExpression:
7543
+ case Syntax.RestElement:
7544
+ case Syntax.AssignmentPattern:
7545
+ break;
7546
+ case Syntax.SpreadElement:
7547
+ expr.type = Syntax.RestElement;
7548
+ reinterpretExpressionAsPattern(expr.argument);
7549
+ break;
7550
+ case Syntax.ArrayExpression:
7551
+ expr.type = Syntax.ArrayPattern;
7552
+ for (i = 0; i < expr.elements.length; i++) {
7553
+ if (expr.elements[i] !== null) {
7554
+ reinterpretExpressionAsPattern(expr.elements[i]);
7555
+ }
7556
+ }
7557
+ break;
7558
+ case Syntax.ObjectExpression:
7559
+ expr.type = Syntax.ObjectPattern;
7560
+ for (i = 0; i < expr.properties.length; i++) {
7561
+ reinterpretExpressionAsPattern(expr.properties[i].value);
7562
+ }
7563
+ break;
7564
+ case Syntax.AssignmentExpression:
7565
+ expr.type = Syntax.AssignmentPattern;
7566
+ reinterpretExpressionAsPattern(expr.left);
7567
+ break;
7568
+ default:
7569
+ // Allow other node type for tolerant parsing.
7570
+ break;
7571
+ }
7572
+ }
7573
+
7574
+ function parseTemplateElement(option) {
7575
+ var node, token;
7576
+
7577
+ if (lookahead.type !== Token.Template || (option.head && !lookahead.head)) {
7578
+ throwUnexpectedToken();
7579
+ }
7580
+
7581
+ node = new Node();
7582
+ token = lex();
7583
+
7584
+ return node.finishTemplateElement({ raw: token.value.raw, cooked: token.value.cooked }, token.tail);
7585
+ }
7586
+
7587
+ function parseTemplateLiteral() {
7588
+ var quasi, quasis, expressions, node = new Node();
7589
+
7590
+ quasi = parseTemplateElement({ head: true });
7591
+ quasis = [ quasi ];
7592
+ expressions = [];
7593
+
7594
+ while (!quasi.tail) {
7595
+ expressions.push(parseExpression());
7596
+ quasi = parseTemplateElement({ head: false });
7597
+ quasis.push(quasi);
7598
+ }
7599
+
7600
+ return node.finishTemplateLiteral(quasis, expressions);
7601
+ }
7602
+
6984
7603
  // 11.1.6 The Grouping Operator
6985
7604
 
6986
7605
  function parseGroupExpression() {
6987
- var expr, expressions, startToken, isValidArrowParameter = true;
7606
+ var expr, expressions, startToken, i, params = [];
6988
7607
 
6989
7608
  expect('(');
6990
7609
 
@@ -6995,13 +7614,14 @@ define('logger', ['env!env/print'], function (print) {
6995
7614
  }
6996
7615
  return {
6997
7616
  type: PlaceHolders.ArrowParameterPlaceHolder,
6998
- params: []
7617
+ params: [],
7618
+ rawParams: []
6999
7619
  };
7000
7620
  }
7001
7621
 
7002
7622
  startToken = lookahead;
7003
7623
  if (match('...')) {
7004
- expr = parseRestElement();
7624
+ expr = parseRestElement(params);
7005
7625
  expect(')');
7006
7626
  if (!match('=>')) {
7007
7627
  expect('=>');
@@ -7012,13 +7632,11 @@ define('logger', ['env!env/print'], function (print) {
7012
7632
  };
7013
7633
  }
7014
7634
 
7015
- if (match('(')) {
7016
- isValidArrowParameter = false;
7017
- }
7018
-
7019
- expr = parseAssignmentExpression();
7635
+ isBindingElement = true;
7636
+ expr = inheritCoverGrammar(parseAssignmentExpression);
7020
7637
 
7021
7638
  if (match(',')) {
7639
+ isAssignmentTarget = false;
7022
7640
  expressions = [expr];
7023
7641
 
7024
7642
  while (startIndex < length) {
@@ -7028,23 +7646,25 @@ define('logger', ['env!env/print'], function (print) {
7028
7646
  lex();
7029
7647
 
7030
7648
  if (match('...')) {
7031
- if (!isValidArrowParameter) {
7649
+ if (!isBindingElement) {
7032
7650
  throwUnexpectedToken(lookahead);
7033
7651
  }
7034
- expressions.push(parseRestElement());
7652
+ expressions.push(parseRestElement(params));
7035
7653
  expect(')');
7036
7654
  if (!match('=>')) {
7037
7655
  expect('=>');
7038
7656
  }
7657
+ isBindingElement = false;
7658
+ for (i = 0; i < expressions.length; i++) {
7659
+ reinterpretExpressionAsPattern(expressions[i]);
7660
+ }
7039
7661
  return {
7040
7662
  type: PlaceHolders.ArrowParameterPlaceHolder,
7041
7663
  params: expressions
7042
7664
  };
7043
- } else if (match('(')) {
7044
- isValidArrowParameter = false;
7045
7665
  }
7046
7666
 
7047
- expressions.push(parseAssignmentExpression());
7667
+ expressions.push(inheritCoverGrammar(parseAssignmentExpression));
7048
7668
  }
7049
7669
 
7050
7670
  expr = new WrappingNode(startToken).finishSequenceExpression(expressions);
@@ -7053,10 +7673,25 @@ define('logger', ['env!env/print'], function (print) {
7053
7673
 
7054
7674
  expect(')');
7055
7675
 
7056
- if (match('=>') && !isValidArrowParameter) {
7057
- throwUnexpectedToken(lookahead);
7058
- }
7676
+ if (match('=>')) {
7677
+ if (!isBindingElement) {
7678
+ throwUnexpectedToken(lookahead);
7679
+ }
7059
7680
 
7681
+ if (expr.type === Syntax.SequenceExpression) {
7682
+ for (i = 0; i < expr.expressions.length; i++) {
7683
+ reinterpretExpressionAsPattern(expr.expressions[i]);
7684
+ }
7685
+ } else {
7686
+ reinterpretExpressionAsPattern(expr);
7687
+ }
7688
+
7689
+ expr = {
7690
+ type: PlaceHolders.ArrowParameterPlaceHolder,
7691
+ params: expr.type === Syntax.SequenceExpression ? expr.expressions : [expr]
7692
+ };
7693
+ }
7694
+ isBindingElement = false;
7060
7695
  return expr;
7061
7696
  }
7062
7697
 
@@ -7067,15 +7702,16 @@ define('logger', ['env!env/print'], function (print) {
7067
7702
  var type, token, expr, node;
7068
7703
 
7069
7704
  if (match('(')) {
7070
- return parseGroupExpression();
7705
+ isBindingElement = false;
7706
+ return inheritCoverGrammar(parseGroupExpression);
7071
7707
  }
7072
7708
 
7073
7709
  if (match('[')) {
7074
- return parseArrayInitialiser();
7710
+ return inheritCoverGrammar(parseArrayInitialiser);
7075
7711
  }
7076
7712
 
7077
7713
  if (match('{')) {
7078
- return parseObjectInitialiser();
7714
+ return inheritCoverGrammar(parseObjectInitialiser);
7079
7715
  }
7080
7716
 
7081
7717
  type = lookahead.type;
@@ -7084,11 +7720,13 @@ define('logger', ['env!env/print'], function (print) {
7084
7720
  if (type === Token.Identifier) {
7085
7721
  expr = node.finishIdentifier(lex().value);
7086
7722
  } else if (type === Token.StringLiteral || type === Token.NumericLiteral) {
7723
+ isAssignmentTarget = isBindingElement = false;
7087
7724
  if (strict && lookahead.octal) {
7088
7725
  tolerateUnexpectedToken(lookahead, Messages.StrictOctalLiteral);
7089
7726
  }
7090
7727
  expr = node.finishLiteral(lex());
7091
7728
  } else if (type === Token.Keyword) {
7729
+ isAssignmentTarget = isBindingElement = false;
7092
7730
  if (matchKeyword('function')) {
7093
7731
  return parseFunctionExpression();
7094
7732
  }
@@ -7101,14 +7739,17 @@ define('logger', ['env!env/print'], function (print) {
7101
7739
  }
7102
7740
  throwUnexpectedToken(lex());
7103
7741
  } else if (type === Token.BooleanLiteral) {
7742
+ isAssignmentTarget = isBindingElement = false;
7104
7743
  token = lex();
7105
7744
  token.value = (token.value === 'true');
7106
7745
  expr = node.finishLiteral(token);
7107
7746
  } else if (type === Token.NullLiteral) {
7747
+ isAssignmentTarget = isBindingElement = false;
7108
7748
  token = lex();
7109
7749
  token.value = null;
7110
7750
  expr = node.finishLiteral(token);
7111
7751
  } else if (match('/') || match('/=')) {
7752
+ isAssignmentTarget = isBindingElement = false;
7112
7753
  index = startIndex;
7113
7754
 
7114
7755
  if (typeof extra.tokens !== 'undefined') {
@@ -7118,6 +7759,8 @@ define('logger', ['env!env/print'], function (print) {
7118
7759
  }
7119
7760
  lex();
7120
7761
  expr = node.finishLiteral(token);
7762
+ } else if (type === Token.Template) {
7763
+ expr = parseTemplateLiteral();
7121
7764
  } else {
7122
7765
  throwUnexpectedToken(lex());
7123
7766
  }
@@ -7128,13 +7771,20 @@ define('logger', ['env!env/print'], function (print) {
7128
7771
  // 11.2 Left-Hand-Side Expressions
7129
7772
 
7130
7773
  function parseArguments() {
7131
- var args = [];
7774
+ var args = [], expr;
7132
7775
 
7133
7776
  expect('(');
7134
7777
 
7135
7778
  if (!match(')')) {
7136
7779
  while (startIndex < length) {
7137
- args.push(parseAssignmentExpression());
7780
+ if (match('...')) {
7781
+ expr = new Node();
7782
+ lex();
7783
+ expr.finishSpreadElement(isolateCoverGrammar(parseAssignmentExpression));
7784
+ } else {
7785
+ expr = isolateCoverGrammar(parseAssignmentExpression);
7786
+ }
7787
+ args.push(expr);
7138
7788
  if (match(')')) {
7139
7789
  break;
7140
7790
  }
@@ -7170,7 +7820,7 @@ define('logger', ['env!env/print'], function (print) {
7170
7820
 
7171
7821
  expect('[');
7172
7822
 
7173
- expr = parseExpression();
7823
+ expr = isolateCoverGrammar(parseExpression);
7174
7824
 
7175
7825
  expect(']');
7176
7826
 
@@ -7181,29 +7831,50 @@ define('logger', ['env!env/print'], function (print) {
7181
7831
  var callee, args, node = new Node();
7182
7832
 
7183
7833
  expectKeyword('new');
7184
- callee = parseLeftHandSideExpression();
7834
+ callee = isolateCoverGrammar(parseLeftHandSideExpression);
7185
7835
  args = match('(') ? parseArguments() : [];
7186
7836
 
7837
+ isAssignmentTarget = isBindingElement = false;
7838
+
7187
7839
  return node.finishNewExpression(callee, args);
7188
7840
  }
7189
7841
 
7190
7842
  function parseLeftHandSideExpressionAllowCall() {
7191
- var expr, args, property, startToken, previousAllowIn = state.allowIn;
7843
+ var quasi, expr, args, property, startToken, previousAllowIn = state.allowIn;
7192
7844
 
7193
7845
  startToken = lookahead;
7194
7846
  state.allowIn = true;
7195
- expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression();
7847
+
7848
+ if (matchKeyword('super') && state.inFunctionBody) {
7849
+ expr = new Node();
7850
+ lex();
7851
+ expr = expr.finishSuper();
7852
+ if (!match('(') && !match('.') && !match('[')) {
7853
+ throwUnexpectedToken(lookahead);
7854
+ }
7855
+ } else {
7856
+ expr = inheritCoverGrammar(matchKeyword('new') ? parseNewExpression : parsePrimaryExpression);
7857
+ }
7196
7858
 
7197
7859
  for (;;) {
7198
7860
  if (match('.')) {
7861
+ isBindingElement = false;
7862
+ isAssignmentTarget = true;
7199
7863
  property = parseNonComputedMember();
7200
7864
  expr = new WrappingNode(startToken).finishMemberExpression('.', expr, property);
7201
7865
  } else if (match('(')) {
7866
+ isBindingElement = false;
7867
+ isAssignmentTarget = false;
7202
7868
  args = parseArguments();
7203
7869
  expr = new WrappingNode(startToken).finishCallExpression(expr, args);
7204
7870
  } else if (match('[')) {
7871
+ isBindingElement = false;
7872
+ isAssignmentTarget = true;
7205
7873
  property = parseComputedMember();
7206
7874
  expr = new WrappingNode(startToken).finishMemberExpression('[', expr, property);
7875
+ } else if (lookahead.type === Token.Template && lookahead.head) {
7876
+ quasi = parseTemplateLiteral();
7877
+ expr = new WrappingNode(startToken).finishTaggedTemplateExpression(expr, quasi);
7207
7878
  } else {
7208
7879
  break;
7209
7880
  }
@@ -7214,20 +7885,36 @@ define('logger', ['env!env/print'], function (print) {
7214
7885
  }
7215
7886
 
7216
7887
  function parseLeftHandSideExpression() {
7217
- var expr, property, startToken;
7888
+ var quasi, expr, property, startToken;
7218
7889
  assert(state.allowIn, 'callee of new expression always allow in keyword.');
7219
7890
 
7220
7891
  startToken = lookahead;
7221
7892
 
7222
- expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression();
7893
+ if (matchKeyword('super') && state.inFunctionBody) {
7894
+ expr = new Node();
7895
+ lex();
7896
+ expr = expr.finishSuper();
7897
+ if (!match('[') && !match('.')) {
7898
+ throwUnexpectedToken(lookahead);
7899
+ }
7900
+ } else {
7901
+ expr = inheritCoverGrammar(matchKeyword('new') ? parseNewExpression : parsePrimaryExpression);
7902
+ }
7223
7903
 
7224
7904
  for (;;) {
7225
7905
  if (match('[')) {
7906
+ isBindingElement = false;
7907
+ isAssignmentTarget = true;
7226
7908
  property = parseComputedMember();
7227
7909
  expr = new WrappingNode(startToken).finishMemberExpression('[', expr, property);
7228
7910
  } else if (match('.')) {
7911
+ isBindingElement = false;
7912
+ isAssignmentTarget = true;
7229
7913
  property = parseNonComputedMember();
7230
7914
  expr = new WrappingNode(startToken).finishMemberExpression('.', expr, property);
7915
+ } else if (lookahead.type === Token.Template && lookahead.head) {
7916
+ quasi = parseTemplateLiteral();
7917
+ expr = new WrappingNode(startToken).finishTaggedTemplateExpression(expr, quasi);
7231
7918
  } else {
7232
7919
  break;
7233
7920
  }
@@ -7240,7 +7927,7 @@ define('logger', ['env!env/print'], function (print) {
7240
7927
  function parsePostfixExpression() {
7241
7928
  var expr, token, startToken = lookahead;
7242
7929
 
7243
- expr = parseLeftHandSideExpressionAllowCall();
7930
+ expr = inheritCoverGrammar(parseLeftHandSideExpressionAllowCall);
7244
7931
 
7245
7932
  if (!hasLineTerminator && lookahead.type === Token.Punctuator) {
7246
7933
  if (match('++') || match('--')) {
@@ -7249,10 +7936,12 @@ define('logger', ['env!env/print'], function (print) {
7249
7936
  tolerateError(Messages.StrictLHSPostfix);
7250
7937
  }
7251
7938
 
7252
- if (!isLeftHandSide(expr)) {
7939
+ if (!isAssignmentTarget) {
7253
7940
  tolerateError(Messages.InvalidLHSInAssignment);
7254
7941
  }
7255
7942
 
7943
+ isAssignmentTarget = isBindingElement = false;
7944
+
7256
7945
  token = lex();
7257
7946
  expr = new WrappingNode(startToken).finishPostfixExpression(token.value, expr);
7258
7947
  }
@@ -7271,30 +7960,32 @@ define('logger', ['env!env/print'], function (print) {
7271
7960
  } else if (match('++') || match('--')) {
7272
7961
  startToken = lookahead;
7273
7962
  token = lex();
7274
- expr = parseUnaryExpression();
7963
+ expr = inheritCoverGrammar(parseUnaryExpression);
7275
7964
  // 11.4.4, 11.4.5
7276
7965
  if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
7277
7966
  tolerateError(Messages.StrictLHSPrefix);
7278
7967
  }
7279
7968
 
7280
- if (!isLeftHandSide(expr)) {
7969
+ if (!isAssignmentTarget) {
7281
7970
  tolerateError(Messages.InvalidLHSInAssignment);
7282
7971
  }
7283
-
7284
7972
  expr = new WrappingNode(startToken).finishUnaryExpression(token.value, expr);
7973
+ isAssignmentTarget = isBindingElement = false;
7285
7974
  } else if (match('+') || match('-') || match('~') || match('!')) {
7286
7975
  startToken = lookahead;
7287
7976
  token = lex();
7288
- expr = parseUnaryExpression();
7977
+ expr = inheritCoverGrammar(parseUnaryExpression);
7289
7978
  expr = new WrappingNode(startToken).finishUnaryExpression(token.value, expr);
7979
+ isAssignmentTarget = isBindingElement = false;
7290
7980
  } else if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) {
7291
7981
  startToken = lookahead;
7292
7982
  token = lex();
7293
- expr = parseUnaryExpression();
7983
+ expr = inheritCoverGrammar(parseUnaryExpression);
7294
7984
  expr = new WrappingNode(startToken).finishUnaryExpression(token.value, expr);
7295
7985
  if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) {
7296
7986
  tolerateError(Messages.StrictDelete);
7297
7987
  }
7988
+ isAssignmentTarget = isBindingElement = false;
7298
7989
  } else {
7299
7990
  expr = parsePostfixExpression();
7300
7991
  }
@@ -7385,18 +8076,19 @@ define('logger', ['env!env/print'], function (print) {
7385
8076
  var marker, markers, expr, token, prec, stack, right, operator, left, i;
7386
8077
 
7387
8078
  marker = lookahead;
7388
- left = parseUnaryExpression();
8079
+ left = inheritCoverGrammar(parseUnaryExpression);
7389
8080
 
7390
8081
  token = lookahead;
7391
8082
  prec = binaryPrecedence(token, state.allowIn);
7392
8083
  if (prec === 0) {
7393
8084
  return left;
7394
8085
  }
8086
+ isAssignmentTarget = isBindingElement = false;
7395
8087
  token.prec = prec;
7396
8088
  lex();
7397
8089
 
7398
8090
  markers = [marker, lookahead];
7399
- right = parseUnaryExpression();
8091
+ right = isolateCoverGrammar(parseUnaryExpression);
7400
8092
 
7401
8093
  stack = [left, token, right];
7402
8094
 
@@ -7417,7 +8109,7 @@ define('logger', ['env!env/print'], function (print) {
7417
8109
  token.prec = prec;
7418
8110
  stack.push(token);
7419
8111
  markers.push(lookahead);
7420
- expr = parseUnaryExpression();
8112
+ expr = isolateCoverGrammar(parseUnaryExpression);
7421
8113
  stack.push(expr);
7422
8114
  }
7423
8115
 
@@ -7441,17 +8133,18 @@ define('logger', ['env!env/print'], function (print) {
7441
8133
 
7442
8134
  startToken = lookahead;
7443
8135
 
7444
- expr = parseBinaryExpression();
8136
+ expr = inheritCoverGrammar(parseBinaryExpression);
7445
8137
  if (match('?')) {
7446
8138
  lex();
7447
8139
  previousAllowIn = state.allowIn;
7448
8140
  state.allowIn = true;
7449
- consequent = parseAssignmentExpression();
8141
+ consequent = isolateCoverGrammar(parseAssignmentExpression);
7450
8142
  state.allowIn = previousAllowIn;
7451
8143
  expect(':');
7452
- alternate = parseAssignmentExpression();
8144
+ alternate = isolateCoverGrammar(parseAssignmentExpression);
7453
8145
 
7454
8146
  expr = new WrappingNode(startToken).finishConditionalExpression(expr, consequent, alternate);
8147
+ isAssignmentTarget = isBindingElement = false;
7455
8148
  }
7456
8149
 
7457
8150
  return expr;
@@ -7463,9 +8156,36 @@ define('logger', ['env!env/print'], function (print) {
7463
8156
  if (match('{')) {
7464
8157
  return parseFunctionSourceElements();
7465
8158
  }
7466
- return parseAssignmentExpression();
8159
+ return isolateCoverGrammar(parseAssignmentExpression);
7467
8160
  }
7468
8161
 
8162
+ function checkPatternParam(options, param) {
8163
+ var i;
8164
+ switch (param.type) {
8165
+ case Syntax.Identifier:
8166
+ validateParam(options, param, param.name);
8167
+ break;
8168
+ case Syntax.RestElement:
8169
+ checkPatternParam(options, param.argument);
8170
+ break;
8171
+ case Syntax.AssignmentPattern:
8172
+ checkPatternParam(options, param.left);
8173
+ break;
8174
+ case Syntax.ArrayPattern:
8175
+ for (i = 0; i < param.elements.length; i++) {
8176
+ if (param.elements[i] !== null) {
8177
+ checkPatternParam(options, param.elements[i]);
8178
+ }
8179
+ }
8180
+ break;
8181
+ default:
8182
+ assert(param.type === Syntax.ObjectPattern, 'Invalid type');
8183
+ for (i = 0; i < param.properties.length; i++) {
8184
+ checkPatternParam(options, param.properties[i].value);
8185
+ }
8186
+ break;
8187
+ }
8188
+ }
7469
8189
  function reinterpretAsCoverFormalsList(expr) {
7470
8190
  var i, len, param, params, defaults, defaultCount, options, token;
7471
8191
 
@@ -7475,10 +8195,6 @@ define('logger', ['env!env/print'], function (print) {
7475
8195
 
7476
8196
  switch (expr.type) {
7477
8197
  case Syntax.Identifier:
7478
- case Syntax.AssignmentExpression:
7479
- break;
7480
- case Syntax.SequenceExpression:
7481
- params = expr.expressions;
7482
8198
  break;
7483
8199
  case PlaceHolders.ArrowParameterPlaceHolder:
7484
8200
  params = expr.params;
@@ -7493,21 +8209,18 @@ define('logger', ['env!env/print'], function (print) {
7493
8209
 
7494
8210
  for (i = 0, len = params.length; i < len; i += 1) {
7495
8211
  param = params[i];
7496
- if (param.type === Syntax.Identifier) {
7497
- params[i] = param;
7498
- defaults.push(null);
7499
- validateParam(options, param, param.name);
7500
- } else if (param.type === Syntax.RestElement) {
7501
- params[i] = param;
7502
- defaults.push(null);
7503
- validateParam(options, param.argument, param.argument.name);
7504
- } else if (param.type === Syntax.AssignmentExpression) {
8212
+ switch (param.type) {
8213
+ case Syntax.AssignmentPattern:
7505
8214
  params[i] = param.left;
7506
8215
  defaults.push(param.right);
7507
8216
  ++defaultCount;
7508
- validateParam(options, param.left, param.left.name);
7509
- } else {
7510
- return null;
8217
+ checkPatternParam(options, param.left);
8218
+ break;
8219
+ default:
8220
+ checkPatternParam(options, param);
8221
+ params[i] = param;
8222
+ defaults.push(null);
8223
+ break;
7511
8224
  }
7512
8225
  }
7513
8226
 
@@ -7532,6 +8245,9 @@ define('logger', ['env!env/print'], function (print) {
7532
8245
  function parseArrowFunctionExpression(options, node) {
7533
8246
  var previousStrict, body;
7534
8247
 
8248
+ if (hasLineTerminator) {
8249
+ tolerateUnexpectedToken(lookahead);
8250
+ }
7535
8251
  expect('=>');
7536
8252
  previousStrict = strict;
7537
8253
 
@@ -7549,6 +8265,34 @@ define('logger', ['env!env/print'], function (print) {
7549
8265
  return node.finishArrowFunctionExpression(options.params, options.defaults, body, body.type !== Syntax.BlockStatement);
7550
8266
  }
7551
8267
 
8268
+ // [ES6] 14.4 Yield expression
8269
+
8270
+ function parseYieldExpression() {
8271
+ var argument, expr, delegate;
8272
+
8273
+ expr = new Node();
8274
+
8275
+ if (!state.allowYield) {
8276
+ tolerateUnexpectedToken(lookahead, Messages.IllegalYield);
8277
+ }
8278
+
8279
+ expectKeyword('yield');
8280
+
8281
+ if (!hasLineTerminator) {
8282
+ delegate = match('*');
8283
+ if (delegate) {
8284
+ lex();
8285
+ argument = parseExpression();
8286
+ } else {
8287
+ if (!match(';') && !match('}') && lookahead.type !== Token.EOF) {
8288
+ argument = parseExpression();
8289
+ }
8290
+ }
8291
+ }
8292
+
8293
+ return expr.finishYieldExpression(argument, delegate);
8294
+ }
8295
+
7552
8296
  // 11.13 Assignment Operators
7553
8297
 
7554
8298
  function parseAssignmentExpression() {
@@ -7557,19 +8301,26 @@ define('logger', ['env!env/print'], function (print) {
7557
8301
  startToken = lookahead;
7558
8302
  token = lookahead;
7559
8303
 
8304
+ if (matchKeyword('yield')) {
8305
+ return parseYieldExpression();
8306
+ }
8307
+
7560
8308
  expr = parseConditionalExpression();
7561
8309
 
7562
8310
  if (expr.type === PlaceHolders.ArrowParameterPlaceHolder || match('=>')) {
8311
+ isAssignmentTarget = isBindingElement = false;
7563
8312
  list = reinterpretAsCoverFormalsList(expr);
7564
8313
 
7565
8314
  if (list) {
8315
+ firstCoverInitializedNameError = null;
7566
8316
  return parseArrowFunctionExpression(list, new WrappingNode(startToken));
7567
8317
  }
8318
+
8319
+ return expr;
7568
8320
  }
7569
8321
 
7570
8322
  if (matchAssign()) {
7571
- // LeftHandSideExpression
7572
- if (!isLeftHandSide(expr)) {
8323
+ if (!isAssignmentTarget) {
7573
8324
  tolerateError(Messages.InvalidLHSInAssignment);
7574
8325
  }
7575
8326
 
@@ -7578,9 +8329,16 @@ define('logger', ['env!env/print'], function (print) {
7578
8329
  tolerateUnexpectedToken(token, Messages.StrictLHSAssignment);
7579
8330
  }
7580
8331
 
8332
+ if (!match('=')) {
8333
+ isAssignmentTarget = isBindingElement = false;
8334
+ } else {
8335
+ reinterpretExpressionAsPattern(expr);
8336
+ }
8337
+
7581
8338
  token = lex();
7582
- right = parseAssignmentExpression();
8339
+ right = isolateCoverGrammar(parseAssignmentExpression);
7583
8340
  expr = new WrappingNode(startToken).finishAssignmentExpression(token.value, expr, right);
8341
+ firstCoverInitializedNameError = null;
7584
8342
  }
7585
8343
 
7586
8344
  return expr;
@@ -7591,7 +8349,7 @@ define('logger', ['env!env/print'], function (print) {
7591
8349
  function parseExpression() {
7592
8350
  var expr, startToken = lookahead, expressions;
7593
8351
 
7594
- expr = parseAssignmentExpression();
8352
+ expr = isolateCoverGrammar(parseAssignmentExpression);
7595
8353
 
7596
8354
  if (match(',')) {
7597
8355
  expressions = [expr];
@@ -7601,7 +8359,7 @@ define('logger', ['env!env/print'], function (print) {
7601
8359
  break;
7602
8360
  }
7603
8361
  lex();
7604
- expressions.push(parseAssignmentExpression());
8362
+ expressions.push(isolateCoverGrammar(parseAssignmentExpression));
7605
8363
  }
7606
8364
 
7607
8365
  expr = new WrappingNode(startToken).finishSequenceExpression(expressions);
@@ -7615,9 +8373,19 @@ define('logger', ['env!env/print'], function (print) {
7615
8373
  function parseStatementListItem() {
7616
8374
  if (lookahead.type === Token.Keyword) {
7617
8375
  switch (lookahead.value) {
8376
+ case 'export':
8377
+ if (sourceType !== 'module') {
8378
+ tolerateUnexpectedToken(lookahead, Messages.IllegalExportDeclaration);
8379
+ }
8380
+ return parseExportDeclaration();
8381
+ case 'import':
8382
+ if (sourceType !== 'module') {
8383
+ tolerateUnexpectedToken(lookahead, Messages.IllegalImportDeclaration);
8384
+ }
8385
+ return parseImportDeclaration();
7618
8386
  case 'const':
7619
8387
  case 'let':
7620
- return parseLexicalDeclaration();
8388
+ return parseLexicalDeclaration({inFor: false});
7621
8389
  case 'function':
7622
8390
  return parseFunctionDeclaration(new Node());
7623
8391
  case 'class':
@@ -7671,9 +8439,9 @@ define('logger', ['env!env/print'], function (print) {
7671
8439
  }
7672
8440
 
7673
8441
  function parseVariableDeclaration() {
7674
- var init = null, id, node = new Node();
8442
+ var init = null, id, node = new Node(), params = [];
7675
8443
 
7676
- id = parseVariableIdentifier();
8444
+ id = parsePattern(params);
7677
8445
 
7678
8446
  // 12.2.1
7679
8447
  if (strict && isRestrictedWord(id.name)) {
@@ -7682,7 +8450,9 @@ define('logger', ['env!env/print'], function (print) {
7682
8450
 
7683
8451
  if (match('=')) {
7684
8452
  lex();
7685
- init = parseAssignmentExpression();
8453
+ init = isolateCoverGrammar(parseAssignmentExpression);
8454
+ } else if (id.type !== Syntax.Identifier) {
8455
+ expect('=');
7686
8456
  }
7687
8457
 
7688
8458
  return node.finishVariableDeclarator(id, init);
@@ -7714,34 +8484,34 @@ define('logger', ['env!env/print'], function (print) {
7714
8484
  return node.finishVariableDeclaration(declarations);
7715
8485
  }
7716
8486
 
7717
- function parseLexicalBinding(kind) {
7718
- var init = null, id, node = new Node();
8487
+ function parseLexicalBinding(kind, options) {
8488
+ var init = null, id, node = new Node(), params = [];
7719
8489
 
7720
- id = parseVariableIdentifier();
8490
+ id = parsePattern(params);
7721
8491
 
7722
8492
  // 12.2.1
7723
- if (strict && isRestrictedWord(id.name)) {
8493
+ if (strict && id.type === Syntax.Identifier && isRestrictedWord(id.name)) {
7724
8494
  tolerateError(Messages.StrictVarName);
7725
8495
  }
7726
8496
 
7727
8497
  if (kind === 'const') {
7728
- if (!matchKeyword('in')) {
8498
+ if (!matchKeyword('in') && !matchContextualKeyword('of')) {
7729
8499
  expect('=');
7730
- init = parseAssignmentExpression();
8500
+ init = isolateCoverGrammar(parseAssignmentExpression);
7731
8501
  }
7732
- } else if (match('=')) {
7733
- lex();
7734
- init = parseAssignmentExpression();
8502
+ } else if ((!options.inFor && id.type !== Syntax.Identifier) || match('=')) {
8503
+ expect('=');
8504
+ init = isolateCoverGrammar(parseAssignmentExpression);
7735
8505
  }
7736
8506
 
7737
8507
  return node.finishVariableDeclarator(id, init);
7738
8508
  }
7739
8509
 
7740
- function parseBindingList(kind) {
8510
+ function parseBindingList(kind, options) {
7741
8511
  var list = [];
7742
8512
 
7743
8513
  do {
7744
- list.push(parseLexicalBinding(kind));
8514
+ list.push(parseLexicalBinding(kind, options));
7745
8515
  if (!match(',')) {
7746
8516
  break;
7747
8517
  }
@@ -7751,20 +8521,20 @@ define('logger', ['env!env/print'], function (print) {
7751
8521
  return list;
7752
8522
  }
7753
8523
 
7754
- function parseLexicalDeclaration() {
8524
+ function parseLexicalDeclaration(options) {
7755
8525
  var kind, declarations, node = new Node();
7756
8526
 
7757
8527
  kind = lex().value;
7758
8528
  assert(kind === 'let' || kind === 'const', 'Lexical declaration must be either let or const');
7759
8529
 
7760
- declarations = parseBindingList(kind);
8530
+ declarations = parseBindingList(kind, options);
7761
8531
 
7762
8532
  consumeSemicolon();
7763
8533
 
7764
8534
  return node.finishLexicalDeclaration(declarations, kind);
7765
8535
  }
7766
8536
 
7767
- function parseRestElement() {
8537
+ function parseRestElement(params) {
7768
8538
  var param, node = new Node();
7769
8539
 
7770
8540
  lex();
@@ -7773,6 +8543,8 @@ define('logger', ['env!env/print'], function (print) {
7773
8543
  throwError(Messages.ObjectPatternAsRestParameter);
7774
8544
  }
7775
8545
 
8546
+ params.push(lookahead);
8547
+
7776
8548
  param = parseVariableIdentifier();
7777
8549
 
7778
8550
  if (match('=')) {
@@ -7877,10 +8649,11 @@ define('logger', ['env!env/print'], function (print) {
7877
8649
  }
7878
8650
 
7879
8651
  function parseForStatement(node) {
7880
- var init, test, update, left, right, kind, declarations,
8652
+ var init, forIn, initSeq, initStartToken, test, update, left, right, kind, declarations,
7881
8653
  body, oldInIteration, previousAllowIn = state.allowIn;
7882
8654
 
7883
8655
  init = test = update = null;
8656
+ forIn = true;
7884
8657
 
7885
8658
  expectKeyword('for');
7886
8659
 
@@ -7902,6 +8675,12 @@ define('logger', ['env!env/print'], function (print) {
7902
8675
  left = init;
7903
8676
  right = parseExpression();
7904
8677
  init = null;
8678
+ } else if (init.declarations.length === 1 && init.declarations[0].init === null && matchContextualKeyword('of')) {
8679
+ lex();
8680
+ left = init;
8681
+ right = parseAssignmentExpression();
8682
+ init = null;
8683
+ forIn = false;
7905
8684
  } else {
7906
8685
  expect(';');
7907
8686
  }
@@ -7910,7 +8689,7 @@ define('logger', ['env!env/print'], function (print) {
7910
8689
  kind = lex().value;
7911
8690
 
7912
8691
  state.allowIn = false;
7913
- declarations = parseBindingList(kind);
8692
+ declarations = parseBindingList(kind, {inFor: true});
7914
8693
  state.allowIn = previousAllowIn;
7915
8694
 
7916
8695
  if (declarations.length === 1 && declarations[0].init === null && matchKeyword('in')) {
@@ -7919,26 +8698,53 @@ define('logger', ['env!env/print'], function (print) {
7919
8698
  left = init;
7920
8699
  right = parseExpression();
7921
8700
  init = null;
8701
+ } else if (declarations.length === 1 && declarations[0].init === null && matchContextualKeyword('of')) {
8702
+ init = init.finishLexicalDeclaration(declarations, kind);
8703
+ lex();
8704
+ left = init;
8705
+ right = parseAssignmentExpression();
8706
+ init = null;
8707
+ forIn = false;
7922
8708
  } else {
7923
8709
  consumeSemicolon();
7924
8710
  init = init.finishLexicalDeclaration(declarations, kind);
7925
8711
  }
7926
8712
  } else {
8713
+ initStartToken = lookahead;
7927
8714
  state.allowIn = false;
7928
- init = parseExpression();
8715
+ init = inheritCoverGrammar(parseAssignmentExpression);
7929
8716
  state.allowIn = previousAllowIn;
7930
8717
 
7931
8718
  if (matchKeyword('in')) {
7932
- // LeftHandSideExpression
7933
- if (!isLeftHandSide(init)) {
8719
+ if (!isAssignmentTarget) {
7934
8720
  tolerateError(Messages.InvalidLHSInForIn);
7935
8721
  }
7936
8722
 
7937
8723
  lex();
8724
+ reinterpretExpressionAsPattern(init);
7938
8725
  left = init;
7939
8726
  right = parseExpression();
7940
8727
  init = null;
8728
+ } else if (matchContextualKeyword('of')) {
8729
+ if (!isAssignmentTarget) {
8730
+ tolerateError(Messages.InvalidLHSInForLoop);
8731
+ }
8732
+
8733
+ lex();
8734
+ reinterpretExpressionAsPattern(init);
8735
+ left = init;
8736
+ right = parseAssignmentExpression();
8737
+ init = null;
8738
+ forIn = false;
7941
8739
  } else {
8740
+ if (match(',')) {
8741
+ initSeq = [init];
8742
+ while (match(',')) {
8743
+ lex();
8744
+ initSeq.push(isolateCoverGrammar(parseAssignmentExpression));
8745
+ }
8746
+ init = new WrappingNode(initStartToken).finishSequenceExpression(initSeq);
8747
+ }
7942
8748
  expect(';');
7943
8749
  }
7944
8750
  }
@@ -7961,13 +8767,14 @@ define('logger', ['env!env/print'], function (print) {
7961
8767
  oldInIteration = state.inIteration;
7962
8768
  state.inIteration = true;
7963
8769
 
7964
- body = parseStatement();
8770
+ body = isolateCoverGrammar(parseStatement);
7965
8771
 
7966
8772
  state.inIteration = oldInIteration;
7967
8773
 
7968
8774
  return (typeof left === 'undefined') ?
7969
8775
  node.finishForStatement(init, test, update, body) :
7970
- node.finishForInStatement(left, right, body);
8776
+ forIn ? node.finishForInStatement(left, right, body) :
8777
+ node.finishForOfStatement(left, right, body);
7971
8778
  }
7972
8779
 
7973
8780
  // 12.7 The continue statement
@@ -8207,7 +9014,7 @@ define('logger', ['env!env/print'], function (print) {
8207
9014
  // 12.14 The try statement
8208
9015
 
8209
9016
  function parseCatchClause() {
8210
- var param, body, node = new Node();
9017
+ var param, params = [], paramMap = {}, key, i, body, node = new Node();
8211
9018
 
8212
9019
  expectKeyword('catch');
8213
9020
 
@@ -8216,7 +9023,15 @@ define('logger', ['env!env/print'], function (print) {
8216
9023
  throwUnexpectedToken(lookahead);
8217
9024
  }
8218
9025
 
8219
- param = parseVariableIdentifier();
9026
+ param = parsePattern(params);
9027
+ for (i = 0; i < params.length; i++) {
9028
+ key = '$' + params[i].value;
9029
+ if (Object.prototype.hasOwnProperty.call(paramMap, key)) {
9030
+ tolerateError(Messages.DuplicateBinding, params[i].value);
9031
+ }
9032
+ paramMap[key] = true;
9033
+ }
9034
+
8220
9035
  // 12.14.1
8221
9036
  if (strict && isRestrictedWord(param.name)) {
8222
9037
  tolerateError(Messages.StrictCatchVariable);
@@ -8276,7 +9091,7 @@ define('logger', ['env!env/print'], function (print) {
8276
9091
  if (type === Token.Punctuator && lookahead.value === '{') {
8277
9092
  return parseBlock();
8278
9093
  }
8279
-
9094
+ isAssignmentTarget = isBindingElement = true;
8280
9095
  node = new Node();
8281
9096
 
8282
9097
  if (type === Token.Punctuator) {
@@ -8428,7 +9243,7 @@ define('logger', ['env!env/print'], function (print) {
8428
9243
  options.firstRestricted = param;
8429
9244
  options.message = Messages.StrictReservedWord;
8430
9245
  } else if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) {
8431
- options.firstRestricted = param;
9246
+ options.stricted = param;
8432
9247
  options.message = Messages.StrictParamDupe;
8433
9248
  }
8434
9249
  }
@@ -8436,23 +9251,25 @@ define('logger', ['env!env/print'], function (print) {
8436
9251
  }
8437
9252
 
8438
9253
  function parseParam(options) {
8439
- var token, param, def;
9254
+ var token, param, params = [], i, def;
8440
9255
 
8441
9256
  token = lookahead;
8442
9257
  if (token.value === '...') {
8443
- param = parseRestElement();
9258
+ param = parseRestElement(params);
8444
9259
  validateParam(options, param.argument, param.argument.name);
8445
9260
  options.params.push(param);
8446
9261
  options.defaults.push(null);
8447
9262
  return false;
8448
9263
  }
8449
9264
 
8450
- param = parseVariableIdentifier();
8451
- validateParam(options, token, token.value);
9265
+ param = parsePatternWithDefault(params);
9266
+ for (i = 0; i < params.length; i++) {
9267
+ validateParam(options, params[i], params[i].value);
9268
+ }
8452
9269
 
8453
- if (match('=')) {
8454
- lex();
8455
- def = parseAssignmentExpression();
9270
+ if (param.type === Syntax.AssignmentPattern) {
9271
+ def = param.right;
9272
+ param = param.left;
8456
9273
  ++options.defaultCount;
8457
9274
  }
8458
9275
 
@@ -8499,27 +9316,40 @@ define('logger', ['env!env/print'], function (print) {
8499
9316
  };
8500
9317
  }
8501
9318
 
8502
- function parseFunctionDeclaration(node) {
8503
- var id, params = [], defaults = [], body, token, stricted, tmp, firstRestricted, message, previousStrict;
9319
+ function parseFunctionDeclaration(node, identifierIsOptional) {
9320
+ var id = null, params = [], defaults = [], body, token, stricted, tmp, firstRestricted, message, previousStrict,
9321
+ isGenerator, previousAllowYield;
8504
9322
 
8505
9323
  expectKeyword('function');
8506
- token = lookahead;
8507
- id = parseVariableIdentifier();
8508
- if (strict) {
8509
- if (isRestrictedWord(token.value)) {
8510
- tolerateUnexpectedToken(token, Messages.StrictFunctionName);
8511
- }
8512
- } else {
8513
- if (isRestrictedWord(token.value)) {
8514
- firstRestricted = token;
8515
- message = Messages.StrictFunctionName;
8516
- } else if (isStrictModeReservedWord(token.value)) {
8517
- firstRestricted = token;
8518
- message = Messages.StrictReservedWord;
9324
+
9325
+ isGenerator = match('*');
9326
+ if (isGenerator) {
9327
+ lex();
9328
+ }
9329
+
9330
+ if (!identifierIsOptional || !match('(')) {
9331
+ token = lookahead;
9332
+ id = parseVariableIdentifier();
9333
+ if (strict) {
9334
+ if (isRestrictedWord(token.value)) {
9335
+ tolerateUnexpectedToken(token, Messages.StrictFunctionName);
9336
+ }
9337
+ } else {
9338
+ if (isRestrictedWord(token.value)) {
9339
+ firstRestricted = token;
9340
+ message = Messages.StrictFunctionName;
9341
+ } else if (isStrictModeReservedWord(token.value)) {
9342
+ firstRestricted = token;
9343
+ message = Messages.StrictReservedWord;
9344
+ }
8519
9345
  }
8520
9346
  }
8521
9347
 
9348
+ previousAllowYield = state.allowYield;
9349
+ state.allowYield = false;
8522
9350
  tmp = parseParams(firstRestricted);
9351
+ state.allowYield = previousAllowYield;
9352
+
8523
9353
  params = tmp.params;
8524
9354
  defaults = tmp.defaults;
8525
9355
  stricted = tmp.stricted;
@@ -8528,7 +9358,9 @@ define('logger', ['env!env/print'], function (print) {
8528
9358
  message = tmp.message;
8529
9359
  }
8530
9360
 
9361
+ previousAllowYield = state.allowYield;
8531
9362
  previousStrict = strict;
9363
+ state.allowYield = isGenerator;
8532
9364
  body = parseFunctionSourceElements();
8533
9365
  if (strict && firstRestricted) {
8534
9366
  throwUnexpectedToken(firstRestricted, message);
@@ -8537,16 +9369,23 @@ define('logger', ['env!env/print'], function (print) {
8537
9369
  tolerateUnexpectedToken(stricted, message);
8538
9370
  }
8539
9371
  strict = previousStrict;
9372
+ state.allowYield = previousAllowYield;
8540
9373
 
8541
- return node.finishFunctionDeclaration(id, params, defaults, body);
9374
+ return node.finishFunctionDeclaration(id, params, defaults, body, isGenerator);
8542
9375
  }
8543
9376
 
8544
9377
  function parseFunctionExpression() {
8545
9378
  var token, id = null, stricted, firstRestricted, message, tmp,
8546
- params = [], defaults = [], body, previousStrict, node = new Node();
9379
+ params = [], defaults = [], body, previousStrict, node = new Node(),
9380
+ isGenerator, previousAllowYield;
8547
9381
 
8548
9382
  expectKeyword('function');
8549
9383
 
9384
+ isGenerator = match('*');
9385
+ if (isGenerator) {
9386
+ lex();
9387
+ }
9388
+
8550
9389
  if (!match('(')) {
8551
9390
  token = lookahead;
8552
9391
  id = parseVariableIdentifier();
@@ -8565,7 +9404,11 @@ define('logger', ['env!env/print'], function (print) {
8565
9404
  }
8566
9405
  }
8567
9406
 
9407
+ previousAllowYield = state.allowYield;
9408
+ state.allowYield = false;
8568
9409
  tmp = parseParams(firstRestricted);
9410
+ state.allowYield = previousAllowYield;
9411
+
8569
9412
  params = tmp.params;
8570
9413
  defaults = tmp.defaults;
8571
9414
  stricted = tmp.stricted;
@@ -8575,7 +9418,10 @@ define('logger', ['env!env/print'], function (print) {
8575
9418
  }
8576
9419
 
8577
9420
  previousStrict = strict;
9421
+ previousAllowYield = state.allowYield;
9422
+ state.allowYield = isGenerator;
8578
9423
  body = parseFunctionSourceElements();
9424
+
8579
9425
  if (strict && firstRestricted) {
8580
9426
  throwUnexpectedToken(firstRestricted, message);
8581
9427
  }
@@ -8583,8 +9429,9 @@ define('logger', ['env!env/print'], function (print) {
8583
9429
  tolerateUnexpectedToken(stricted, message);
8584
9430
  }
8585
9431
  strict = previousStrict;
9432
+ state.allowYield = previousAllowYield;
8586
9433
 
8587
- return node.finishFunctionExpression(id, params, defaults, body);
9434
+ return node.finishFunctionExpression(id, params, defaults, body, isGenerator);
8588
9435
  }
8589
9436
 
8590
9437
 
@@ -8603,16 +9450,24 @@ define('logger', ['env!env/print'], function (print) {
8603
9450
  token = lookahead;
8604
9451
  isStatic = false;
8605
9452
  computed = match('[');
8606
- key = parseObjectPropertyKey();
8607
- if (key.name === 'static' && lookaheadPropertyName()) {
8608
- token = lookahead;
8609
- isStatic = true;
8610
- computed = match('[');
9453
+ if (match('*')) {
9454
+ lex();
9455
+ } else {
8611
9456
  key = parseObjectPropertyKey();
9457
+ if (key.name === 'static' && (lookaheadPropertyName() || match('*'))) {
9458
+ token = lookahead;
9459
+ isStatic = true;
9460
+ computed = match('[');
9461
+ if (match('*')) {
9462
+ lex();
9463
+ } else {
9464
+ key = parseObjectPropertyKey();
9465
+ }
9466
+ }
8612
9467
  }
8613
9468
  method = tryParseMethodDefinition(token, key, computed, method);
8614
9469
  if (method) {
8615
- method.static = isStatic;
9470
+ method['static'] = isStatic;
8616
9471
  if (method.kind === 'init') {
8617
9472
  method.kind = 'method';
8618
9473
  }
@@ -8646,17 +9501,19 @@ define('logger', ['env!env/print'], function (print) {
8646
9501
  return classBody.finishClassBody(body);
8647
9502
  }
8648
9503
 
8649
- function parseClassDeclaration() {
9504
+ function parseClassDeclaration(identifierIsOptional) {
8650
9505
  var id = null, superClass = null, classNode = new Node(), classBody, previousStrict = strict;
8651
9506
  strict = true;
8652
9507
 
8653
9508
  expectKeyword('class');
8654
9509
 
8655
- id = parseVariableIdentifier();
9510
+ if (!identifierIsOptional || lookahead.type === Token.Identifier) {
9511
+ id = parseVariableIdentifier();
9512
+ }
8656
9513
 
8657
9514
  if (matchKeyword('extends')) {
8658
9515
  lex();
8659
- superClass = parseLeftHandSideExpressionAllowCall();
9516
+ superClass = isolateCoverGrammar(parseLeftHandSideExpressionAllowCall);
8660
9517
  }
8661
9518
  classBody = parseClassBody();
8662
9519
  strict = previousStrict;
@@ -8676,7 +9533,7 @@ define('logger', ['env!env/print'], function (print) {
8676
9533
 
8677
9534
  if (matchKeyword('extends')) {
8678
9535
  lex();
8679
- superClass = parseLeftHandSideExpressionAllowCall();
9536
+ superClass = isolateCoverGrammar(parseLeftHandSideExpressionAllowCall);
8680
9537
  }
8681
9538
  classBody = parseClassBody();
8682
9539
  strict = previousStrict;
@@ -8684,6 +9541,256 @@ define('logger', ['env!env/print'], function (print) {
8684
9541
  return classNode.finishClassExpression(id, superClass, classBody);
8685
9542
  }
8686
9543
 
9544
+ // Modules grammar from:
9545
+ // people.mozilla.org/~jorendorff/es6-draft.html
9546
+
9547
+ function parseModuleSpecifier() {
9548
+ var node = new Node();
9549
+
9550
+ if (lookahead.type !== Token.StringLiteral) {
9551
+ throwError(Messages.InvalidModuleSpecifier);
9552
+ }
9553
+ return node.finishLiteral(lex());
9554
+ }
9555
+
9556
+ function parseExportSpecifier() {
9557
+ var exported, local, node = new Node(), def;
9558
+ if (matchKeyword('default')) {
9559
+ // export {default} from 'something';
9560
+ def = new Node();
9561
+ lex();
9562
+ local = def.finishIdentifier('default');
9563
+ } else {
9564
+ local = parseVariableIdentifier();
9565
+ }
9566
+ if (matchContextualKeyword('as')) {
9567
+ lex();
9568
+ exported = parseNonComputedProperty();
9569
+ }
9570
+ return node.finishExportSpecifier(local, exported);
9571
+ }
9572
+
9573
+ function parseExportNamedDeclaration(node) {
9574
+ var declaration = null,
9575
+ isExportFromIdentifier,
9576
+ src = null, specifiers = [];
9577
+
9578
+ // non-default export
9579
+ if (lookahead.type === Token.Keyword) {
9580
+ // covers:
9581
+ // export var f = 1;
9582
+ switch (lookahead.value) {
9583
+ case 'let':
9584
+ case 'const':
9585
+ case 'var':
9586
+ case 'class':
9587
+ case 'function':
9588
+ declaration = parseStatementListItem();
9589
+ return node.finishExportNamedDeclaration(declaration, specifiers, null);
9590
+ }
9591
+ }
9592
+
9593
+ expect('{');
9594
+ if (!match('}')) {
9595
+ do {
9596
+ isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default');
9597
+ specifiers.push(parseExportSpecifier());
9598
+ } while (match(',') && lex());
9599
+ }
9600
+ expect('}');
9601
+
9602
+ if (matchContextualKeyword('from')) {
9603
+ // covering:
9604
+ // export {default} from 'foo';
9605
+ // export {foo} from 'foo';
9606
+ lex();
9607
+ src = parseModuleSpecifier();
9608
+ consumeSemicolon();
9609
+ } else if (isExportFromIdentifier) {
9610
+ // covering:
9611
+ // export {default}; // missing fromClause
9612
+ throwError(lookahead.value ?
9613
+ Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
9614
+ } else {
9615
+ // cover
9616
+ // export {foo};
9617
+ consumeSemicolon();
9618
+ }
9619
+ return node.finishExportNamedDeclaration(declaration, specifiers, src);
9620
+ }
9621
+
9622
+ function parseExportDefaultDeclaration(node) {
9623
+ var declaration = null,
9624
+ expression = null;
9625
+
9626
+ // covers:
9627
+ // export default ...
9628
+ expectKeyword('default');
9629
+
9630
+ if (matchKeyword('function')) {
9631
+ // covers:
9632
+ // export default function foo () {}
9633
+ // export default function () {}
9634
+ declaration = parseFunctionDeclaration(new Node(), true);
9635
+ return node.finishExportDefaultDeclaration(declaration);
9636
+ }
9637
+ if (matchKeyword('class')) {
9638
+ declaration = parseClassDeclaration(true);
9639
+ return node.finishExportDefaultDeclaration(declaration);
9640
+ }
9641
+
9642
+ if (matchContextualKeyword('from')) {
9643
+ throwError(Messages.UnexpectedToken, lookahead.value);
9644
+ }
9645
+
9646
+ // covers:
9647
+ // export default {};
9648
+ // export default [];
9649
+ // export default (1 + 2);
9650
+ if (match('{')) {
9651
+ expression = parseObjectInitialiser();
9652
+ } else if (match('[')) {
9653
+ expression = parseArrayInitialiser();
9654
+ } else {
9655
+ expression = parseAssignmentExpression();
9656
+ }
9657
+ consumeSemicolon();
9658
+ return node.finishExportDefaultDeclaration(expression);
9659
+ }
9660
+
9661
+ function parseExportAllDeclaration(node) {
9662
+ var src;
9663
+
9664
+ // covers:
9665
+ // export * from 'foo';
9666
+ expect('*');
9667
+ if (!matchContextualKeyword('from')) {
9668
+ throwError(lookahead.value ?
9669
+ Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
9670
+ }
9671
+ lex();
9672
+ src = parseModuleSpecifier();
9673
+ consumeSemicolon();
9674
+
9675
+ return node.finishExportAllDeclaration(src);
9676
+ }
9677
+
9678
+ function parseExportDeclaration() {
9679
+ var node = new Node();
9680
+ if (state.inFunctionBody) {
9681
+ throwError(Messages.IllegalExportDeclaration);
9682
+ }
9683
+
9684
+ expectKeyword('export');
9685
+
9686
+ if (matchKeyword('default')) {
9687
+ return parseExportDefaultDeclaration(node);
9688
+ }
9689
+ if (match('*')) {
9690
+ return parseExportAllDeclaration(node);
9691
+ }
9692
+ return parseExportNamedDeclaration(node);
9693
+ }
9694
+
9695
+ function parseImportSpecifier() {
9696
+ // import {<foo as bar>} ...;
9697
+ var local, imported, node = new Node();
9698
+
9699
+ imported = parseNonComputedProperty();
9700
+ if (matchContextualKeyword('as')) {
9701
+ lex();
9702
+ local = parseVariableIdentifier();
9703
+ }
9704
+
9705
+ return node.finishImportSpecifier(local, imported);
9706
+ }
9707
+
9708
+ function parseNamedImports() {
9709
+ var specifiers = [];
9710
+ // {foo, bar as bas}
9711
+ expect('{');
9712
+ if (!match('}')) {
9713
+ do {
9714
+ specifiers.push(parseImportSpecifier());
9715
+ } while (match(',') && lex());
9716
+ }
9717
+ expect('}');
9718
+ return specifiers;
9719
+ }
9720
+
9721
+ function parseImportDefaultSpecifier() {
9722
+ // import <foo> ...;
9723
+ var local, node = new Node();
9724
+
9725
+ local = parseNonComputedProperty();
9726
+
9727
+ return node.finishImportDefaultSpecifier(local);
9728
+ }
9729
+
9730
+ function parseImportNamespaceSpecifier() {
9731
+ // import <* as foo> ...;
9732
+ var local, node = new Node();
9733
+
9734
+ expect('*');
9735
+ if (!matchContextualKeyword('as')) {
9736
+ throwError(Messages.NoAsAfterImportNamespace);
9737
+ }
9738
+ lex();
9739
+ local = parseNonComputedProperty();
9740
+
9741
+ return node.finishImportNamespaceSpecifier(local);
9742
+ }
9743
+
9744
+ function parseImportDeclaration() {
9745
+ var specifiers, src, node = new Node();
9746
+
9747
+ if (state.inFunctionBody) {
9748
+ throwError(Messages.IllegalImportDeclaration);
9749
+ }
9750
+
9751
+ expectKeyword('import');
9752
+ specifiers = [];
9753
+
9754
+ if (lookahead.type === Token.StringLiteral) {
9755
+ // covers:
9756
+ // import 'foo';
9757
+ src = parseModuleSpecifier();
9758
+ consumeSemicolon();
9759
+ return node.finishImportDeclaration(specifiers, src);
9760
+ }
9761
+
9762
+ if (!matchKeyword('default') && isIdentifierName(lookahead)) {
9763
+ // covers:
9764
+ // import foo
9765
+ // import foo, ...
9766
+ specifiers.push(parseImportDefaultSpecifier());
9767
+ if (match(',')) {
9768
+ lex();
9769
+ }
9770
+ }
9771
+ if (match('*')) {
9772
+ // covers:
9773
+ // import foo, * as foo
9774
+ // import * as foo
9775
+ specifiers.push(parseImportNamespaceSpecifier());
9776
+ } else if (match('{')) {
9777
+ // covers:
9778
+ // import foo, {bar}
9779
+ // import {bar}
9780
+ specifiers = specifiers.concat(parseNamedImports());
9781
+ }
9782
+
9783
+ if (!matchContextualKeyword('from')) {
9784
+ throwError(lookahead.value ?
9785
+ Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
9786
+ }
9787
+ lex();
9788
+ src = parseModuleSpecifier();
9789
+ consumeSemicolon();
9790
+
9791
+ return node.finishImportDeclaration(specifiers, src);
9792
+ }
9793
+
8687
9794
  // 14 Program
8688
9795
 
8689
9796
  function parseScriptBody() {
@@ -8730,7 +9837,6 @@ define('logger', ['env!env/print'], function (print) {
8730
9837
 
8731
9838
  peek();
8732
9839
  node = new Node();
8733
- strict = false;
8734
9840
 
8735
9841
  body = parseScriptBody();
8736
9842
  return node.finishProgram(body);
@@ -8783,11 +9889,13 @@ define('logger', ['env!env/print'], function (print) {
8783
9889
  lookahead = null;
8784
9890
  state = {
8785
9891
  allowIn: true,
9892
+ allowYield: false,
8786
9893
  labelSet: {},
8787
9894
  inFunctionBody: false,
8788
9895
  inIteration: false,
8789
9896
  inSwitch: false,
8790
- lastCommentStart: -1
9897
+ lastCommentStart: -1,
9898
+ curlyStack: []
8791
9899
  };
8792
9900
 
8793
9901
  extra = {};
@@ -8870,12 +9978,16 @@ define('logger', ['env!env/print'], function (print) {
8870
9978
  lookahead = null;
8871
9979
  state = {
8872
9980
  allowIn: true,
9981
+ allowYield: false,
8873
9982
  labelSet: {},
8874
9983
  inFunctionBody: false,
8875
9984
  inIteration: false,
8876
9985
  inSwitch: false,
8877
- lastCommentStart: -1
9986
+ lastCommentStart: -1,
9987
+ curlyStack: []
8878
9988
  };
9989
+ sourceType = 'script';
9990
+ strict = false;
8879
9991
 
8880
9992
  extra = {};
8881
9993
  if (typeof options !== 'undefined') {
@@ -8903,6 +10015,11 @@ define('logger', ['env!env/print'], function (print) {
8903
10015
  extra.trailingComments = [];
8904
10016
  extra.leadingComments = [];
8905
10017
  }
10018
+ if (options.sourceType === 'module') {
10019
+ // very restrictive condition for now
10020
+ sourceType = options.sourceType;
10021
+ strict = true;
10022
+ }
8906
10023
  }
8907
10024
 
8908
10025
  try {
@@ -8927,14 +10044,14 @@ define('logger', ['env!env/print'], function (print) {
8927
10044
  }
8928
10045
 
8929
10046
  // Sync with *.json manifests.
8930
- exports.version = '2.1.0';
10047
+ exports.version = '2.4.1';
8931
10048
 
8932
10049
  exports.tokenize = tokenize;
8933
10050
 
8934
10051
  exports.parse = parse;
8935
10052
 
8936
10053
  // Deep copy.
8937
- /* istanbul ignore next */
10054
+ /* istanbul ignore next */
8938
10055
  exports.Syntax = (function () {
8939
10056
  var name, types = {};
8940
10057
 
@@ -15840,10 +16957,12 @@ function defaults(args, defs, croak) {
15840
16957
  };
15841
16958
 
15842
16959
  function merge(obj, ext) {
16960
+ var count = 0;
15843
16961
  for (var i in ext) if (ext.hasOwnProperty(i)) {
15844
16962
  obj[i] = ext[i];
16963
+ count++;
15845
16964
  }
15846
- return obj;
16965
+ return count;
15847
16966
  };
15848
16967
 
15849
16968
  function noop() {};
@@ -16032,7 +17151,13 @@ Dictionary.prototype = {
16032
17151
  for (var i in this._values)
16033
17152
  ret.push(f(this._values[i], i.substr(1)));
16034
17153
  return ret;
16035
- }
17154
+ },
17155
+ toObject: function() { return this._values }
17156
+ };
17157
+ Dictionary.fromObject = function(obj) {
17158
+ var dict = new Dictionary();
17159
+ dict._size = merge(dict._values, obj);
17160
+ return dict;
16036
17161
  };
16037
17162
 
16038
17163
  /***********************************************************************
@@ -16121,7 +17246,7 @@ function DEFNODE(type, props, methods, base) {
16121
17246
  return ctor;
16122
17247
  };
16123
17248
 
16124
- var AST_Token = DEFNODE("Token", "type value line col pos endpos nlb comments_before file", {
17249
+ var AST_Token = DEFNODE("Token", "type value line col pos endline endcol endpos nlb comments_before file", {
16125
17250
  }, null);
16126
17251
 
16127
17252
  var AST_Node = DEFNODE("Node", "start end", {
@@ -16157,11 +17282,12 @@ var AST_Debugger = DEFNODE("Debugger", null, {
16157
17282
  $documentation: "Represents a debugger statement",
16158
17283
  }, AST_Statement);
16159
17284
 
16160
- var AST_Directive = DEFNODE("Directive", "value scope", {
17285
+ var AST_Directive = DEFNODE("Directive", "value scope quote", {
16161
17286
  $documentation: "Represents a directive, like \"use strict\";",
16162
17287
  $propdoc: {
16163
17288
  value: "[string] The value of this directive as a plain string (it's not an AST_String!)",
16164
- scope: "[AST_Scope/S] The scope that this directive affects"
17289
+ scope: "[AST_Scope/S] The scope that this directive affects",
17290
+ quote: "[string] the original quote character"
16165
17291
  },
16166
17292
  }, AST_Statement);
16167
17293
 
@@ -16242,21 +17368,27 @@ var AST_DWLoop = DEFNODE("DWLoop", "condition", {
16242
17368
  $documentation: "Base class for do/while statements",
16243
17369
  $propdoc: {
16244
17370
  condition: "[AST_Node] the loop condition. Should not be instanceof AST_Statement"
16245
- },
16246
- _walk: function(visitor) {
16247
- return visitor._visit(this, function(){
16248
- this.condition._walk(visitor);
16249
- this.body._walk(visitor);
16250
- });
16251
17371
  }
16252
17372
  }, AST_IterationStatement);
16253
17373
 
16254
17374
  var AST_Do = DEFNODE("Do", null, {
16255
17375
  $documentation: "A `do` statement",
17376
+ _walk: function(visitor) {
17377
+ return visitor._visit(this, function(){
17378
+ this.body._walk(visitor);
17379
+ this.condition._walk(visitor);
17380
+ });
17381
+ }
16256
17382
  }, AST_DWLoop);
16257
17383
 
16258
17384
  var AST_While = DEFNODE("While", null, {
16259
17385
  $documentation: "A `while` statement",
17386
+ _walk: function(visitor) {
17387
+ return visitor._visit(this, function(){
17388
+ this.condition._walk(visitor);
17389
+ this.body._walk(visitor);
17390
+ });
17391
+ }
16260
17392
  }, AST_DWLoop);
16261
17393
 
16262
17394
  var AST_For = DEFNODE("For", "init condition step", {
@@ -16797,8 +17929,11 @@ var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", {
16797
17929
  }
16798
17930
  });
16799
17931
 
16800
- var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", null, {
17932
+ var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", "quote", {
16801
17933
  $documentation: "A key: value object property",
17934
+ $propdoc: {
17935
+ quote: "[string] the original quote character"
17936
+ }
16802
17937
  }, AST_ObjectProperty);
16803
17938
 
16804
17939
  var AST_ObjectSetter = DEFNODE("ObjectSetter", null, {
@@ -16883,10 +18018,11 @@ var AST_Constant = DEFNODE("Constant", null, {
16883
18018
  }
16884
18019
  });
16885
18020
 
16886
- var AST_String = DEFNODE("String", "value", {
18021
+ var AST_String = DEFNODE("String", "value quote", {
16887
18022
  $documentation: "A string literal",
16888
18023
  $propdoc: {
16889
- value: "[string] the contents of this string"
18024
+ value: "[string] the contents of this string",
18025
+ quote: "[string] the original quote character"
16890
18026
  }
16891
18027
  }, AST_Constant);
16892
18028
 
@@ -17130,7 +18266,7 @@ var OPERATORS = makePredicate([
17130
18266
  "||"
17131
18267
  ]);
17132
18268
 
17133
- var WHITESPACE_CHARS = makePredicate(characters(" \u00a0\n\r\t\f\u000b\u200b\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000"));
18269
+ var WHITESPACE_CHARS = makePredicate(characters(" \u00a0\n\r\t\f\u000b\u200b\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\uFEFF"));
17134
18270
 
17135
18271
  var PUNC_BEFORE_EXPRESSION = makePredicate(characters("[{(,.;:"));
17136
18272
 
@@ -17142,7 +18278,8 @@ var REGEXP_MODIFIERS = makePredicate(characters("gmsiy"));
17142
18278
 
17143
18279
  // regexps adapted from http://xregexp.com/plugins/#unicode
17144
18280
  var UNICODE = {
17145
- 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]"),
18281
+ 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\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\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-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\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-\\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-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\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-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\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]"),
18282
+ 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\\u0DE6-\\u0DEF\\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\\uA9F0-\\uA9F9\\uAA50-\\uAA59\\uABF0-\\uABF9\\uFF10-\\uFF19]"),
17146
18283
  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]"),
17147
18284
  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]"),
17148
18285
  connector_punctuation: new RegExp("[\\u005F\\u203F\\u2040\\u2054\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFF3F]")
@@ -17155,13 +18292,17 @@ function is_letter(code) {
17155
18292
  };
17156
18293
 
17157
18294
  function is_digit(code) {
17158
- return code >= 48 && code <= 57; //XXX: find out if "UnicodeDigit" means something else than 0..9
18295
+ return code >= 48 && code <= 57;
17159
18296
  };
17160
18297
 
17161
18298
  function is_alphanumeric_char(code) {
17162
18299
  return is_digit(code) || is_letter(code);
17163
18300
  };
17164
18301
 
18302
+ function is_unicode_digit(code) {
18303
+ return UNICODE.digit.test(String.fromCharCode(code));
18304
+ }
18305
+
17165
18306
  function is_unicode_combining_mark(ch) {
17166
18307
  return UNICODE.non_spacing_mark.test(ch) || UNICODE.space_combining_mark.test(ch);
17167
18308
  };
@@ -17186,6 +18327,7 @@ function is_identifier_char(ch) {
17186
18327
  || code == 8205 // \u200d: zero-width joiner <ZWJ> (in my ECMA-262 PDF, this is also 200c)
17187
18328
  || is_unicode_combining_mark(ch)
17188
18329
  || is_unicode_connector_punctuation(ch)
18330
+ || is_unicode_digit(code)
17189
18331
  ;
17190
18332
  };
17191
18333
 
@@ -17203,8 +18345,9 @@ function parse_js_number(num) {
17203
18345
  }
17204
18346
  };
17205
18347
 
17206
- function JS_Parse_Error(message, line, col, pos) {
18348
+ function JS_Parse_Error(message, filename, line, col, pos) {
17207
18349
  this.message = message;
18350
+ this.filename = filename;
17208
18351
  this.line = line;
17209
18352
  this.col = col;
17210
18353
  this.pos = pos;
@@ -17216,7 +18359,7 @@ JS_Parse_Error.prototype.toString = function() {
17216
18359
  };
17217
18360
 
17218
18361
  function js_error(message, filename, line, col, pos) {
17219
- throw new JS_Parse_Error(message, line, col, pos);
18362
+ throw new JS_Parse_Error(message, filename, line, col, pos);
17220
18363
  };
17221
18364
 
17222
18365
  function is_token(token, type, val) {
@@ -17228,7 +18371,7 @@ var EX_EOF = {};
17228
18371
  function tokenizer($TEXT, filename, html5_comments) {
17229
18372
 
17230
18373
  var S = {
17231
- text : $TEXT.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/\uFEFF/g, ''),
18374
+ text : $TEXT,
17232
18375
  filename : filename,
17233
18376
  pos : 0,
17234
18377
  tokpos : 0,
@@ -17247,10 +18390,15 @@ function tokenizer($TEXT, filename, html5_comments) {
17247
18390
  var ch = S.text.charAt(S.pos++);
17248
18391
  if (signal_eof && !ch)
17249
18392
  throw EX_EOF;
17250
- if (ch == "\n") {
18393
+ if ("\r\n\u2028\u2029".indexOf(ch) >= 0) {
17251
18394
  S.newline_before = S.newline_before || !in_string;
17252
18395
  ++S.line;
17253
18396
  S.col = 0;
18397
+ if (!in_string && ch == "\r" && peek() == "\n") {
18398
+ // treat a \r\n sequence as a single \n
18399
+ ++S.pos;
18400
+ ch = "\n";
18401
+ }
17254
18402
  } else {
17255
18403
  ++S.col;
17256
18404
  }
@@ -17284,14 +18432,16 @@ function tokenizer($TEXT, filename, html5_comments) {
17284
18432
  (type == "punc" && PUNC_BEFORE_EXPRESSION(value)));
17285
18433
  prev_was_dot = (type == "punc" && value == ".");
17286
18434
  var ret = {
17287
- type : type,
17288
- value : value,
17289
- line : S.tokline,
17290
- col : S.tokcol,
17291
- pos : S.tokpos,
17292
- endpos : S.pos,
17293
- nlb : S.newline_before,
17294
- file : filename
18435
+ type : type,
18436
+ value : value,
18437
+ line : S.tokline,
18438
+ col : S.tokcol,
18439
+ pos : S.tokpos,
18440
+ endline : S.line,
18441
+ endcol : S.col,
18442
+ endpos : S.pos,
18443
+ nlb : S.newline_before,
18444
+ file : filename
17295
18445
  };
17296
18446
  if (!is_comment) {
17297
18447
  ret.comments_before = S.comments_before;
@@ -17306,7 +18456,8 @@ function tokenizer($TEXT, filename, html5_comments) {
17306
18456
  };
17307
18457
 
17308
18458
  function skip_whitespace() {
17309
- while (WHITESPACE_CHARS(peek()))
18459
+ var ch;
18460
+ while (WHITESPACE_CHARS(ch = peek()) || ch == "\u2028" || ch == "\u2029")
17310
18461
  next();
17311
18462
  };
17312
18463
 
@@ -17361,8 +18512,13 @@ function tokenizer($TEXT, filename, html5_comments) {
17361
18512
  case 120 : return String.fromCharCode(hex_bytes(2)); // \x
17362
18513
  case 117 : return String.fromCharCode(hex_bytes(4)); // \u
17363
18514
  case 10 : return ""; // newline
17364
- default : return ch;
18515
+ case 13 : // \r
18516
+ if (peek() == "\n") { // DOS newline
18517
+ next(true, in_string);
18518
+ return "";
18519
+ }
17365
18520
  }
18521
+ return ch;
17366
18522
  };
17367
18523
 
17368
18524
  function hex_bytes(n) {
@@ -17376,10 +18532,10 @@ function tokenizer($TEXT, filename, html5_comments) {
17376
18532
  return num;
17377
18533
  };
17378
18534
 
17379
- var read_string = with_eof_error("Unterminated string constant", function(){
18535
+ var read_string = with_eof_error("Unterminated string constant", function(quote_char){
17380
18536
  var quote = next(), ret = "";
17381
18537
  for (;;) {
17382
- var ch = next(true);
18538
+ var ch = next(true, true);
17383
18539
  if (ch == "\\") {
17384
18540
  // read OctalEscapeSequence (XXX: deprecated if "strict mode")
17385
18541
  // https://github.com/mishoo/UglifyJS/issues/178
@@ -17401,7 +18557,9 @@ function tokenizer($TEXT, filename, html5_comments) {
17401
18557
  else if (ch == quote) break;
17402
18558
  ret += ch;
17403
18559
  }
17404
- return token("string", ret);
18560
+ var tok = token("string", ret);
18561
+ tok.quote = quote_char;
18562
+ return tok;
17405
18563
  });
17406
18564
 
17407
18565
  function skip_line_comment(type) {
@@ -17414,6 +18572,7 @@ function tokenizer($TEXT, filename, html5_comments) {
17414
18572
  ret = S.text.substring(S.pos, i);
17415
18573
  S.pos = i;
17416
18574
  }
18575
+ S.col = S.tokcol + (S.pos - S.tokpos);
17417
18576
  S.comments_before.push(token(type, ret, true));
17418
18577
  S.regex_allowed = regex_allowed;
17419
18578
  return next_token();
@@ -17555,7 +18714,7 @@ function tokenizer($TEXT, filename, html5_comments) {
17555
18714
  if (!ch) return token("eof");
17556
18715
  var code = ch.charCodeAt(0);
17557
18716
  switch (code) {
17558
- case 34: case 39: return read_string();
18717
+ case 34: case 39: return read_string(ch);
17559
18718
  case 46: return handle_dot();
17560
18719
  case 47: return handle_slash();
17561
18720
  }
@@ -17745,8 +18904,14 @@ function parse($TEXT, options) {
17745
18904
  case "string":
17746
18905
  var dir = S.in_directives, stat = simple_statement();
17747
18906
  // XXXv2: decide how to fix directives
17748
- if (dir && stat.body instanceof AST_String && !is("punc", ","))
17749
- return new AST_Directive({ value: stat.body.value });
18907
+ if (dir && stat.body instanceof AST_String && !is("punc", ",")) {
18908
+ return new AST_Directive({
18909
+ start : stat.body.start,
18910
+ end : stat.body.end,
18911
+ quote : stat.body.quote,
18912
+ value : stat.body.value,
18913
+ });
18914
+ }
17750
18915
  return stat;
17751
18916
  case "num":
17752
18917
  case "regexp":
@@ -18132,7 +19297,12 @@ function parse($TEXT, options) {
18132
19297
  ret = new AST_Number({ start: tok, end: tok, value: tok.value });
18133
19298
  break;
18134
19299
  case "string":
18135
- ret = new AST_String({ start: tok, end: tok, value: tok.value });
19300
+ ret = new AST_String({
19301
+ start : tok,
19302
+ end : tok,
19303
+ value : tok.value,
19304
+ quote : tok.quote
19305
+ });
18136
19306
  break;
18137
19307
  case "regexp":
18138
19308
  ret = new AST_RegExp({ start: tok, end: tok, value: tok.value });
@@ -18245,6 +19415,7 @@ function parse($TEXT, options) {
18245
19415
  expect(":");
18246
19416
  a.push(new AST_ObjectKeyVal({
18247
19417
  start : start,
19418
+ quote : start.quote,
18248
19419
  key : name,
18249
19420
  value : expression(false),
18250
19421
  end : prev()
@@ -18750,23 +19921,36 @@ function SymbolDef(scope, index, orig) {
18750
19921
 
18751
19922
  SymbolDef.prototype = {
18752
19923
  unmangleable: function(options) {
18753
- return (this.global && !(options && options.toplevel))
19924
+ if (!options) options = {};
19925
+
19926
+ return (this.global && !options.toplevel)
18754
19927
  || this.undeclared
18755
- || (!(options && options.eval) && (this.scope.uses_eval || this.scope.uses_with));
19928
+ || (!options.eval && (this.scope.uses_eval || this.scope.uses_with))
19929
+ || (options.keep_fnames
19930
+ && (this.orig[0] instanceof AST_SymbolLambda
19931
+ || this.orig[0] instanceof AST_SymbolDefun));
18756
19932
  },
18757
19933
  mangle: function(options) {
18758
- if (!this.mangled_name && !this.unmangleable(options)) {
19934
+ var cache = options.cache && options.cache.props;
19935
+ if (this.global && cache && cache.has(this.name)) {
19936
+ this.mangled_name = cache.get(this.name);
19937
+ }
19938
+ else if (!this.mangled_name && !this.unmangleable(options)) {
18759
19939
  var s = this.scope;
18760
19940
  if (!options.screw_ie8 && this.orig[0] instanceof AST_SymbolLambda)
18761
19941
  s = s.parent_scope;
18762
19942
  this.mangled_name = s.next_mangled(options, this);
19943
+ if (this.global && cache) {
19944
+ cache.set(this.name, this.mangled_name);
19945
+ }
18763
19946
  }
18764
19947
  }
18765
19948
  };
18766
19949
 
18767
19950
  AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
18768
19951
  options = defaults(options, {
18769
- screw_ie8: false
19952
+ screw_ie8: false,
19953
+ cache: null
18770
19954
  });
18771
19955
 
18772
19956
  // pass 1: setup scope chaining and handle definitions
@@ -18871,6 +20055,10 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
18871
20055
  }
18872
20056
  });
18873
20057
  self.walk(tw);
20058
+
20059
+ if (options.cache) {
20060
+ this.cname = options.cache.cname;
20061
+ }
18874
20062
  });
18875
20063
 
18876
20064
  AST_Scope.DEFMETHOD("init_scope_vars", function(nesting){
@@ -19015,11 +20203,12 @@ AST_Symbol.DEFMETHOD("global", function(){
19015
20203
 
19016
20204
  AST_Toplevel.DEFMETHOD("_default_mangler_options", function(options){
19017
20205
  return defaults(options, {
19018
- except : [],
19019
- eval : false,
19020
- sort : false,
19021
- toplevel : false,
19022
- screw_ie8 : false
20206
+ except : [],
20207
+ eval : false,
20208
+ sort : false,
20209
+ toplevel : false,
20210
+ screw_ie8 : false,
20211
+ keep_fnames : false
19023
20212
  });
19024
20213
  });
19025
20214
 
@@ -19031,6 +20220,15 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options){
19031
20220
  // the AST_SymbolDeclaration that it points to).
19032
20221
  var lname = -1;
19033
20222
  var to_mangle = [];
20223
+
20224
+ if (options.cache) {
20225
+ this.globals.each(function(symbol){
20226
+ if (options.except.indexOf(symbol.name) < 0) {
20227
+ to_mangle.push(symbol);
20228
+ }
20229
+ });
20230
+ }
20231
+
19034
20232
  var tw = new TreeWalker(function(node, descend){
19035
20233
  if (node instanceof AST_LabeledStatement) {
19036
20234
  // lname is incremented when we get to the AST_Label
@@ -19065,6 +20263,10 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options){
19065
20263
  });
19066
20264
  this.walk(tw);
19067
20265
  to_mangle.forEach(function(def){ def.mangle(options) });
20266
+
20267
+ if (options.cache) {
20268
+ options.cache.cname = this.cname;
20269
+ }
19068
20270
  });
19069
20271
 
19070
20272
  AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options){
@@ -19164,7 +20366,9 @@ var base54 = (function() {
19164
20366
  base54.freq = function(){ return frequency };
19165
20367
  function base54(num) {
19166
20368
  var ret = "", base = 54;
20369
+ num++;
19167
20370
  do {
20371
+ num--;
19168
20372
  ret += String.fromCharCode(chars[num % base]);
19169
20373
  num = Math.floor(num / base);
19170
20374
  base = 64;
@@ -19325,6 +20529,7 @@ function OutputStream(options) {
19325
20529
  preserve_line : false,
19326
20530
  screw_ie8 : false,
19327
20531
  preamble : null,
20532
+ quote_style : 0
19328
20533
  }, true);
19329
20534
 
19330
20535
  var indentation = 0;
@@ -19346,9 +20551,9 @@ function OutputStream(options) {
19346
20551
  });
19347
20552
  };
19348
20553
 
19349
- function make_string(str) {
20554
+ function make_string(str, quote) {
19350
20555
  var dq = 0, sq = 0;
19351
- str = str.replace(/[\\\b\f\n\r\t\x22\x27\u2028\u2029\0]/g, function(s){
20556
+ str = str.replace(/[\\\b\f\n\r\t\x22\x27\u2028\u2029\0\ufeff]/g, function(s){
19352
20557
  switch (s) {
19353
20558
  case "\\": return "\\\\";
19354
20559
  case "\b": return "\\b";
@@ -19360,16 +20565,31 @@ function OutputStream(options) {
19360
20565
  case '"': ++dq; return '"';
19361
20566
  case "'": ++sq; return "'";
19362
20567
  case "\0": return "\\x00";
20568
+ case "\ufeff": return "\\ufeff";
19363
20569
  }
19364
20570
  return s;
19365
20571
  });
20572
+ function quote_single() {
20573
+ return "'" + str.replace(/\x27/g, "\\'") + "'";
20574
+ }
20575
+ function quote_double() {
20576
+ return '"' + str.replace(/\x22/g, '\\"') + '"';
20577
+ }
19366
20578
  if (options.ascii_only) str = to_ascii(str);
19367
- if (dq > sq) return "'" + str.replace(/\x27/g, "\\'") + "'";
19368
- else return '"' + str.replace(/\x22/g, '\\"') + '"';
20579
+ switch (options.quote_style) {
20580
+ case 1:
20581
+ return quote_single();
20582
+ case 2:
20583
+ return quote_double();
20584
+ case 3:
20585
+ return quote == "'" ? quote_single() : quote_double();
20586
+ default:
20587
+ return dq > sq ? quote_single() : quote_double();
20588
+ }
19369
20589
  };
19370
20590
 
19371
- function encode_string(str) {
19372
- var ret = make_string(str);
20591
+ function encode_string(str, quote) {
20592
+ var ret = make_string(str, quote);
19373
20593
  if (options.inline_script)
19374
20594
  ret = ret.replace(/<\x2fscript([>\/\t\n\f\r ])/gi, "<\\/script$1");
19375
20595
  return ret;
@@ -19422,7 +20642,6 @@ function OutputStream(options) {
19422
20642
  might_need_space = false;
19423
20643
  }
19424
20644
  might_need_semicolon = false;
19425
- maybe_newline();
19426
20645
  }
19427
20646
 
19428
20647
  if (!options.beautify && options.preserve_line && stack[stack.length - 1]) {
@@ -19483,7 +20702,7 @@ function OutputStream(options) {
19483
20702
 
19484
20703
  var newline = options.beautify ? function() {
19485
20704
  print("\n");
19486
- } : noop;
20705
+ } : maybe_newline;
19487
20706
 
19488
20707
  var semicolon = options.beautify ? function() {
19489
20708
  print(";");
@@ -19585,7 +20804,7 @@ function OutputStream(options) {
19585
20804
  force_semicolon : force_semicolon,
19586
20805
  to_ascii : to_ascii,
19587
20806
  print_name : function(name) { print(make_name(name)) },
19588
- print_string : function(str) { print(encode_string(str)) },
20807
+ print_string : function(str, quote) { print(encode_string(str, quote)) },
19589
20808
  next_indent : next_indent,
19590
20809
  with_indent : with_indent,
19591
20810
  with_block : with_block,
@@ -19674,6 +20893,15 @@ function OutputStream(options) {
19674
20893
  return c(self, comment);
19675
20894
  });
19676
20895
  }
20896
+
20897
+ // Keep single line comments after nlb, after nlb
20898
+ if (!output.option("beautify") && comments.length > 0 &&
20899
+ /comment[134]/.test(comments[0].type) &&
20900
+ output.col() !== 0 && comments[0].nlb)
20901
+ {
20902
+ output.print("\n");
20903
+ }
20904
+
19677
20905
  comments.forEach(function(c){
19678
20906
  if (/comment[134]/.test(c.type)) {
19679
20907
  output.print("//" + c.value + "\n");
@@ -19811,12 +21039,6 @@ function OutputStream(options) {
19811
21039
  return true;
19812
21040
  });
19813
21041
 
19814
- PARENS(AST_NaN, function(output){
19815
- var p = output.parent();
19816
- if (p instanceof AST_PropAccess && p.expression === this)
19817
- return true;
19818
- });
19819
-
19820
21042
  PARENS([ AST_Assign, AST_Conditional ], function (output){
19821
21043
  var p = output.parent();
19822
21044
  // !(a = false) → true
@@ -19839,7 +21061,7 @@ function OutputStream(options) {
19839
21061
  /* -----[ PRINTERS ]----- */
19840
21062
 
19841
21063
  DEFPRINT(AST_Directive, function(self, output){
19842
- output.print_string(self.value);
21064
+ output.print_string(self.value, self.quote);
19843
21065
  output.semicolon();
19844
21066
  });
19845
21067
  DEFPRINT(AST_Debugger, function(self, output){
@@ -20335,6 +21557,7 @@ function OutputStream(options) {
20335
21557
  });
20336
21558
  DEFPRINT(AST_ObjectKeyVal, function(self, output){
20337
21559
  var key = self.key;
21560
+ var quote = self.quote;
20338
21561
  if (output.option("quote_keys")) {
20339
21562
  output.print_string(key + "");
20340
21563
  } else if ((typeof key == "number"
@@ -20345,7 +21568,7 @@ function OutputStream(options) {
20345
21568
  } else if (RESERVED_WORDS(key) ? output.option("screw_ie8") : is_identifier_string(key)) {
20346
21569
  output.print_name(key);
20347
21570
  } else {
20348
- output.print_string(key);
21571
+ output.print_string(key, quote);
20349
21572
  }
20350
21573
  output.colon();
20351
21574
  self.value.print(output);
@@ -20371,10 +21594,10 @@ function OutputStream(options) {
20371
21594
  });
20372
21595
  DEFPRINT(AST_Hole, noop);
20373
21596
  DEFPRINT(AST_Infinity, function(self, output){
20374
- output.print("1/0");
21597
+ output.print("Infinity");
20375
21598
  });
20376
21599
  DEFPRINT(AST_NaN, function(self, output){
20377
- output.print("0/0");
21600
+ output.print("NaN");
20378
21601
  });
20379
21602
  DEFPRINT(AST_This, function(self, output){
20380
21603
  output.print("this");
@@ -20383,7 +21606,7 @@ function OutputStream(options) {
20383
21606
  output.print(self.getValue());
20384
21607
  });
20385
21608
  DEFPRINT(AST_String, function(self, output){
20386
- output.print_string(self.getValue());
21609
+ output.print_string(self.getValue(), self.quote);
20387
21610
  });
20388
21611
  DEFPRINT(AST_Number, function(self, output){
20389
21612
  output.print(make_num(self.getValue()));
@@ -20632,6 +21855,7 @@ function Compressor(options, false_by_default) {
20632
21855
  unused : !false_by_default,
20633
21856
  hoist_funs : !false_by_default,
20634
21857
  keep_fargs : false,
21858
+ keep_fnames : false,
20635
21859
  hoist_vars : false,
20636
21860
  if_return : !false_by_default,
20637
21861
  join_vars : !false_by_default,
@@ -20732,10 +21956,10 @@ merge(Compressor.prototype, {
20732
21956
  return make_node(AST_Undefined, orig).optimize(compressor);
20733
21957
  default:
20734
21958
  if (val === null) {
20735
- return make_node(AST_Null, orig).optimize(compressor);
21959
+ return make_node(AST_Null, orig, { value: null }).optimize(compressor);
20736
21960
  }
20737
21961
  if (val instanceof RegExp) {
20738
- return make_node(AST_RegExp, orig).optimize(compressor);
21962
+ return make_node(AST_RegExp, orig, { value: val }).optimize(compressor);
20739
21963
  }
20740
21964
  throw new Error(string_template("Can't handle constant of type: {type}", {
20741
21965
  type: typeof val
@@ -20795,6 +22019,17 @@ merge(Compressor.prototype, {
20795
22019
  return statements;
20796
22020
 
20797
22021
  function process_for_angular(statements) {
22022
+ function has_inject(comment) {
22023
+ return /@ngInject/.test(comment.value);
22024
+ }
22025
+ function make_arguments_names_list(func) {
22026
+ return func.argnames.map(function(sym){
22027
+ return make_node(AST_String, sym, { value: sym.name });
22028
+ });
22029
+ }
22030
+ function make_array(orig, elements) {
22031
+ return make_node(AST_Array, orig, { elements: elements });
22032
+ }
20798
22033
  function make_injector(func, name) {
20799
22034
  return make_node(AST_SimpleStatement, func, {
20800
22035
  body: make_node(AST_Assign, func, {
@@ -20803,37 +22038,56 @@ merge(Compressor.prototype, {
20803
22038
  expression: make_node(AST_SymbolRef, name, name),
20804
22039
  property: "$inject"
20805
22040
  }),
20806
- right: make_node(AST_Array, func, {
20807
- elements: func.argnames.map(function(sym){
20808
- return make_node(AST_String, sym, { value: sym.name });
20809
- })
20810
- })
22041
+ right: make_array(func, make_arguments_names_list(func))
20811
22042
  })
20812
22043
  });
20813
22044
  }
22045
+ function check_expression(body) {
22046
+ if (body && body.args) {
22047
+ // if this is a function call check all of arguments passed
22048
+ body.args.forEach(function(argument, index, array) {
22049
+ var comments = argument.start.comments_before;
22050
+ // if the argument is function preceded by @ngInject
22051
+ if (argument instanceof AST_Lambda && comments.length && has_inject(comments[0])) {
22052
+ // replace the function with an array of names of its parameters and function at the end
22053
+ array[index] = make_array(argument, make_arguments_names_list(argument).concat(argument));
22054
+ }
22055
+ });
22056
+ // if this is chained call check previous one recursively
22057
+ if (body.expression && body.expression.expression) {
22058
+ check_expression(body.expression.expression);
22059
+ }
22060
+ }
22061
+ }
20814
22062
  return statements.reduce(function(a, stat){
20815
22063
  a.push(stat);
20816
- var token = stat.start;
20817
- var comments = token.comments_before;
20818
- if (comments && comments.length > 0) {
20819
- var last = comments.pop();
20820
- if (/@ngInject/.test(last.value)) {
20821
- // case 1: defun
20822
- if (stat instanceof AST_Defun) {
20823
- a.push(make_injector(stat, stat.name));
20824
- }
20825
- else if (stat instanceof AST_Definitions) {
20826
- stat.definitions.forEach(function(def){
20827
- if (def.value && def.value instanceof AST_Lambda) {
20828
- a.push(make_injector(def.value, def.name));
20829
- }
20830
- });
20831
- }
20832
- else {
20833
- compressor.warn("Unknown statement marked with @ngInject [{file}:{line},{col}]", token);
22064
+
22065
+ if (stat.body && stat.body.args) {
22066
+ check_expression(stat.body);
22067
+ } else {
22068
+ var token = stat.start;
22069
+ var comments = token.comments_before;
22070
+ if (comments && comments.length > 0) {
22071
+ var last = comments.pop();
22072
+ if (has_inject(last)) {
22073
+ // case 1: defun
22074
+ if (stat instanceof AST_Defun) {
22075
+ a.push(make_injector(stat, stat.name));
22076
+ }
22077
+ else if (stat instanceof AST_Definitions) {
22078
+ stat.definitions.forEach(function(def) {
22079
+ if (def.value && def.value instanceof AST_Lambda) {
22080
+ a.push(make_injector(def.value, def.name));
22081
+ }
22082
+ });
22083
+ }
22084
+ else {
22085
+ compressor.warn("Unknown statement marked with @ngInject [{file}:{line},{col}]", token);
22086
+ }
20834
22087
  }
20835
22088
  }
20836
22089
  }
22090
+
20837
22091
  return a;
20838
22092
  }, []);
20839
22093
  }
@@ -21028,7 +22282,7 @@ merge(Compressor.prototype, {
21028
22282
  seq = [];
21029
22283
  };
21030
22284
  statements.forEach(function(stat){
21031
- if (stat instanceof AST_SimpleStatement) seq.push(stat.body);
22285
+ if (stat instanceof AST_SimpleStatement && seq.length < 2000) seq.push(stat.body);
21032
22286
  else push_seq(), ret.push(stat);
21033
22287
  });
21034
22288
  push_seq();
@@ -21519,7 +22773,7 @@ merge(Compressor.prototype, {
21519
22773
  def(AST_BlockStatement, block_aborts);
21520
22774
  def(AST_SwitchBranch, block_aborts);
21521
22775
  def(AST_If, function(){
21522
- return this.alternative && aborts(this.body) && aborts(this.alternative);
22776
+ return this.alternative && aborts(this.body) && aborts(this.alternative) && this;
21523
22777
  });
21524
22778
  })(function(node, func){
21525
22779
  node.DEFMETHOD("aborts", func);
@@ -21625,7 +22879,7 @@ merge(Compressor.prototype, {
21625
22879
  var tt = new TreeTransformer(
21626
22880
  function before(node, descend, in_list) {
21627
22881
  if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
21628
- if (!compressor.option("keep_fargs")) {
22882
+ if (compressor.option("unsafe") && !compressor.option("keep_fargs")) {
21629
22883
  for (var a = node.argnames, i = a.length; --i >= 0;) {
21630
22884
  var sym = a[i];
21631
22885
  if (sym.unreferenced()) {
@@ -21707,12 +22961,12 @@ merge(Compressor.prototype, {
21707
22961
  return make_node(AST_EmptyStatement, node);
21708
22962
  }
21709
22963
  if (def.length == 0) {
21710
- return side_effects;
22964
+ return in_list ? MAP.splice(side_effects.body) : side_effects;
21711
22965
  }
21712
22966
  node.definitions = def;
21713
22967
  if (side_effects) {
21714
22968
  side_effects.body.unshift(node);
21715
- node = side_effects;
22969
+ return in_list ? MAP.splice(side_effects.body) : side_effects;
21716
22970
  }
21717
22971
  return node;
21718
22972
  }
@@ -22236,7 +23490,7 @@ merge(Compressor.prototype, {
22236
23490
 
22237
23491
  OPT(AST_Function, function(self, compressor){
22238
23492
  self = AST_Lambda.prototype.optimize.call(self, compressor);
22239
- if (compressor.option("unused")) {
23493
+ if (compressor.option("unused") && !compressor.option("keep_fnames")) {
22240
23494
  if (self.name && self.name.unreferenced()) {
22241
23495
  self.name = null;
22242
23496
  }
@@ -22292,6 +23546,11 @@ merge(Compressor.prototype, {
22292
23546
  }).transform(compressor);
22293
23547
  break;
22294
23548
  case "Function":
23549
+ // new Function() => function(){}
23550
+ if (self.args.length == 0) return make_node(AST_Function, self, {
23551
+ argnames: [],
23552
+ body: []
23553
+ });
22295
23554
  if (all(self.args, function(x){ return x instanceof AST_String })) {
22296
23555
  // quite a corner-case, but we can handle it:
22297
23556
  // https://github.com/mishoo/UglifyJS2/issues/203
@@ -22407,11 +23666,16 @@ merge(Compressor.prototype, {
22407
23666
  }
22408
23667
  }
22409
23668
  if (compressor.option("drop_console")) {
22410
- if (self.expression instanceof AST_PropAccess &&
22411
- self.expression.expression instanceof AST_SymbolRef &&
22412
- self.expression.expression.name == "console" &&
22413
- self.expression.expression.undeclared()) {
22414
- return make_node(AST_Undefined, self).transform(compressor);
23669
+ if (self.expression instanceof AST_PropAccess) {
23670
+ var name = self.expression.expression;
23671
+ while (name.expression) {
23672
+ name = name.expression;
23673
+ }
23674
+ if (name instanceof AST_SymbolRef
23675
+ && name.name == "console"
23676
+ && name.undeclared()) {
23677
+ return make_node(AST_Undefined, self).transform(compressor);
23678
+ }
22415
23679
  }
22416
23680
  }
22417
23681
  return self.evaluate(compressor)[0];
@@ -22471,7 +23735,7 @@ merge(Compressor.prototype, {
22471
23735
  if (self.cdr instanceof AST_UnaryPrefix
22472
23736
  && self.cdr.operator == "void"
22473
23737
  && !self.cdr.expression.has_side_effects(compressor)) {
22474
- self.cdr.operator = self.car;
23738
+ self.cdr.expression = self.car;
22475
23739
  return self.cdr;
22476
23740
  }
22477
23741
  if (self.cdr instanceof AST_Undefined) {
@@ -22639,6 +23903,12 @@ merge(Compressor.prototype, {
22639
23903
  var rr = self.right.evaluate(compressor);
22640
23904
  if ((ll.length > 1 && !ll[1]) || (rr.length > 1 && !rr[1])) {
22641
23905
  compressor.warn("Boolean && always false [{file}:{line},{col}]", self.start);
23906
+ if (self.left.has_side_effects(compressor)) {
23907
+ return make_node(AST_Seq, self, {
23908
+ car: self.left,
23909
+ cdr: make_node(AST_False)
23910
+ }).optimize(compressor);
23911
+ }
22642
23912
  return make_node(AST_False, self);
22643
23913
  }
22644
23914
  if (ll.length > 1 && ll[1]) {
@@ -22653,6 +23923,12 @@ merge(Compressor.prototype, {
22653
23923
  var rr = self.right.evaluate(compressor);
22654
23924
  if ((ll.length > 1 && ll[1]) || (rr.length > 1 && rr[1])) {
22655
23925
  compressor.warn("Boolean || always true [{file}:{line},{col}]", self.start);
23926
+ if (self.left.has_side_effects(compressor)) {
23927
+ return make_node(AST_Seq, self, {
23928
+ car: self.left,
23929
+ cdr: make_node(AST_True)
23930
+ }).optimize(compressor);
23931
+ }
22656
23932
  return make_node(AST_True, self);
22657
23933
  }
22658
23934
  if (ll.length > 1 && !ll[1]) {
@@ -22773,14 +24049,22 @@ merge(Compressor.prototype, {
22773
24049
  case "undefined":
22774
24050
  return make_node(AST_Undefined, self);
22775
24051
  case "NaN":
22776
- return make_node(AST_NaN, self);
24052
+ return make_node(AST_NaN, self).transform(compressor);
22777
24053
  case "Infinity":
22778
- return make_node(AST_Infinity, self);
24054
+ return make_node(AST_Infinity, self).transform(compressor);
22779
24055
  }
22780
24056
  }
22781
24057
  return self;
22782
24058
  });
22783
24059
 
24060
+ OPT(AST_Infinity, function (self, compressor) {
24061
+ return make_node(AST_Binary, self, {
24062
+ operator : '/',
24063
+ left : make_node(AST_Number, self, {value: 1}),
24064
+ right : make_node(AST_Number, self, {value: 0})
24065
+ });
24066
+ });
24067
+
22784
24068
  OPT(AST_Undefined, function(self, compressor){
22785
24069
  if (compressor.option("unsafe")) {
22786
24070
  var scope = compressor.find_parent(AST_Scope);
@@ -22844,6 +24128,7 @@ merge(Compressor.prototype, {
22844
24128
  && alternative instanceof AST_Assign
22845
24129
  && consequent.operator == alternative.operator
22846
24130
  && consequent.left.equivalent_to(alternative.left)
24131
+ && !consequent.left.has_side_effects(compressor)
22847
24132
  ) {
22848
24133
  /*
22849
24134
  * Stuff like this:
@@ -22864,6 +24149,7 @@ merge(Compressor.prototype, {
22864
24149
  if (consequent instanceof AST_Call
22865
24150
  && alternative.TYPE === consequent.TYPE
22866
24151
  && consequent.args.length == alternative.args.length
24152
+ && !consequent.expression.has_side_effects(compressor)
22867
24153
  && consequent.expression.equivalent_to(alternative.expression)) {
22868
24154
  if (consequent.args.length == 0) {
22869
24155
  return make_node(AST_Seq, self, {
@@ -22904,6 +24190,20 @@ merge(Compressor.prototype, {
22904
24190
 
22905
24191
  }
22906
24192
  }
24193
+ // x=y?true:false --> x=!!y
24194
+ if (consequent instanceof AST_True
24195
+ && alternative instanceof AST_False) {
24196
+ self.condition = self.condition.negate(compressor);
24197
+ return make_node(AST_UnaryPrefix, self.condition, {
24198
+ operator: "!",
24199
+ expression: self.condition
24200
+ });
24201
+ }
24202
+ // x=y?false:true --> x=!y
24203
+ if (consequent instanceof AST_False
24204
+ && alternative instanceof AST_True) {
24205
+ return self.condition.negate(compressor)
24206
+ }
22907
24207
  return self;
22908
24208
  });
22909
24209
 
@@ -22967,7 +24267,7 @@ merge(Compressor.prototype, {
22967
24267
  });
22968
24268
 
22969
24269
  function literals_in_boolean_context(self, compressor) {
22970
- if (compressor.option("booleans") && compressor.in_boolean_context()) {
24270
+ if (compressor.option("booleans") && compressor.in_boolean_context() && !self.has_side_effects(compressor)) {
22971
24271
  return make_node(AST_True, self);
22972
24272
  }
22973
24273
  return self;
@@ -23033,11 +24333,16 @@ function SourceMap(options) {
23033
24333
  orig_line_diff : 0,
23034
24334
  dest_line_diff : 0,
23035
24335
  });
23036
- var generator = new MOZ_SourceMap.SourceMapGenerator({
23037
- file : options.file,
23038
- sourceRoot : options.root
23039
- });
23040
24336
  var orig_map = options.orig && new MOZ_SourceMap.SourceMapConsumer(options.orig);
24337
+ var generator;
24338
+ if (orig_map) {
24339
+ generator = MOZ_SourceMap.SourceMapGenerator.fromSourceMap(orig_map);
24340
+ } else {
24341
+ generator = new MOZ_SourceMap.SourceMapGenerator({
24342
+ file : options.file,
24343
+ sourceRoot : options.root
24344
+ });
24345
+ }
23041
24346
  function add(source, gen_line, gen_col, orig_line, orig_col, name) {
23042
24347
  if (orig_map) {
23043
24348
  var info = orig_map.originalPositionFor({
@@ -23058,11 +24363,11 @@ function SourceMap(options) {
23058
24363
  source : source,
23059
24364
  name : name
23060
24365
  });
23061
- };
24366
+ }
23062
24367
  return {
23063
24368
  add : add,
23064
24369
  get : function() { return generator },
23065
- toString : function() { return generator.toString() }
24370
+ toString : function() { return JSON.stringify(generator.toJSON()); }
23066
24371
  };
23067
24372
  };
23068
24373
 
@@ -23438,26 +24743,30 @@ function SourceMap(options) {
23438
24743
  /* -----[ tools ]----- */
23439
24744
 
23440
24745
  function my_start_token(moznode) {
23441
- var loc = moznode.loc;
24746
+ var loc = moznode.loc, start = loc && loc.start;
23442
24747
  var range = moznode.range;
23443
24748
  return new AST_Token({
23444
- file : loc && loc.source,
23445
- line : loc && loc.start.line,
23446
- col : loc && loc.start.column,
23447
- pos : range ? range[0] : moznode.start,
23448
- endpos : range ? range[0] : moznode.start
24749
+ file : loc && loc.source,
24750
+ line : start && start.line,
24751
+ col : start && start.column,
24752
+ pos : range ? range[0] : moznode.start,
24753
+ endline : start && start.line,
24754
+ endcol : start && start.column,
24755
+ endpos : range ? range[0] : moznode.start
23449
24756
  });
23450
24757
  };
23451
24758
 
23452
24759
  function my_end_token(moznode) {
23453
- var loc = moznode.loc;
24760
+ var loc = moznode.loc, end = loc && loc.end;
23454
24761
  var range = moznode.range;
23455
24762
  return new AST_Token({
23456
- file : loc && loc.source,
23457
- line : loc && loc.end.line,
23458
- col : loc && loc.end.column,
23459
- pos : range ? range[1] : moznode.end,
23460
- endpos : range ? range[1] : moznode.end
24763
+ file : loc && loc.source,
24764
+ line : end && end.line,
24765
+ col : end && end.column,
24766
+ pos : range ? range[1] : moznode.end,
24767
+ endline : end && end.line,
24768
+ endcol : end && end.column,
24769
+ endpos : range ? range[1] : moznode.end
23461
24770
  });
23462
24771
  };
23463
24772
 
@@ -23533,23 +24842,16 @@ function SourceMap(options) {
23533
24842
  return ast;
23534
24843
  };
23535
24844
 
23536
- function moz_sub_loc(token) {
23537
- return token.line ? {
23538
- line: token.line,
23539
- column: token.col
23540
- } : null;
23541
- };
23542
-
23543
- function set_moz_loc(mynode, moznode) {
24845
+ function set_moz_loc(mynode, moznode, myparent) {
23544
24846
  var start = mynode.start;
23545
24847
  var end = mynode.end;
23546
- if (start.pos != null && end.pos != null) {
23547
- moznode.range = [start.pos, end.pos];
24848
+ if (start.pos != null && end.endpos != null) {
24849
+ moznode.range = [start.pos, end.endpos];
23548
24850
  }
23549
24851
  if (start.line) {
23550
24852
  moznode.loc = {
23551
- start: moz_sub_loc(start),
23552
- end: moz_sub_loc(end)
24853
+ start: {line: start.line, column: start.col},
24854
+ end: end.endline ? {line: end.endline, column: end.endcol} : null
23553
24855
  };
23554
24856
  if (start.file) {
23555
24857
  moznode.loc.source = start.file;
@@ -23577,6 +24879,224 @@ function SourceMap(options) {
23577
24879
 
23578
24880
  })();
23579
24881
 
24882
+ /***********************************************************************
24883
+
24884
+ A JavaScript tokenizer / parser / beautifier / compressor.
24885
+ https://github.com/mishoo/UglifyJS2
24886
+
24887
+ -------------------------------- (C) ---------------------------------
24888
+
24889
+ Author: Mihai Bazon
24890
+ <mihai.bazon@gmail.com>
24891
+ http://mihai.bazon.net/blog
24892
+
24893
+ Distributed under the BSD license:
24894
+
24895
+ Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
24896
+
24897
+ Redistribution and use in source and binary forms, with or without
24898
+ modification, are permitted provided that the following conditions
24899
+ are met:
24900
+
24901
+ * Redistributions of source code must retain the above
24902
+ copyright notice, this list of conditions and the following
24903
+ disclaimer.
24904
+
24905
+ * Redistributions in binary form must reproduce the above
24906
+ copyright notice, this list of conditions and the following
24907
+ disclaimer in the documentation and/or other materials
24908
+ provided with the distribution.
24909
+
24910
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
24911
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24912
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24913
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
24914
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24915
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24916
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24917
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24918
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
24919
+ TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
24920
+ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24921
+ SUCH DAMAGE.
24922
+
24923
+ ***********************************************************************/
24924
+
24925
+ "use strict";
24926
+
24927
+ function find_builtins() {
24928
+ var a = [];
24929
+ [ Object, Array, Function, Number,
24930
+ String, Boolean, Error, Math,
24931
+ Date, RegExp
24932
+ ].forEach(function(ctor){
24933
+ Object.getOwnPropertyNames(ctor).map(add);
24934
+ if (ctor.prototype) {
24935
+ Object.getOwnPropertyNames(ctor.prototype).map(add);
24936
+ }
24937
+ });
24938
+ function add(name) {
24939
+ push_uniq(a, name);
24940
+ }
24941
+ return a;
24942
+ }
24943
+
24944
+ function mangle_properties(ast, options) {
24945
+ options = defaults(options, {
24946
+ reserved : null,
24947
+ cache : null,
24948
+ only_cache : false
24949
+ });
24950
+
24951
+ var reserved = options.reserved;
24952
+ if (reserved == null)
24953
+ reserved = find_builtins();
24954
+
24955
+ var cache = options.cache;
24956
+ if (cache == null) {
24957
+ cache = {
24958
+ cname: -1,
24959
+ props: new Dictionary()
24960
+ };
24961
+ }
24962
+
24963
+ var names_to_mangle = [];
24964
+
24965
+ // step 1: find candidates to mangle
24966
+ ast.walk(new TreeWalker(function(node){
24967
+ if (node instanceof AST_ObjectKeyVal) {
24968
+ add(node.key);
24969
+ }
24970
+ else if (node instanceof AST_ObjectProperty) {
24971
+ // setter or getter, since KeyVal is handled above
24972
+ add(node.key.name);
24973
+ }
24974
+ else if (node instanceof AST_Dot) {
24975
+ if (this.parent() instanceof AST_Assign) {
24976
+ add(node.property);
24977
+ }
24978
+ }
24979
+ else if (node instanceof AST_Sub) {
24980
+ if (this.parent() instanceof AST_Assign) {
24981
+ addStrings(node.property);
24982
+ }
24983
+ }
24984
+ }));
24985
+
24986
+ // step 2: transform the tree, renaming properties
24987
+ return ast.transform(new TreeTransformer(function(node){
24988
+ if (node instanceof AST_ObjectKeyVal) {
24989
+ if (should_mangle(node.key)) {
24990
+ node.key = mangle(node.key);
24991
+ }
24992
+ }
24993
+ else if (node instanceof AST_ObjectProperty) {
24994
+ // setter or getter
24995
+ if (should_mangle(node.key.name)) {
24996
+ node.key.name = mangle(node.key.name);
24997
+ }
24998
+ }
24999
+ else if (node instanceof AST_Dot) {
25000
+ if (should_mangle(node.property)) {
25001
+ node.property = mangle(node.property);
25002
+ }
25003
+ }
25004
+ else if (node instanceof AST_Sub) {
25005
+ node.property = mangleStrings(node.property);
25006
+ }
25007
+ // else if (node instanceof AST_String) {
25008
+ // if (should_mangle(node.value)) {
25009
+ // AST_Node.warn(
25010
+ // "Found \"{prop}\" property candidate for mangling in an arbitrary string [{file}:{line},{col}]", {
25011
+ // file : node.start.file,
25012
+ // line : node.start.line,
25013
+ // col : node.start.col,
25014
+ // prop : node.value
25015
+ // }
25016
+ // );
25017
+ // }
25018
+ // }
25019
+ }));
25020
+
25021
+ // only function declarations after this line
25022
+
25023
+ function can_mangle(name) {
25024
+ if (reserved.indexOf(name) >= 0) return false;
25025
+ if (options.only_cache) {
25026
+ return cache.props.has(name);
25027
+ }
25028
+ if (/^[0-9.]+$/.test(name)) return false;
25029
+ return true;
25030
+ }
25031
+
25032
+ function should_mangle(name) {
25033
+ if (reserved.indexOf(name) >= 0) return false;
25034
+ return cache.props.has(name)
25035
+ || names_to_mangle.indexOf(name) >= 0;
25036
+ }
25037
+
25038
+ function add(name) {
25039
+ if (can_mangle(name))
25040
+ push_uniq(names_to_mangle, name);
25041
+ }
25042
+
25043
+ function mangle(name) {
25044
+ var mangled = cache.props.get(name);
25045
+ if (!mangled) {
25046
+ do {
25047
+ mangled = base54(++cache.cname);
25048
+ } while (!can_mangle(mangled));
25049
+ cache.props.set(name, mangled);
25050
+ }
25051
+ return mangled;
25052
+ }
25053
+
25054
+ function addStrings(node) {
25055
+ var out = {};
25056
+ try {
25057
+ (function walk(node){
25058
+ node.walk(new TreeWalker(function(node){
25059
+ if (node instanceof AST_Seq) {
25060
+ walk(node.cdr);
25061
+ return true;
25062
+ }
25063
+ if (node instanceof AST_String) {
25064
+ add(node.value);
25065
+ return true;
25066
+ }
25067
+ if (node instanceof AST_Conditional) {
25068
+ walk(node.consequent);
25069
+ walk(node.alternative);
25070
+ return true;
25071
+ }
25072
+ throw out;
25073
+ }));
25074
+ })(node);
25075
+ } catch(ex) {
25076
+ if (ex !== out) throw ex;
25077
+ }
25078
+ }
25079
+
25080
+ function mangleStrings(node) {
25081
+ return node.transform(new TreeTransformer(function(node){
25082
+ if (node instanceof AST_Seq) {
25083
+ node.cdr = mangleStrings(node.cdr);
25084
+ }
25085
+ else if (node instanceof AST_String) {
25086
+ if (should_mangle(node.value)) {
25087
+ node.value = mangle(node.value);
25088
+ }
25089
+ }
25090
+ else if (node instanceof AST_Conditional) {
25091
+ node.consequent = mangleStrings(node.consequent);
25092
+ node.alternative = mangleStrings(node.alternative);
25093
+ }
25094
+ return node;
25095
+ }));
25096
+ }
25097
+
25098
+ }
25099
+
23580
25100
  AST_Node.warn_function = function(txt) { logger.error("uglifyjs2 WARN: " + txt); };
23581
25101
  exports.minify = function(files, options, name) {
23582
25102
  options = defaults(options, {
@@ -23624,8 +25144,8 @@ exports.minify = function(files, options, name) {
23624
25144
 
23625
25145
  // 3. mangle
23626
25146
  if (options.mangle) {
23627
- toplevel.figure_out_scope();
23628
- toplevel.compute_char_frequency();
25147
+ toplevel.figure_out_scope(options.mangle);
25148
+ toplevel.compute_char_frequency(options.mangle);
23629
25149
  toplevel.mangle_names(options.mangle);
23630
25150
  }
23631
25151
 
@@ -23660,9 +25180,14 @@ exports.minify = function(files, options, name) {
23660
25180
  stream += "\n//# sourceMappingURL=" + options.outSourceMap;
23661
25181
  }
23662
25182
 
25183
+ var source_map = output.source_map;
25184
+ if (source_map) {
25185
+ source_map = source_map + "";
25186
+ }
25187
+
23663
25188
  return {
23664
25189
  code : stream + "",
23665
- map : output.source_map + ""
25190
+ map : source_map
23666
25191
  };
23667
25192
  };
23668
25193
 
@@ -23715,7 +25240,6 @@ exports.describe_ast = function() {
23715
25240
  return out + "";
23716
25241
  };
23717
25242
 
23718
-
23719
25243
  });
23720
25244
  /**
23721
25245
  * @license Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
@@ -24026,18 +25550,56 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
24026
25550
  * @returns {Boolean}
24027
25551
  */
24028
25552
  parse.definesRequire = function (fileName, fileContents) {
24029
- var found = false;
25553
+ var foundDefine = false,
25554
+ foundDefineAmd = false;
24030
25555
 
24031
25556
  traverse(esprima.parse(fileContents), function (node) {
24032
- if (parse.hasDefineAmd(node)) {
24033
- found = true;
25557
+ // Look for a top level declaration of a define, like
25558
+ // var requirejs, require, define, off Program body.
25559
+ if (node.type === 'Program' && node.body && node.body.length) {
25560
+ foundDefine = node.body.some(function(bodyNode) {
25561
+ // var define
25562
+ if (bodyNode.type === 'VariableDeclaration') {
25563
+ var decls = bodyNode.declarations;
25564
+ if (decls) {
25565
+ var hasVarDefine = decls.some(function(declNode) {
25566
+ return (declNode.type === 'VariableDeclarator' &&
25567
+ declNode.id &&
25568
+ declNode.id.type === 'Identifier' &&
25569
+ declNode.id.name === 'define');
25570
+ });
25571
+ if (hasVarDefine) {
25572
+ return true;
25573
+ }
25574
+ }
25575
+ }
25576
+
25577
+ // function define() {}
25578
+ if (bodyNode.type === 'FunctionDeclaration' &&
25579
+ bodyNode.id &&
25580
+ bodyNode.id.type === 'Identifier' &&
25581
+ bodyNode.id.name === 'define') {
25582
+ return true;
25583
+ }
25584
+
25585
+
25586
+
25587
+
25588
+
25589
+
25590
+ });
25591
+ }
25592
+
25593
+ // Need define variable found first, before detecting define.amd.
25594
+ if (foundDefine && parse.hasDefineAmd(node)) {
25595
+ foundDefineAmd = true;
24034
25596
 
24035
25597
  //Stop traversal
24036
25598
  return false;
24037
25599
  }
24038
25600
  });
24039
25601
 
24040
- return found;
25602
+ return foundDefine && foundDefineAmd;
24041
25603
  };
24042
25604
 
24043
25605
  /**
@@ -24542,9 +26104,17 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
24542
26104
  } else if (deps.type === 'ObjectExpression') {
24543
26105
  //deps is object literal, null out
24544
26106
  deps = factory = null;
24545
- } else if (deps.type === 'Identifier' && args.length === 2) {
24546
- // define('id', factory)
24547
- deps = factory = null;
26107
+ } else if (deps.type === 'Identifier') {
26108
+ if (args.length === 2) {
26109
+ //define('id', factory)
26110
+ deps = factory = null;
26111
+ } else if (args.length === 3 && isFnExpression(factory)) {
26112
+ //define('id', depsIdentifier, factory)
26113
+ //Since identifier, cannot know the deps, but do not
26114
+ //error out, assume they are taken care of outside of
26115
+ //static parsing.
26116
+ deps = null;
26117
+ }
24548
26118
  }
24549
26119
  }
24550
26120
 
@@ -25196,7 +26766,7 @@ define('pragma', ['parse', 'logger'], function (parse, logger) {
25196
26766
  configRegExp: /(^|[^\.])(requirejs|require)(\.config)\s*\(/g,
25197
26767
  nsWrapRegExp: /\/\*requirejs namespace: true \*\//,
25198
26768
  apiDefRegExp: /var requirejs,\s*require,\s*define;/,
25199
- defineCheckRegExp: /typeof\s+define\s*===?\s*["']function["']\s*&&\s*define\s*\.\s*amd/g,
26769
+ defineCheckRegExp: /typeof(\s+|\s*\(\s*)define(\s*\))?\s*===?\s*["']function["']\s*&&\s*define\s*\.\s*amd/g,
25200
26770
  defineStringCheckRegExp: /typeof\s+define\s*===?\s*["']function["']\s*&&\s*define\s*\[\s*["']amd["']\s*\]/g,
25201
26771
  defineTypeFirstCheckRegExp: /\s*["']function["']\s*==(=?)\s*typeof\s+define\s*&&\s*define\s*\.\s*amd/g,
25202
26772
  defineJQueryRegExp: /typeof\s+define\s*===?\s*["']function["']\s*&&\s*define\s*\.\s*amd\s*&&\s*define\s*\.\s*amd\s*\.\s*jQuery/g,
@@ -25505,7 +27075,13 @@ define('rhino/optimize', ['logger', 'env!env/file'], function (logger, file) {
25505
27075
  try {
25506
27076
  // Try for newer closure compiler that needs Java 7+
25507
27077
  JSSourceFilefromCode = java.lang.Class.forName('com.google.javascript.jscomp.SourceFile').getMethod('fromCode', [java.lang.String, java.lang.String]);
25508
- } catch (e) {}
27078
+ } catch (e) {
27079
+ try {
27080
+ // Try Nashorn style
27081
+ var stringClass = Java.type("java.lang.String").class;
27082
+ JSSourceFilefromCode = Java.type("com.google.javascript.jscomp.SourceFile").class.getMethod("fromCode", [stringClass, stringClass]);
27083
+ } catch (e) {}
27084
+ }
25509
27085
  }
25510
27086
 
25511
27087
  //Helper for closure compiler, because of weird Java-JavaScript interactions.
@@ -26092,7 +27668,7 @@ function (lang, logger, envOptimize, file, parse,
26092
27668
  uconfig.fromString = true;
26093
27669
 
26094
27670
  if (config.generateSourceMaps && (outFileName || config._buildSourceMap)) {
26095
- uconfig.outSourceMap = baseName;
27671
+ uconfig.outSourceMap = baseName + '.map';
26096
27672
 
26097
27673
  if (config._buildSourceMap) {
26098
27674
  existingMap = JSON.parse(config._buildSourceMap);
@@ -26110,12 +27686,7 @@ function (lang, logger, envOptimize, file, parse,
26110
27686
  result = uglify2.minify(fileContents, uconfig, baseName + '.src.js');
26111
27687
  if (uconfig.outSourceMap && result.map) {
26112
27688
  resultMap = result.map;
26113
- if (existingMap) {
26114
- resultMap = JSON.parse(resultMap);
26115
- finalMap = SourceMapGenerator.fromSourceMap(new SourceMapConsumer(resultMap));
26116
- finalMap.applySourceMap(new SourceMapConsumer(existingMap));
26117
- resultMap = finalMap.toString();
26118
- } else if (!config._buildSourceMap) {
27689
+ if (!existingMap && !config._buildSourceMap) {
26119
27690
  file.saveFile(outFileName + '.src.js', fileContents);
26120
27691
  }
26121
27692
 
@@ -26125,7 +27696,6 @@ function (lang, logger, envOptimize, file, parse,
26125
27696
  config._buildSourceMap = resultMap;
26126
27697
  } else {
26127
27698
  file.saveFile(outFileName + '.map', resultMap);
26128
- fileContents += "\n//# sourceMappingURL=" + baseName + ".map";
26129
27699
  }
26130
27700
  } else {
26131
27701
  fileContents = result.code;
@@ -27121,7 +28691,8 @@ define('build', function (require) {
27121
28691
  //would result in modifying source. This condition can happen
27122
28692
  //with some more tricky paths: config and appDir/baseUrl
27123
28693
  //setting, which is a sign of incorrect config.
27124
- if (module._buildPath === module._sourcePath) {
28694
+ if (module._buildPath === module._sourcePath &&
28695
+ !config.allowSourceOverwrites) {
27125
28696
  throw new Error('Module ID \'' + module.name +
27126
28697
  '\' has a source path that is same as output path: ' +
27127
28698
  module._sourcePath +
@@ -28285,7 +29856,7 @@ define('build', function (require) {
28285
29856
  var hasError = false;
28286
29857
  if (syncChecks[env.get()]) {
28287
29858
  try {
28288
- build.checkForErrors(context);
29859
+ build.checkForErrors(context, layer);
28289
29860
  } catch (e) {
28290
29861
  hasError = true;
28291
29862
  deferred.reject(e);
@@ -28305,7 +29876,7 @@ define('build', function (require) {
28305
29876
  // issue, the require never completes, need to check for errors
28306
29877
  // here.
28307
29878
  if (syncChecks[env.get()]) {
28308
- build.checkForErrors(context);
29879
+ build.checkForErrors(context, layer);
28309
29880
  }
28310
29881
 
28311
29882
  return deferred.promise.then(function () {
@@ -28314,13 +29885,13 @@ define('build', function (require) {
28314
29885
  require(lang.deeplikeCopy(baseLoaderConfig));
28315
29886
  }
28316
29887
 
28317
- build.checkForErrors(context);
29888
+ build.checkForErrors(context, layer);
28318
29889
 
28319
29890
  return layer;
28320
29891
  });
28321
29892
  };
28322
29893
 
28323
- build.checkForErrors = function (context) {
29894
+ build.checkForErrors = function (context, layer) {
28324
29895
  //Check to see if it all loaded. If not, then throw, and give
28325
29896
  //a message on what is left.
28326
29897
  var id, prop, mod, idParts, pluginId, pluginResources,
@@ -28372,8 +29943,9 @@ define('build', function (require) {
28372
29943
  }
28373
29944
 
28374
29945
  //Look for plugins that did not call load()
28375
-
28376
- if (idParts.length > 1) {
29946
+ //But skip plugin IDs that were already inlined and called
29947
+ //define() with a name.
29948
+ if (!hasProp(layer.modulesWithNames, id) && idParts.length > 1) {
28377
29949
  if (falseProp(failedPluginMap, pluginId)) {
28378
29950
  failedPluginIds.push(pluginId);
28379
29951
  }
@@ -28504,9 +30076,13 @@ define('build', function (require) {
28504
30076
 
28505
30077
  if (config.generateSourceMaps) {
28506
30078
  sourceMapBase = config.dir || config.baseUrl;
28507
- fileForSourceMap = module._buildPath === 'FUNCTION' ?
28508
- (module.name || module.include[0] || 'FUNCTION') + '.build.js' :
28509
- module._buildPath.replace(sourceMapBase, '');
30079
+ if (module._buildPath === 'FUNCTION') {
30080
+ fileForSourceMap = (module.name || module.include[0] || 'FUNCTION') + '.build.js';
30081
+ } else if (config.out) {
30082
+ fileForSourceMap = module._buildPath.split('/').pop();
30083
+ } else {
30084
+ fileForSourceMap = module._buildPath.replace(sourceMapBase, '');
30085
+ }
28510
30086
  sourceMapGenerator = new SourceMapGenerator.SourceMapGenerator({
28511
30087
  file: fileForSourceMap
28512
30088
  });
@@ -28621,7 +30197,7 @@ define('build', function (require) {
28621
30197
  });
28622
30198
  }
28623
30199
  }).then(function () {
28624
- var refPath, pluginId, resourcePath,
30200
+ var refPath, pluginId, resourcePath, shimDeps,
28625
30201
  sourceMapPath, sourceMapLineNumber,
28626
30202
  shortPath = path.replace(config.dir, "");
28627
30203
 
@@ -28635,11 +30211,13 @@ define('build', function (require) {
28635
30211
  if (moduleName && falseProp(layer.modulesWithNames, moduleName) && !config.skipModuleInsertion) {
28636
30212
  shim = config.shim && (getOwn(config.shim, moduleName) || (packageName && getOwn(config.shim, packageName)));
28637
30213
  if (shim) {
30214
+ shimDeps = lang.isArray(shim) ? shim : shim.deps;
28638
30215
  if (config.wrapShim) {
30216
+
28639
30217
  singleContents = '(function(root) {\n' +
28640
30218
  namespaceWithDot + 'define("' + moduleName + '", ' +
28641
- (shim.deps && shim.deps.length ?
28642
- build.makeJsArrayString(shim.deps) + ', ' : '[], ') +
30219
+ (shimDeps && shimDeps.length ?
30220
+ build.makeJsArrayString(shimDeps) + ', ' : '[], ') +
28643
30221
  'function() {\n' +
28644
30222
  ' return (function() {\n' +
28645
30223
  singleContents +
@@ -28652,8 +30230,8 @@ define('build', function (require) {
28652
30230
  '}(this));\n';
28653
30231
  } else {
28654
30232
  singleContents += '\n' + namespaceWithDot + 'define("' + moduleName + '", ' +
28655
- (shim.deps && shim.deps.length ?
28656
- build.makeJsArrayString(shim.deps) + ', ' : '') +
30233
+ (shimDeps && shimDeps.length ?
30234
+ build.makeJsArrayString(shimDeps) + ', ' : '') +
28657
30235
  (shim.exportsFn ? shim.exportsFn() : 'function(){}') +
28658
30236
  ');\n';
28659
30237
  }
@@ -28960,7 +30538,7 @@ function (args, quit, logger, build) {
28960
30538
  } else if (commandOption === 'v') {
28961
30539
  console.log('r.js: ' + version +
28962
30540
  ', RequireJS: ' + this.requirejsVars.require.version +
28963
- ', UglifyJS2: 2.4.16, UglifyJS: 1.3.4');
30541
+ ', UglifyJS2: 2.4.23, UglifyJS: 1.3.4');
28964
30542
  } else if (commandOption === 'convert') {
28965
30543
  loadLib();
28966
30544