]> code.delx.au - gnu-emacs-elpa/commitdiff
Adapt async/await changes to latest master
authorCarl Lei <xecycle@gmail.com>
Thu, 5 Nov 2015 01:56:43 +0000 (09:56 +0800)
committerCarl Lei <xecycle@gmail.com>
Thu, 5 Nov 2015 01:56:43 +0000 (09:56 +0800)
Resolved conflicts:
- fix call signatures to js2-parse-function
- fix js2-AWAIT number
- adapt to rename of getter-setter-node to method-node

1  2 
js2-mode.el
tests/parser.el

diff --cc js2-mode.el
index 35660719f97339f19a7b16fb032577eca1f7a513,87de5505d07551d560ebc254f58a9fd92b7fae7a..1f1121883d51e65a11adcf64680095cf1e796a30
@@@ -612,12 -650,15 +612,14 @@@ which doesn't seem particularly useful
  (defvar js2-ARROW 162)         ; function arrow (=>)
  (defvar js2-CLASS 163)
  (defvar js2-EXTENDS 164)
 -(defvar js2-STATIC 165)
 -(defvar js2-SUPER 166)
 -(defvar js2-TEMPLATE_HEAD 167)    ; part of template literal before substitution
 -(defvar js2-NO_SUBS_TEMPLATE 168) ; template literal without substitutions
 -(defvar js2-TAGGED_TEMPLATE 169)  ; tagged template literal
 +(defvar js2-SUPER 165)
 +(defvar js2-TEMPLATE_HEAD 166)    ; part of template literal before substitution
 +(defvar js2-NO_SUBS_TEMPLATE 167) ; template literal without substitutions
 +(defvar js2-TAGGED_TEMPLATE 168)  ; tagged template literal
  
- (defconst js2-num-tokens (1+ js2-TAGGED_TEMPLATE))
 -(defvar js2-AWAIT 170)  ; await (pseudo keyword)
++(defvar js2-AWAIT 169)  ; await (pseudo keyword)
+ (defconst js2-num-tokens (1+ js2-AWAIT))
  
  (defconst js2-debug-print-trees nil)
  
@@@ -3293,8 -3314,12 +3300,10 @@@ The `params' field is a Lisp list of no
           (rest-p (js2-function-node-rest-p n))
           (body (js2-function-node-body n))
           (expr (not (eq (js2-function-node-form n) 'FUNCTION_STATEMENT))))
-     (unless (or method arrow)
-       (insert pad "function")
 -    (unless getter
 -      (insert pad))
 -    (when (js2-function-node-async n)
 -      (insert "async "))
 -    (unless (or getter arrow)
 -      (insert "function")
++    (unless method
++      (insert pad)
++      (when (js2-function-node-async n) (insert "async "))
++      (unless arrow (insert "function"))
        (when (eq (js2-function-node-generator-type n) 'STAR)
          (insert "*")))
      (when name
@@@ -8171,9 -7978,12 +8218,9 @@@ Last token scanned is the close-curly f
      (when (js2-match-token js2-NAME)
        (setq name (js2-create-name-node t)))
      (js2-must-match js2-LP "msg.no.paren.parms")
-     (js2-parse-function 'FUNCTION_EXPRESSION pos star-p name)))
+     (js2-parse-function 'FUNCTION_EXPRESSION pos star-p async-p name)))
  
- (defun js2-parse-function-internal (function-type pos star-p &optional name)
 -(defun js2-parse-function (function-type pos star-p async-p &optional name)
 -  "Function parser.  FUNCTION-TYPE is a symbol, POS is the
 -beginning of the first token (function keyword, unless it's an
 -arrow function), NAME is js2-name-node."
++(defun js2-parse-function-internal (function-type pos star-p &optional async-p name)
    (let (fn-node lp)
      (if (= (js2-current-token-type) js2-LP) ; eventually matched LP?
          (setq lp (js2-current-token-beg)))
      (setf (js2-scope-parent-scope fn-node) js2-current-scope)
      fn-node))
  
- (defun js2-parse-function (function-type pos star-p &optional name)
++(defun js2-parse-function (function-type pos star-p &optional async-p name)
 +  "Function parser.  FUNCTION-TYPE is a symbol, POS is the
 +beginning of the first token (function keyword, unless it's an
 +arrow function), NAME is js2-name-node."
 +  (let ((continue t)
 +        ts-state
 +        fn-node
 +        ;; Preserve strict state outside this function.
 +        (js2-in-use-strict-directive js2-in-use-strict-directive))
 +    ;; Parse multiple times if a new strict mode directive is discovered in the
 +    ;; function body, as new rules will be retroactively applied to the legality
 +    ;; of function names and parameters.
 +    (while continue
 +      (setq ts-state (make-js2-ts-state))
 +      (setq continue (catch 'reparse
 +                       (setq fn-node (js2-parse-function-internal
-                                       function-type pos star-p name))
++                                      function-type pos star-p async-p name))
 +                       ;; Don't continue.
 +                       nil))
 +      (when continue
 +        (js2-ts-seek ts-state)))
 +    fn-node))
 +
  (defun js2-parse-statements (&optional parent)
    "Parse a statement list.  Last token consumed must be js2-LC.
  
diff --cc tests/parser.el
Simple merge