branch: master commit 97d27d664aed3aaf4332358fd805f64694c53436 Author: Dmitry Gutov <dgu...@yandex.ru> Commit: Dmitry Gutov <dgu...@yandex.ru>
Put the visitor and printer properties on unprefixed symbols as well Fixes #422. --- js2-mode.el | 298 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 151 insertions(+), 147 deletions(-) diff --git a/js2-mode.el b/js2-mode.el index 9ab95d2..f4db9ff 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -1,6 +1,6 @@ ;;; js2-mode.el --- Improved JavaScript editing mode -;; Copyright (C) 2009, 2011-2016 Free Software Foundation, Inc. +;; Copyright (C) 2009, 2011-2017 Free Software Foundation, Inc. ;; Author: Steve Yegge <steve.ye...@gmail.com> ;; mooz <stillped...@gmail.com> @@ -2228,6 +2228,10 @@ If any given node in NODES is nil, doesn't record that link." "Return absolute buffer position of end of N." (+ (js2-node-abs-pos n) (js2-node-len n))) +(defun js2--struct-put (name key value) + (put name key value) + (put (intern (format "cl-struct-%s" name)) key value)) + ;; It's important to make sure block nodes have a Lisp list for the ;; child nodes, to limit printing recursion depth in an AST that ;; otherwise consists of defstruct vectors. Emacs will crash printing @@ -2244,8 +2248,8 @@ If any given node in NODES is nil, doesn't record that link." "A block of statements." kids) ; a Lisp list of the child statement nodes -(put 'cl-struct-js2-block-node 'js2-visitor 'js2-visit-block) -(put 'cl-struct-js2-block-node 'js2-printer 'js2-print-block) +(js2--struct-put 'js2-block-node 'js2-visitor 'js2-visit-block) +(js2--struct-put 'js2-block-node 'js2-printer 'js2-print-block) (defun js2-visit-block (ast callback) "Visit the `js2-block-node' children of AST." @@ -2276,8 +2280,8 @@ If any given node in NODES is nil, doesn't record that link." parent-scope ; a `js2-scope' top) ; top-level `js2-scope' (script/function) -(put 'cl-struct-js2-scope 'js2-visitor 'js2-visit-block) -(put 'cl-struct-js2-scope 'js2-printer 'js2-print-none) +(js2--struct-put 'js2-scope 'js2-visitor 'js2-visit-block) +(js2--struct-put 'js2-scope 'js2-printer 'js2-print-none) (defun js2-node-get-enclosing-scope (node) "Return the innermost `js2-scope' node surrounding NODE. @@ -2350,8 +2354,8 @@ NAME can be a Lisp symbol or string. SYMBOL is a `js2-symbol'." len))) "AST node representing a parse error.") -(put 'cl-struct-js2-error-node 'js2-visitor 'js2-visit-none) -(put 'cl-struct-js2-error-node 'js2-printer 'js2-print-none) +(js2--struct-put 'js2-error-node 'js2-visitor 'js2-visit-none) +(js2--struct-put 'js2-error-node 'js2-printer 'js2-print-none) (cl-defstruct (js2-script-node (:include js2-scope) @@ -2370,8 +2374,8 @@ NAME can be a Lisp symbol or string. SYMBOL is a `js2-symbol'." consts ; bool-vector matching var-decls (temp-number 0)) ; for generating temp variables -(put 'cl-struct-js2-script-node 'js2-visitor 'js2-visit-block) -(put 'cl-struct-js2-script-node 'js2-printer 'js2-print-script) +(js2--struct-put 'js2-script-node 'js2-visitor 'js2-visit-block) +(js2--struct-put 'js2-script-node 'js2-printer 'js2-print-script) (defun js2-print-script (node indent) (dolist (kid (js2-block-node-kids node)) @@ -2391,8 +2395,8 @@ NAME can be a Lisp symbol or string. SYMBOL is a `js2-symbol'." warnings ; a Lisp list of warnings found during parsing node-count) ; number of nodes in the tree, including the root -(put 'cl-struct-js2-ast-root 'js2-visitor 'js2-visit-ast-root) -(put 'cl-struct-js2-ast-root 'js2-printer 'js2-print-script) +(js2--struct-put 'js2-ast-root 'js2-visitor 'js2-visit-ast-root) +(js2--struct-put 'js2-ast-root 'js2-printer 'js2-print-script) (defun js2-visit-ast-root (ast callback) (dolist (kid (js2-ast-root-kids ast)) @@ -2409,8 +2413,8 @@ NAME can be a Lisp symbol or string. SYMBOL is a `js2-symbol'." format))) format) ; 'line, 'block, 'jsdoc or 'html -(put 'cl-struct-js2-comment-node 'js2-visitor 'js2-visit-none) -(put 'cl-struct-js2-comment-node 'js2-printer 'js2-print-comment) +(js2--struct-put 'js2-comment-node 'js2-visitor 'js2-visit-none) +(js2--struct-put 'js2-comment-node 'js2-printer 'js2-print-comment) (defun js2-print-comment (n i) ;; We really ought to link end-of-line comments to their nodes. @@ -2432,8 +2436,8 @@ NAME can be a Lisp symbol or string. SYMBOL is a `js2-symbol'." "Change NODE type to `js2-EXPR_RESULT'. Used for code generation." (setf (js2-node-type node) js2-EXPR_RESULT)) -(put 'cl-struct-js2-expr-stmt-node 'js2-visitor 'js2-visit-expr-stmt-node) -(put 'cl-struct-js2-expr-stmt-node 'js2-printer 'js2-print-expr-stmt-node) +(js2--struct-put 'js2-expr-stmt-node 'js2-visitor 'js2-visit-expr-stmt-node) +(js2--struct-put 'js2-expr-stmt-node 'js2-printer 'js2-print-expr-stmt-node) (defun js2-visit-expr-stmt-node (n v) (js2-visit-ast (js2-expr-stmt-node-expr n) v)) @@ -2465,8 +2469,8 @@ NAME can be a Lisp symbol or string. SYMBOL is a `js2-symbol'." condition ; while (expression) while-pos) ; buffer position of 'while' keyword -(put 'cl-struct-js2-do-node 'js2-visitor 'js2-visit-do-node) -(put 'cl-struct-js2-do-node 'js2-printer 'js2-print-do-node) +(js2--struct-put 'js2-do-node 'js2-visitor 'js2-visit-do-node) +(js2--struct-put 'js2-do-node 'js2-printer 'js2-print-do-node) (defun js2-visit-do-node (n v) (js2-visit-ast (js2-do-node-body n) v) @@ -2499,8 +2503,8 @@ so many of its properties will be nil. declaration ; js2-var-decl-node (var, let, const) or js2-class-node default) ; js2-function-node or js2-assign-node -(put 'cl-struct-js2-export-node 'js2-visitor 'js2-visit-export-node) -(put 'cl-struct-js2-export-node 'js2-printer 'js2-print-export-node) +(js2--struct-put 'js2-export-node 'js2-visitor 'js2-visit-export-node) +(js2--struct-put 'js2-export-node 'js2-printer 'js2-print-export-node) (defun js2-visit-export-node (n v) (let ((exports-list (js2-export-node-exports-list n)) @@ -2555,8 +2559,8 @@ so many of its properties will be nil. "AST node for while-loop." condition) ; while-condition -(put 'cl-struct-js2-while-node 'js2-visitor 'js2-visit-while-node) -(put 'cl-struct-js2-while-node 'js2-printer 'js2-print-while-node) +(js2--struct-put 'js2-while-node 'js2-visitor 'js2-visit-while-node) +(js2--struct-put 'js2-while-node 'js2-printer 'js2-print-while-node) (defun js2-visit-while-node (n v) (js2-visit-ast (js2-while-node-condition n) v) @@ -2583,8 +2587,8 @@ so many of its properties will be nil. condition ; loop condition update) ; update clause -(put 'cl-struct-js2-for-node 'js2-visitor 'js2-visit-for-node) -(put 'cl-struct-js2-for-node 'js2-printer 'js2-print-for-node) +(js2--struct-put 'js2-for-node 'js2-visitor 'js2-visit-for-node) +(js2--struct-put 'js2-for-node 'js2-printer 'js2-print-for-node) (defun js2-visit-for-node (n v) (js2-visit-ast (js2-for-node-init n) v) @@ -2624,8 +2628,8 @@ so many of its properties will be nil. foreach-p ; t if it's a for-each loop forof-p) ; t if it's a for-of loop -(put 'cl-struct-js2-for-in-node 'js2-visitor 'js2-visit-for-in-node) -(put 'cl-struct-js2-for-in-node 'js2-printer 'js2-print-for-in-node) +(js2--struct-put 'js2-for-in-node 'js2-visitor 'js2-visit-for-in-node) +(js2--struct-put 'js2-for-in-node 'js2-printer 'js2-print-for-in-node) (defun js2-visit-for-in-node (n v) (js2-visit-ast (js2-for-in-node-iterator n) v) @@ -2657,8 +2661,8 @@ so many of its properties will be nil. "AST node for a return statement." retval) ; expression to return, or 'undefined -(put 'cl-struct-js2-return-node 'js2-visitor 'js2-visit-return-node) -(put 'cl-struct-js2-return-node 'js2-printer 'js2-print-return-node) +(js2--struct-put 'js2-return-node 'js2-visitor 'js2-visit-return-node) +(js2--struct-put 'js2-return-node 'js2-printer 'js2-print-return-node) (defun js2-visit-return-node (n v) (js2-visit-ast (js2-return-node-retval n) v)) @@ -2688,8 +2692,8 @@ so many of its properties will be nil. lp ; position of left-paren, nil if omitted rp) ; position of right-paren, nil if omitted -(put 'cl-struct-js2-if-node 'js2-visitor 'js2-visit-if-node) -(put 'cl-struct-js2-if-node 'js2-printer 'js2-print-if-node) +(js2--struct-put 'js2-if-node 'js2-visitor 'js2-visit-if-node) +(js2--struct-put 'js2-if-node 'js2-printer 'js2-print-if-node) (defun js2-visit-if-node (n v) (js2-visit-ast (js2-if-node-condition n) v) @@ -2733,8 +2737,8 @@ containing 'foo' and a local-name node containing 'bar'." local-name ; js2-name-node with the variable name in this scope extern-name) ; js2-name-node with the value name in the exporting module -(put 'cl-struct-js2-export-binding-node 'js2-printer 'js2-print-extern-binding) -(put 'cl-struct-js2-export-binding-node 'js2-visitor 'js2-visit-extern-binding) +(js2--struct-put 'js2-export-binding-node 'js2-printer 'js2-print-extern-binding) +(js2--struct-put 'js2-export-binding-node 'js2-visitor 'js2-visit-extern-binding) (defun js2-visit-extern-binding (n v) "Visit an extern binding node. First visit the local-name, and, if @@ -2774,8 +2778,8 @@ import ImportClause FromClause;" from ; js2-from-clause-node indicating the module from which to import. module-id) ; module-id of the import. E.g. 'src/mylib'. -(put 'cl-struct-js2-import-node 'js2-printer 'js2-print-import) -(put 'cl-struct-js2-import-node 'js2-visitor 'js2-visit-import) +(js2--struct-put 'js2-import-node 'js2-printer 'js2-print-import) +(js2--struct-put 'js2-import-node 'js2-visitor 'js2-visit-import) (defun js2-visit-import (n v) (let ((import-clause (js2-import-node-import n)) @@ -2818,8 +2822,8 @@ local context." named-imports ; lisp list of js2-export-binding-node for all named imports. default-binding) ; js2-export-binding-node for the default import binding -(put 'cl-struct-js2-import-clause-node 'js2-visitor 'js2-visit-import-clause) -(put 'cl-struct-js2-import-clause-node 'js2-printer 'js2-print-import-clause) +(js2--struct-put 'js2-import-clause-node 'js2-visitor 'js2-visit-import-clause) +(js2--struct-put 'js2-import-clause-node 'js2-printer 'js2-print-import-clause) (defun js2-visit-import-clause (n v) (let ((ns-import (js2-import-clause-node-namespace-import n)) @@ -2886,8 +2890,8 @@ It contains a single name node referring to the bound name." (defun js2-visit-namespace-import (n v) (js2-visit-ast (js2-namespace-import-node-name n) v)) -(put 'cl-struct-js2-namespace-import-node 'js2-visitor 'js2-visit-namespace-import) -(put 'cl-struct-js2-namespace-import-node 'js2-printer 'js2-print-namespace-import) +(js2--struct-put 'js2-namespace-import-node 'js2-visitor 'js2-visit-namespace-import) +(js2--struct-put 'js2-namespace-import-node 'js2-printer 'js2-print-namespace-import) (cl-defstruct (js2-from-clause-node (:include js2-node) @@ -2903,8 +2907,8 @@ modules metadata itself." module-id ; string containing the module specifier. metadata-p) ; true if this clause refers to the module's metadata -(put 'cl-struct-js2-from-clause-node 'js2-visitor 'js2-visit-none) -(put 'cl-struct-js2-from-clause-node 'js2-printer 'js2-print-from-clause) +(js2--struct-put 'js2-from-clause-node 'js2-visitor 'js2-visit-none) +(js2--struct-put 'js2-from-clause-node 'js2-printer 'js2-print-from-clause) (defun js2-print-from-clause (n) (insert "from ") @@ -2928,8 +2932,8 @@ modules metadata itself." catch-clauses ; a Lisp list of `js2-catch-node' finally-block) ; a `js2-finally-node' -(put 'cl-struct-js2-try-node 'js2-visitor 'js2-visit-try-node) -(put 'cl-struct-js2-try-node 'js2-printer 'js2-print-try-node) +(js2--struct-put 'js2-try-node 'js2-visitor 'js2-visit-try-node) +(js2--struct-put 'js2-try-node 'js2-printer 'js2-print-try-node) (defun js2-visit-try-node (n v) (js2-visit-ast (js2-try-node-try-block n) v) @@ -2968,8 +2972,8 @@ modules metadata itself." lp ; buffer position of left-paren, nil if omitted rp) ; buffer position of right-paren, nil if omitted -(put 'cl-struct-js2-catch-node 'js2-visitor 'js2-visit-catch-node) -(put 'cl-struct-js2-catch-node 'js2-printer 'js2-print-catch-node) +(js2--struct-put 'js2-catch-node 'js2-visitor 'js2-visit-catch-node) +(js2--struct-put 'js2-catch-node 'js2-printer 'js2-print-catch-node) (defun js2-visit-catch-node (n v) (js2-visit-ast (js2-catch-node-param n) v) @@ -2999,8 +3003,8 @@ modules metadata itself." "AST node for a finally clause." body) ; a `js2-node', often but not always a block node -(put 'cl-struct-js2-finally-node 'js2-visitor 'js2-visit-finally-node) -(put 'cl-struct-js2-finally-node 'js2-printer 'js2-print-finally-node) +(js2--struct-put 'js2-finally-node 'js2-visitor 'js2-visit-finally-node) +(js2--struct-put 'js2-finally-node 'js2-printer 'js2-print-finally-node) (defun js2-visit-finally-node (n v) (js2-visit-ast (js2-finally-node-body n) v)) @@ -3026,8 +3030,8 @@ modules metadata itself." lp ; position of open-paren for discriminant, nil if omitted rp) ; position of close-paren for discriminant, nil if omitted -(put 'cl-struct-js2-switch-node 'js2-visitor 'js2-visit-switch-node) -(put 'cl-struct-js2-switch-node 'js2-printer 'js2-print-switch-node) +(js2--struct-put 'js2-switch-node 'js2-visitor 'js2-visit-switch-node) +(js2--struct-put 'js2-switch-node 'js2-printer 'js2-print-switch-node) (defun js2-visit-switch-node (n v) (js2-visit-ast (js2-switch-node-discriminant n) v) @@ -3053,8 +3057,8 @@ modules metadata itself." "AST node for a case clause of a switch statement." expr) ; the case expression (nil for default) -(put 'cl-struct-js2-case-node 'js2-visitor 'js2-visit-case-node) -(put 'cl-struct-js2-case-node 'js2-printer 'js2-print-case-node) +(js2--struct-put 'js2-case-node 'js2-visitor 'js2-visit-case-node) +(js2--struct-put 'js2-case-node 'js2-printer 'js2-print-case-node) (defun js2-visit-case-node (n v) (js2-visit-ast (js2-case-node-expr n) v) @@ -3081,8 +3085,8 @@ modules metadata itself." "AST node for a throw statement." expr) ; the expression to throw -(put 'cl-struct-js2-throw-node 'js2-visitor 'js2-visit-throw-node) -(put 'cl-struct-js2-throw-node 'js2-printer 'js2-print-throw-node) +(js2--struct-put 'js2-throw-node 'js2-visitor 'js2-visit-throw-node) +(js2--struct-put 'js2-throw-node 'js2-printer 'js2-print-throw-node) (defun js2-visit-throw-node (n v) (js2-visit-ast (js2-throw-node-expr n) v)) @@ -3105,8 +3109,8 @@ modules metadata itself." lp ; buffer position of left-paren around object, nil if omitted rp) ; buffer position of right-paren around object, nil if omitted -(put 'cl-struct-js2-with-node 'js2-visitor 'js2-visit-with-node) -(put 'cl-struct-js2-with-node 'js2-printer 'js2-print-with-node) +(js2--struct-put 'js2-with-node 'js2-visitor 'js2-visit-with-node) +(js2--struct-put 'js2-with-node 'js2-printer 'js2-print-with-node) (defun js2-visit-with-node (n v) (js2-visit-ast (js2-with-node-object n) v) @@ -3130,8 +3134,8 @@ modules metadata itself." name ; a string loop) ; for validating and code-generating continue-to-label -(put 'cl-struct-js2-label-node 'js2-visitor 'js2-visit-none) -(put 'cl-struct-js2-label-node 'js2-printer 'js2-print-label) +(js2--struct-put 'js2-label-node 'js2-visitor 'js2-visit-none) +(js2--struct-put 'js2-label-node 'js2-printer 'js2-print-label) (defun js2-print-label (n i) (insert (js2-make-pad i) @@ -3151,8 +3155,8 @@ Multiple labels for a statement are collapsed into the labels field." labels ; Lisp list of `js2-label-node' stmt) ; the statement these labels are for -(put 'cl-struct-js2-labeled-stmt-node 'js2-visitor 'js2-visit-labeled-stmt) -(put 'cl-struct-js2-labeled-stmt-node 'js2-printer 'js2-print-labeled-stmt) +(js2--struct-put 'js2-labeled-stmt-node 'js2-visitor 'js2-visit-labeled-stmt) +(js2--struct-put 'js2-labeled-stmt-node 'js2-printer 'js2-print-labeled-stmt) (defun js2-get-label-by-name (lbl-stmt name) "Return a `js2-label-node' by NAME from LBL-STMT's labels list. @@ -3210,8 +3214,8 @@ The label field is a `js2-name-node', possibly nil, for the named label if provided. E.g. in 'break foo', it represents 'foo'. The target field is the target of the break - a label node or enclosing loop/switch statement.") -(put 'cl-struct-js2-break-node 'js2-visitor 'js2-visit-jump-node) -(put 'cl-struct-js2-break-node 'js2-printer 'js2-print-break-node) +(js2--struct-put 'js2-break-node 'js2-visitor 'js2-visit-jump-node) +(js2--struct-put 'js2-break-node 'js2-printer 'js2-print-break-node) (defun js2-print-break-node (n i) (insert (js2-make-pad i) "break") @@ -3231,8 +3235,8 @@ The label field is the user-supplied enclosing label name, a `js2-name-node'. It is nil if continue specifies no label. The target field is the jump target: a `js2-label-node' or the innermost enclosing loop.") -(put 'cl-struct-js2-continue-node 'js2-visitor 'js2-visit-jump-node) -(put 'cl-struct-js2-continue-node 'js2-printer 'js2-print-continue-node) +(js2--struct-put 'js2-continue-node 'js2-visitor 'js2-visit-jump-node) +(js2--struct-put 'js2-continue-node 'js2-printer 'js2-print-continue-node) (defun js2-print-continue-node (n i) (insert (js2-make-pad i) "continue") @@ -3273,8 +3277,8 @@ The `params' field is a Lisp list of nodes. Each node is either a simple async ; t if the function is defined as `async function` member-expr) ; nonstandard Ecma extension from Rhino -(put 'cl-struct-js2-function-node 'js2-visitor 'js2-visit-function-node) -(put 'cl-struct-js2-function-node 'js2-printer 'js2-print-function-node) +(js2--struct-put 'js2-function-node 'js2-visitor 'js2-visit-function-node) +(js2--struct-put 'js2-function-node 'js2-printer 'js2-print-function-node) (defun js2-visit-function-node (n v) (js2-visit-ast (js2-function-node-name n) v) @@ -3349,8 +3353,8 @@ declarations, the node begins at the position of the first child." kids ; a Lisp list of `js2-var-init-node' structs. decl-type) ; js2-VAR, js2-CONST or js2-LET -(put 'cl-struct-js2-var-decl-node 'js2-visitor 'js2-visit-var-decl) -(put 'cl-struct-js2-var-decl-node 'js2-printer 'js2-print-var-decl) +(js2--struct-put 'js2-var-decl-node 'js2-visitor 'js2-visit-var-decl) +(js2--struct-put 'js2-var-decl-node 'js2-printer 'js2-print-var-decl) (defun js2-visit-var-decl (n v) (dolist (kid (js2-var-decl-node-kids n)) @@ -3387,8 +3391,8 @@ The type field will be js2-CONST for a const decl." target ; `js2-name-node', `js2-object-node', or `js2-array-node' initializer) ; initializer expression, a `js2-node' -(put 'cl-struct-js2-var-init-node 'js2-visitor 'js2-visit-var-init-node) -(put 'cl-struct-js2-var-init-node 'js2-printer 'js2-print-var-init-node) +(js2--struct-put 'js2-var-init-node 'js2-visitor 'js2-visit-var-init-node) +(js2--struct-put 'js2-var-init-node 'js2-printer 'js2-print-var-init-node) (defun js2-visit-var-init-node (n v) (js2-visit-ast (js2-var-init-node-target n) v) @@ -3421,8 +3425,8 @@ The type field will be js2-CONST for a const decl." q-pos ; buffer position of ? c-pos) ; buffer position of : -(put 'cl-struct-js2-cond-node 'js2-visitor 'js2-visit-cond-node) -(put 'cl-struct-js2-cond-node 'js2-printer 'js2-print-cond-node) +(js2--struct-put 'js2-cond-node 'js2-visitor 'js2-visit-cond-node) +(js2--struct-put 'js2-cond-node 'js2-printer 'js2-print-cond-node) (defun js2-visit-cond-node (n v) (js2-visit-ast (js2-cond-node-test-expr n) v) @@ -3452,8 +3456,8 @@ The type field inherited from `js2-node' holds the operator." left ; any `js2-node' right) ; any `js2-node' -(put 'cl-struct-js2-infix-node 'js2-visitor 'js2-visit-infix-node) -(put 'cl-struct-js2-infix-node 'js2-printer 'js2-print-infix-node) +(js2--struct-put 'js2-infix-node 'js2-visitor 'js2-visit-infix-node) +(js2--struct-put 'js2-infix-node 'js2-printer 'js2-print-infix-node) (defun js2-visit-infix-node (n v) (js2-visit-ast (js2-infix-node-left n) v) @@ -3539,8 +3543,8 @@ The type field inherited from `js2-node' holds the operator." "Represents any assignment. The type field holds the actual assignment operator.") -(put 'cl-struct-js2-assign-node 'js2-visitor 'js2-visit-infix-node) -(put 'cl-struct-js2-assign-node 'js2-printer 'js2-print-infix-node) +(js2--struct-put 'js2-assign-node 'js2-visitor 'js2-visit-infix-node) +(js2--struct-put 'js2-assign-node 'js2-printer 'js2-print-infix-node) (cl-defstruct (js2-unary-node (:include js2-node) @@ -3554,8 +3558,8 @@ TYPEOF, DELPROP, TRIPLEDOT or AWAIT. For INC or DEC, a 'postfix node property is added if the operator follows the operand." operand) ; a `js2-node' expression -(put 'cl-struct-js2-unary-node 'js2-visitor 'js2-visit-unary-node) -(put 'cl-struct-js2-unary-node 'js2-printer 'js2-print-unary-node) +(js2--struct-put 'js2-unary-node 'js2-visitor 'js2-visit-unary-node) +(js2--struct-put 'js2-unary-node 'js2-printer 'js2-print-unary-node) (defun js2-visit-unary-node (n v) (js2-visit-ast (js2-unary-node-operand n) v)) @@ -3592,8 +3596,8 @@ Note that a let declaration such as let x=6, y=7 is a `js2-var-decl-node'." lp rp) -(put 'cl-struct-js2-let-node 'js2-visitor 'js2-visit-let-node) -(put 'cl-struct-js2-let-node 'js2-printer 'js2-print-let-node) +(js2--struct-put 'js2-let-node 'js2-visitor 'js2-visit-let-node) +(js2--struct-put 'js2-let-node 'js2-printer 'js2-print-let-node) (defun js2-visit-let-node (n v) (js2-visit-ast (js2-let-node-vars n) v) @@ -3617,8 +3621,8 @@ Note that a let declaration such as let x=6, y=7 is a `js2-var-decl-node'." Used for `null', `this', `true', `false' and `debugger'. The node type is set to js2-NULL, js2-THIS, etc.") -(put 'cl-struct-js2-keyword-node 'js2-visitor 'js2-visit-none) -(put 'cl-struct-js2-keyword-node 'js2-printer 'js2-print-keyword-node) +(js2--struct-put 'js2-keyword-node 'js2-visitor 'js2-visit-none) +(js2--struct-put 'js2-keyword-node 'js2-printer 'js2-print-keyword-node) (defun js2-print-keyword-node (n i) (insert (js2-make-pad i) @@ -3652,8 +3656,8 @@ The node type is set to js2-NULL, js2-THIS, etc.") rp ; position of right-paren, nil if omitted initializer) ; experimental Rhino syntax: optional `js2-object-node' -(put 'cl-struct-js2-new-node 'js2-visitor 'js2-visit-new-node) -(put 'cl-struct-js2-new-node 'js2-printer 'js2-print-new-node) +(js2--struct-put 'js2-new-node 'js2-visitor 'js2-visit-new-node) +(js2--struct-put 'js2-new-node 'js2-printer 'js2-print-new-node) (defun js2-visit-new-node (n v) (js2-visit-ast (js2-new-node-target n) v) @@ -3683,8 +3687,8 @@ The node type is set to js2-NULL, js2-THIS, etc.") name ; a string scope) ; a `js2-scope' (optional, used for codegen) -(put 'cl-struct-js2-name-node 'js2-visitor 'js2-visit-none) -(put 'cl-struct-js2-name-node 'js2-printer 'js2-print-name-node) +(js2--struct-put 'js2-name-node 'js2-visitor 'js2-visit-none) +(js2--struct-put 'js2-name-node 'js2-printer 'js2-print-name-node) (defun js2-print-name-node (n i) (insert (js2-make-pad i) @@ -3717,8 +3721,8 @@ Returns 0 if NODE is nil or its identifier field is nil." num-base ; the number's base legacy-octal-p) ; whether the number is a legacy octal (0123 instead of 0o123) -(put 'cl-struct-js2-number-node 'js2-visitor 'js2-visit-none) -(put 'cl-struct-js2-number-node 'js2-printer 'js2-print-number-node) +(js2--struct-put 'js2-number-node 'js2-visitor 'js2-visit-none) +(js2--struct-put 'js2-number-node 'js2-printer 'js2-print-number-node) (defun js2-print-number-node (n i) (insert (js2-make-pad i) @@ -3736,8 +3740,8 @@ Returns 0 if NODE is nil or its identifier field is nil." value ; the regexp string, without // delimiters flags) ; a string of flags, e.g. `mi'. -(put 'cl-struct-js2-regexp-node 'js2-visitor 'js2-visit-none) -(put 'cl-struct-js2-regexp-node 'js2-printer 'js2-print-regexp) +(js2--struct-put 'js2-regexp-node 'js2-visitor 'js2-visit-none) +(js2--struct-put 'js2-regexp-node 'js2-printer 'js2-print-regexp) (defun js2-print-regexp (n i) (insert (js2-make-pad i) @@ -3760,8 +3764,8 @@ Escape characters are not evaluated; e.g. \n is 2 chars in value field. You can tell the quote type by looking at the first character." value) ; the characters of the string, including the quotes -(put 'cl-struct-js2-string-node 'js2-visitor 'js2-visit-none) -(put 'cl-struct-js2-string-node 'js2-printer 'js2-print-string-node) +(js2--struct-put 'js2-string-node 'js2-visitor 'js2-visit-none) +(js2--struct-put 'js2-string-node 'js2-printer 'js2-print-string-node) (defun js2-print-string-node (n i) (insert (js2-make-pad i) @@ -3776,8 +3780,8 @@ You can tell the quote type by looking at the first character." kids) ; `js2-string-node' is used for string segments, other nodes ; for substitutions inside. -(put 'cl-struct-js2-template-node 'js2-visitor 'js2-visit-template) -(put 'cl-struct-js2-template-node 'js2-printer 'js2-print-template) +(js2--struct-put 'js2-template-node 'js2-visitor 'js2-visit-template) +(js2--struct-put 'js2-template-node 'js2-printer 'js2-print-template) (defun js2-visit-template (n callback) (dolist (kid (js2-template-node-kids n)) @@ -3799,8 +3803,8 @@ You can tell the quote type by looking at the first character." tag ; `js2-node' with the tag expression. template) ; `js2-template-node' with the template. -(put 'cl-struct-js2-tagged-template-node 'js2-visitor 'js2-visit-tagged-template) -(put 'cl-struct-js2-tagged-template-node 'js2-printer 'js2-print-tagged-template) +(js2--struct-put 'js2-tagged-template-node 'js2-visitor 'js2-visit-tagged-template) +(js2--struct-put 'js2-tagged-template-node 'js2-printer 'js2-print-tagged-template) (defun js2-visit-tagged-template (n callback) (js2-visit-ast (js2-tagged-template-node-tag n) callback) @@ -3820,8 +3824,8 @@ You can tell the quote type by looking at the first character." "AST node for an array literal." elems) ; list of expressions. [foo,,bar] yields a nil middle element. -(put 'cl-struct-js2-array-node 'js2-visitor 'js2-visit-array-node) -(put 'cl-struct-js2-array-node 'js2-printer 'js2-print-array-node) +(js2--struct-put 'js2-array-node 'js2-visitor 'js2-visit-array-node) +(js2--struct-put 'js2-array-node 'js2-printer 'js2-print-array-node) (defun js2-visit-array-node (n v) (dolist (e (js2-array-node-elems n)) @@ -3846,8 +3850,8 @@ You can tell the quote type by looking at the first character." `elems' is a list of `js2-object-prop-node'." elems) -(put 'cl-struct-js2-object-node 'js2-visitor 'js2-visit-object-node) -(put 'cl-struct-js2-object-node 'js2-printer 'js2-print-object-node) +(js2--struct-put 'js2-object-node 'js2-visitor 'js2-visit-object-node) +(js2--struct-put 'js2-object-node 'js2-printer 'js2-print-object-node) (defun js2-visit-object-node (n v) (dolist (e (js2-object-node-elems n)) @@ -3874,8 +3878,8 @@ optional `js2-expr-node'" extends ; class heritage (a `js2-expr-node', or nil if none) ) -(put 'cl-struct-js2-class-node 'js2-visitor 'js2-visit-class-node) -(put 'cl-struct-js2-class-node 'js2-printer 'js2-print-class-node) +(js2--struct-put 'js2-class-node 'js2-visitor 'js2-visit-class-node) +(js2--struct-put 'js2-class-node 'js2-printer 'js2-print-class-node) (defun js2-visit-class-node (n v) (js2-visit-ast (js2-class-node-name n) v) @@ -3917,8 +3921,8 @@ optional `js2-expr-node'" "AST node for a `ComputedPropertyName'." expr) -(put 'cl-struct-js2-computed-prop-name-node 'js2-visitor 'js2-visit-computed-prop-name-node) -(put 'cl-struct-js2-computed-prop-name-node 'js2-printer 'js2-print-computed-prop-name-node) +(js2--struct-put 'js2-computed-prop-name-node 'js2-visitor 'js2-visit-computed-prop-name-node) +(js2--struct-put 'js2-computed-prop-name-node 'js2-printer 'js2-print-computed-prop-name-node) (defun js2-visit-computed-prop-name-node (n v) (js2-visit-ast (js2-computed-prop-name-node-expr n) v)) @@ -3942,8 +3946,8 @@ number node or expression node. The `right' field is a is abbreviated, the node's `SHORTHAND' property is non-nil and both fields have the same value.") -(put 'cl-struct-js2-object-prop-node 'js2-visitor 'js2-visit-infix-node) -(put 'cl-struct-js2-object-prop-node 'js2-printer 'js2-print-object-prop-node) +(js2--struct-put 'js2-object-prop-node 'js2-visitor 'js2-visit-infix-node) +(js2--struct-put 'js2-object-prop-node 'js2-printer 'js2-print-object-prop-node) (defun js2-print-object-prop-node (n i) (let* ((left (js2-object-prop-node-left n)) @@ -3964,8 +3968,8 @@ The `left' field is the `js2-name-node' naming the method. The `right' field is always an anonymous `js2-function-node' with a node property `METHOD_TYPE' set to 'GET or 'SET. ") -(put 'cl-struct-js2-method-node 'js2-visitor 'js2-visit-infix-node) -(put 'cl-struct-js2-method-node 'js2-printer 'js2-print-method) +(js2--struct-put 'js2-method-node 'js2-visitor 'js2-visit-infix-node) +(js2--struct-put 'js2-method-node 'js2-printer 'js2-print-method) (defun js2-print-method (n i) (let* ((pad (js2-make-pad i)) @@ -3992,8 +3996,8 @@ property `METHOD_TYPE' set to 'GET or 'SET. ") len left right))) "AST node for a dotted property reference, e.g. foo.bar or foo().bar") -(put 'cl-struct-js2-prop-get-node 'js2-visitor 'js2-visit-prop-get-node) -(put 'cl-struct-js2-prop-get-node 'js2-printer 'js2-print-prop-get-node) +(js2--struct-put 'js2-prop-get-node 'js2-visitor 'js2-visit-prop-get-node) +(js2--struct-put 'js2-prop-get-node 'js2-printer 'js2-print-prop-get-node) (defun js2-visit-prop-get-node (n v) (js2-visit-ast (js2-prop-get-node-left n) v) @@ -4018,8 +4022,8 @@ property `METHOD_TYPE' set to 'GET or 'SET. ") lb ; position of left-bracket, nil if omitted rb) ; position of right-bracket, nil if omitted -(put 'cl-struct-js2-elem-get-node 'js2-visitor 'js2-visit-elem-get-node) -(put 'cl-struct-js2-elem-get-node 'js2-printer 'js2-print-elem-get-node) +(js2--struct-put 'js2-elem-get-node 'js2-visitor 'js2-visit-elem-get-node) +(js2--struct-put 'js2-elem-get-node 'js2-printer 'js2-print-elem-get-node) (defun js2-visit-elem-get-node (n v) (js2-visit-ast (js2-elem-get-node-target n) v) @@ -4045,8 +4049,8 @@ property `METHOD_TYPE' set to 'GET or 'SET. ") lp ; position of open-paren, or nil if missing rp) ; position of close-paren, or nil if missing -(put 'cl-struct-js2-call-node 'js2-visitor 'js2-visit-call-node) -(put 'cl-struct-js2-call-node 'js2-printer 'js2-print-call-node) +(js2--struct-put 'js2-call-node 'js2-visitor 'js2-visit-call-node) +(js2--struct-put 'js2-call-node 'js2-printer 'js2-print-call-node) (defun js2-visit-call-node (n v) (js2-visit-ast (js2-call-node-target n) v) @@ -4070,8 +4074,8 @@ property `METHOD_TYPE' set to 'GET or 'SET. ") star-p ; whether it's yield* value) ; optional: value to be yielded -(put 'cl-struct-js2-yield-node 'js2-visitor 'js2-visit-yield-node) -(put 'cl-struct-js2-yield-node 'js2-printer 'js2-print-yield-node) +(js2--struct-put 'js2-yield-node 'js2-visitor 'js2-visit-yield-node) +(js2--struct-put 'js2-yield-node 'js2-printer 'js2-print-yield-node) (defun js2-visit-yield-node (n v) (js2-visit-ast (js2-yield-node-value n) v)) @@ -4096,8 +4100,8 @@ In particular, used when the parens are syntactically optional, as opposed to required parens such as those enclosing an if-conditional." expr) ; `js2-node' -(put 'cl-struct-js2-paren-node 'js2-visitor 'js2-visit-paren-node) -(put 'cl-struct-js2-paren-node 'js2-printer 'js2-print-paren-node) +(js2--struct-put 'js2-paren-node 'js2-visitor 'js2-visit-paren-node) +(js2--struct-put 'js2-paren-node 'js2-printer 'js2-print-paren-node) (defun js2-visit-paren-node (n v) (js2-visit-ast (js2-paren-node-expr n) v)) @@ -4124,8 +4128,8 @@ as opposed to required parens such as those enclosing an if-conditional." ; SpiderMonkey also supports "legacy generator expressions", but we dont. ) -(put 'cl-struct-js2-comp-node 'js2-visitor 'js2-visit-comp-node) -(put 'cl-struct-js2-comp-node 'js2-printer 'js2-print-comp-node) +(js2--struct-put 'js2-comp-node 'js2-visitor 'js2-visit-comp-node) +(js2--struct-put 'js2-comp-node 'js2-printer 'js2-print-comp-node) (defun js2-visit-comp-node (n v) (js2-visit-ast (js2-comp-node-result n) v) @@ -4175,8 +4179,8 @@ as opposed to required parens such as those enclosing an if-conditional." lp rp))) "AST subtree for each 'for (foo in bar)' loop in an array comprehension.") -(put 'cl-struct-js2-comp-loop-node 'js2-visitor 'js2-visit-comp-loop) -(put 'cl-struct-js2-comp-loop-node 'js2-printer 'js2-print-comp-loop) +(js2--struct-put 'js2-comp-loop-node 'js2-visitor 'js2-visit-comp-loop) +(js2--struct-put 'js2-comp-loop-node 'js2-printer 'js2-print-comp-loop) (defun js2-visit-comp-loop (n v) (js2-visit-ast (js2-comp-loop-node-iterator n) v) @@ -4200,8 +4204,8 @@ as opposed to required parens such as those enclosing an if-conditional." len))) "AST node for an empty expression.") -(put 'cl-struct-js2-empty-expr-node 'js2-visitor 'js2-visit-none) -(put 'cl-struct-js2-empty-expr-node 'js2-printer 'js2-print-none) +(js2--struct-put 'js2-empty-expr-node 'js2-visitor 'js2-visit-none) +(js2--struct-put 'js2-empty-expr-node 'js2-printer 'js2-print-none) (cl-defstruct (js2-xml-node (:include js2-block-node) @@ -4213,8 +4217,8 @@ as opposed to required parens such as those enclosing an if-conditional." The kids field is a list of XML fragments, each a `js2-string-node' or a `js2-xml-js-expr-node'. Equivalent to Rhino's XmlLiteral node.") -(put 'cl-struct-js2-xml-node 'js2-visitor 'js2-visit-block) -(put 'cl-struct-js2-xml-node 'js2-printer 'js2-print-xml-node) +(js2--struct-put 'js2-xml-node 'js2-visitor 'js2-visit-block) +(js2--struct-put 'js2-xml-node 'js2-printer 'js2-print-xml-node) (defun js2-print-xml-node (n i) (dolist (kid (js2-xml-node-kids n)) @@ -4230,8 +4234,8 @@ a `js2-xml-js-expr-node'. Equivalent to Rhino's XmlLiteral node.") The start and end fields correspond to the curly-braces." expr) ; a `js2-expr-node' of some sort -(put 'cl-struct-js2-xml-js-expr-node 'js2-visitor 'js2-visit-xml-js-expr) -(put 'cl-struct-js2-xml-js-expr-node 'js2-printer 'js2-print-xml-js-expr) +(js2--struct-put 'js2-xml-js-expr-node 'js2-visitor 'js2-visit-xml-js-expr) +(js2--struct-put 'js2-xml-js-expr-node 'js2-printer 'js2-print-xml-js-expr) (defun js2-visit-xml-js-expr (n v) (js2-visit-ast (js2-xml-js-expr-node-expr n) v)) @@ -4255,8 +4259,8 @@ following the dot (.) in the operator. No whitespace is permitted between the dot and the lp by the scanner." rp) -(put 'cl-struct-js2-xml-dot-query-node 'js2-visitor 'js2-visit-infix-node) -(put 'cl-struct-js2-xml-dot-query-node 'js2-printer 'js2-print-xml-dot-query) +(js2--struct-put 'js2-xml-dot-query-node 'js2-visitor 'js2-visit-infix-node) +(js2--struct-put 'js2-xml-dot-query-node 'js2-printer 'js2-print-xml-dot-query) (defun js2-print-xml-dot-query (n i) (insert (js2-make-pad i)) @@ -4321,8 +4325,8 @@ or if it is missing due to a syntax error, through the end of the index expression." propname) -(put 'cl-struct-js2-xml-prop-ref-node 'js2-visitor 'js2-visit-xml-prop-ref-node) -(put 'cl-struct-js2-xml-prop-ref-node 'js2-printer 'js2-print-xml-prop-ref-node) +(js2--struct-put 'js2-xml-prop-ref-node 'js2-visitor 'js2-visit-xml-prop-ref-node) +(js2--struct-put 'js2-xml-prop-ref-node 'js2-printer 'js2-print-xml-prop-ref-node) (defun js2-visit-xml-prop-ref-node (n v) (js2-visit-ast (js2-xml-prop-ref-node-namespace n) v) @@ -4367,8 +4371,8 @@ end of the index expression." lb rb) -(put 'cl-struct-js2-xml-elem-ref-node 'js2-visitor 'js2-visit-xml-elem-ref-node) -(put 'cl-struct-js2-xml-elem-ref-node 'js2-printer 'js2-print-xml-elem-ref-node) +(js2--struct-put 'js2-xml-elem-ref-node 'js2-visitor 'js2-visit-xml-elem-ref-node) +(js2--struct-put 'js2-xml-elem-ref-node 'js2-printer 'js2-print-xml-elem-ref-node) (defun js2-visit-xml-elem-ref-node (n v) (js2-visit-ast (js2-xml-elem-ref-node-namespace n) v) @@ -4401,8 +4405,8 @@ The `kids' field is a Lisp list of child content nodes." attrs ; a Lisp list of `js2-xml-attr-node' empty-p) ; t if this is an empty element such as <foo bar="baz"/> -(put 'cl-struct-js2-xml-start-tag-node 'js2-visitor 'js2-visit-xml-start-tag) -(put 'cl-struct-js2-xml-start-tag-node 'js2-printer 'js2-print-xml-start-tag) +(js2--struct-put 'js2-xml-start-tag-node 'js2-visitor 'js2-visit-xml-start-tag) +(js2--struct-put 'js2-xml-start-tag-node 'js2-printer 'js2-print-xml-start-tag) (defun js2-visit-xml-start-tag (n v) (js2-visit-ast (js2-xml-start-tag-node-name n) v) @@ -4429,8 +4433,8 @@ The `kids' field is a Lisp list of child content nodes." "AST node for an XML end-tag. Not currently used." name) ; a `js2-xml-name-node' -(put 'cl-struct-js2-xml-end-tag-node 'js2-visitor 'js2-visit-xml-end-tag) -(put 'cl-struct-js2-xml-end-tag-node 'js2-printer 'js2-print-xml-end-tag) +(js2--struct-put 'js2-xml-end-tag-node 'js2-visitor 'js2-visit-xml-end-tag) +(js2--struct-put 'js2-xml-end-tag-node 'js2-printer 'js2-print-xml-end-tag) (defun js2-visit-xml-end-tag (n v) (js2-visit-ast (js2-xml-end-tag-node-name n) v)) @@ -4454,8 +4458,8 @@ The kids field is a list of `js2-name-node' and `js2-xml-js-expr-node'. For a simple name, the kids list has exactly one node, a `js2-name-node'." namespace) ; a `js2-string-node' -(put 'cl-struct-js2-xml-name-node 'js2-visitor 'js2-visit-xml-name-node) -(put 'cl-struct-js2-xml-name-node 'js2-printer 'js2-print-xml-name-node) +(js2--struct-put 'js2-xml-name-node 'js2-visitor 'js2-visit-xml-name-node) +(js2--struct-put 'js2-xml-name-node 'js2-printer 'js2-print-xml-name-node) (defun js2-visit-xml-name-node (n v) (js2-visit-ast (js2-xml-name-node-namespace n) v)) @@ -4478,8 +4482,8 @@ For a simple name, the kids list has exactly one node, a `js2-name-node'." name ; a `js2-xml-name-node' attrs) ; a list of `js2-xml-attr-node' -(put 'cl-struct-js2-xml-pi-node 'js2-visitor 'js2-visit-xml-pi-node) -(put 'cl-struct-js2-xml-pi-node 'js2-printer 'js2-print-xml-pi-node) +(js2--struct-put 'js2-xml-pi-node 'js2-visitor 'js2-visit-xml-pi-node) +(js2--struct-put 'js2-xml-pi-node 'js2-printer 'js2-print-xml-pi-node) (defun js2-visit-xml-pi-node (n v) (js2-visit-ast (js2-xml-pi-node-name n) v) @@ -4503,8 +4507,8 @@ For a simple name, the kids list has exactly one node, a `js2-name-node'." "AST node for a CDATA escape section. Not currently used." content) ; a `js2-string-node' with node-property 'quote-type 'cdata -(put 'cl-struct-js2-xml-cdata-node 'js2-visitor 'js2-visit-xml-cdata-node) -(put 'cl-struct-js2-xml-cdata-node 'js2-printer 'js2-print-xml-cdata-node) +(js2--struct-put 'js2-xml-cdata-node 'js2-visitor 'js2-visit-xml-cdata-node) +(js2--struct-put 'js2-xml-cdata-node 'js2-printer 'js2-print-xml-cdata-node) (defun js2-visit-xml-cdata-node (n v) (js2-visit-ast (js2-xml-cdata-node-content n) v)) @@ -4526,8 +4530,8 @@ For a simple name, the kids list has exactly one node, a `js2-name-node'." eq-pos ; buffer position of "=" sign quote-type) ; 'single or 'double -(put 'cl-struct-js2-xml-attr-node 'js2-visitor 'js2-visit-xml-attr-node) -(put 'cl-struct-js2-xml-attr-node 'js2-printer 'js2-print-xml-attr-node) +(js2--struct-put 'js2-xml-attr-node 'js2-visitor 'js2-visit-xml-attr-node) +(js2--struct-put 'js2-xml-attr-node 'js2-printer 'js2-print-xml-attr-node) (defun js2-visit-xml-attr-node (n v) (js2-visit-ast (js2-xml-attr-node-name n) v) @@ -4552,8 +4556,8 @@ For a simple name, the kids list has exactly one node, a `js2-name-node'." "AST node for an E4X XML text node. Not currently used." content) ; a Lisp list of `js2-string-node' and `js2-xml-js-expr-node' -(put 'cl-struct-js2-xml-text-node 'js2-visitor 'js2-visit-xml-text-node) -(put 'cl-struct-js2-xml-text-node 'js2-printer 'js2-print-xml-text-node) +(js2--struct-put 'js2-xml-text-node 'js2-visitor 'js2-visit-xml-text-node) +(js2--struct-put 'js2-xml-text-node 'js2-printer 'js2-print-xml-text-node) (defun js2-visit-xml-text-node (n v) (js2-visit-ast (js2-xml-text-node-content n) v)) @@ -4571,8 +4575,8 @@ For a simple name, the kids list has exactly one node, a `js2-name-node'." len))) "AST node for E4X XML comment. Not currently used.") -(put 'cl-struct-js2-xml-comment-node 'js2-visitor 'js2-visit-none) -(put 'cl-struct-js2-xml-comment-node 'js2-printer 'js2-print-xml-comment) +(js2--struct-put 'js2-xml-comment-node 'js2-visitor 'js2-visit-none) +(js2--struct-put 'js2-xml-comment-node 'js2-printer 'js2-print-xml-comment) (defun js2-print-xml-comment (n i) (insert (js2-make-pad i)