<commit_before>; tré – Copyright (c) 2008–2015 <NAME> <<EMAIL>>

(defmacro define-js-std-macro (name args &body body)
  `(define-transpiler-std-macro *js-transpiler* ,name ,args ,@body))

(defun js-make-function-with-expander (x)
  (alet (| (lambda-name x)
           (gensym))
    (with-gensym g
      `(%%block
         (%var ,g)
         ,(copy-lambda x :name ! :body (body-with-noargs-tag (lambda-body x)))
         (= (slot-value ,! 'tre-exp) ,(compile-argument-expansion g ! (lambda-args x)))
         ,!))))

(defun js-requires-expander? (x)
  (unless (body-has-noargs-tag? (lambda-body x))
    (| (assert?)
       (not (simple-argument-list? (lambda-args x))))))

(define-js-std-macro function (&rest x)
  (alet (. 'function x)
    (? .x
       (? (js-requires-expander? !)
          (js-make-function-with-expander !)
          !)
       !)))

(defvar *late-symbol-function-assignments* nil)

(defun js-make-late-symbol-function-assignment (name)
  (push `(= (slot-value ',name 'f) ,(compiled-function-name name))
        *late-symbol-function-assignments*))

(defun emit-late-symbol-function-assignments ()
  (reverse *late-symbol-function-assignments*))

(define-js-std-macro defnative (name args &body body)
  (js-make-late-symbol-function-assignment name)
  `(progn
     (%var ,(%defun-name name))
     ,(shared-defun name args (body-with-noargs-tag body))))

(defun js-early-symbol-maker (g sym)
  `(,@(unless (eq g '~%tfun)
        `((%var ,g)))
    (%= ,g (symbol ,(obfuscated-symbol-name sym)
                   ,(? (keyword? sym)
                       '*keyword-package*
                       (!? (symbol-package sym)
                           (? (& (not (string== "COMMON-LISP" (package-name !)))
                                 (invisible-package? !))
                              `(symbol ,(obfuscated-symbol-name !) nil))))))))

(define-js-std-macro defun (name args &body body)
  (with (dname  (%defun-name name)
         g      '~%tfun)
      `(%%block
         (%var ,dname)
         ,@(js-early-symbol-maker g dname)
         ,(shared-defun dname args body :make-expander? nil)
         (= (symbol-function ,g) ,dname))))
<commit_msg>Hide CL environment–specific packages.<commit_after>; tré – Copyright (c) 2008–2015 <NAME> <<EMAIL>>

(defmacro define-js-std-macro (name args &body body)
  `(define-transpiler-std-macro *js-transpiler* ,name ,args ,@body))

(defun js-make-function-with-expander (x)
  (alet (| (lambda-name x)
           (gensym))
    (with-gensym g
      `(%%block
         (%var ,g)
         ,(copy-lambda x :name ! :body (body-with-noargs-tag (lambda-body x)))
         (= (slot-value ,! 'tre-exp) ,(compile-argument-expansion g ! (lambda-args x)))
         ,!))))

(defun js-requires-expander? (x)
  (unless (body-has-noargs-tag? (lambda-body x))
    (| (assert?)
       (not (simple-argument-list? (lambda-args x))))))

(define-js-std-macro function (&rest x)
  (alet (. 'function x)
    (? .x
       (? (js-requires-expander? !)
          (js-make-function-with-expander !)
          !)
       !)))

(defvar *late-symbol-function-assignments* nil)

(defun js-make-late-symbol-function-assignment (name)
  (push `(= (slot-value ',name 'f) ,(compiled-function-name name))
        *late-symbol-function-assignments*))

(defun emit-late-symbol-function-assignments ()
  (reverse *late-symbol-function-assignments*))

(define-js-std-macro defnative (name args &body body)
  (js-make-late-symbol-function-assignment name)
  `(progn
     (%var ,(%defun-name name))
     ,(shared-defun name args (body-with-noargs-tag body))))

(defun js-early-symbol-maker (g sym)
  `(,@(unless (eq g '~%tfun)
        `((%var ,g)))
    (%= ,g (symbol ,(obfuscated-symbol-name sym)
                   ,(? (keyword? sym)
                       '*keyword-package*
                       (!? (symbol-package sym)
                           (? (& (not (string== "COMMON-LISP" (package-name !)))
                                 (not (invisible-package? !)))
                              `(symbol ,(obfuscated-symbol-name !) nil))))))))

(define-js-std-macro defun (name args &body body)
  (with (dname  (%defun-name name)
         g      '~%tfun)
      `(%%block
         (%var ,dname)
         ,@(js-early-symbol-maker g dname)
         ,(shared-defun dname args body :make-expander? nil)
         (= (symbol-function ,g) ,dname))))

{'fraction_non_alphanumeric': 0.18344416418252693, 'fraction_numerical': 0.0036688832836505388, 'mean_word_length': 2.309559939301973, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '822290', 'n_tokens_mistral': 1576, 'n_tokens_neox': 1507, 'n_words': 312}