<commit_before>;;;;; Transpiler: TRE to JavaScript
;;;;; Copyright (c) 2008-2009 <NAME> <<EMAIL>>
;;;;;
;;;;; Toplevel

(defun js-transpile-0 (f files)
  (format f "/*~%")
  (format f " * Copyright (c) 2005-2008 <NAME> <<EMAIL>>~%")
  (format f " *~%")
  (format f " * Softwarearchitekturbuero S<NAME>~%")
  (format f " * Westermuehlstrasse 31~%")
  (format f " * D-80469 Muenchen~%")
  (format f " * Tel.: ++49 / 89 / 57 08 22 38~%")
  (format f " *~%")
  (format f " * caroshi ECMAScript obfuscator~%")
  (format f " */~%")
  (format f "var _I_ = 0; while (1) {switch (_I_) {case 0: ~%")
   (when (transpiler-lambda-export? *js-transpiler*)
	 (transpiler-add-wanted-function *js-transpiler* 'array-copy))
  (with (tr *js-transpiler*
		 ; Expand.
		 base (transpiler-sighten tr *js-base*)
    	 base2 (transpiler-sighten tr *js-base2*)
		 tests (when (eq t *have-environment-tests*)
				 (transpiler-sighten tr (make-environment-tests)))
	 	 user (transpiler-sighten-files tr files)
		 deps (progn
				(format t "; Collecting dependencies...~%")
				(transpiler-import-from-environment tr)))
      (when (transpiler-lambda-export? *js-transpiler*)
        (format f (+ "function __manualArrayCopy (x) { "
					 "var a = [];"
					 "for (var i = 0; i < x.length; i++)"
						"a[i] = x[i];"
					 "return a;"
					 "}"
					 "function T37funref (f, g) { "
						"var r=function () {"
							"var a = __manualArrayCopy (arguments);"
							"a.unshift (g);"
							"return f.apply (null, a);"
							"};"
						"r.treArgs = cdr (f.treArgs);"
						"return r;"
					 "}~%")))
	  ; Generate.
	  (format t "; Let me think. Hmm")
	  (force-output)
      (princ (transpiler-concat-string-tree
 		       (transpiler-transpile tr base)
		       (transpiler-transpile tr deps)
 		       (transpiler-transpile tr base2)
			   (transpiler-transpile tr tests)
 		       (transpiler-transpile tr user))
	         f))
    (format f "}break;}~%")
    (format t "~%; Everything OK. Done.~%"l))

(defun js-transpile (out files &key (obfuscate? nil))
  (transpiler-reset *js-transpiler*)
  (transpiler-switch-obfuscator *js-transpiler* obfuscate?)
  (js-transpile-0 out files))

;; XXX defunct<commit_msg>Copyright message updated.<commit_after>;;;;; Transpiler: TRE to JavaScript
;;;;; Copyright (c) 2008-2009 <NAME> <<EMAIL>>
;;;;;
;;;;; Toplevel

(defun js-transpile-0 (f files)
  (format f "/*~%")
  (format f " * Copyright (c) 2005-2009 <NAME> <<EMAIL>>~%")
  (format f " *~%")
  (format f " * Softwarearchitekturbuero Sven Klose~%")
  (format f " * Westermuehlstrasse 31~%")
  (format f " * D-80469 Muenchen~%")
  (format f " * Tel.: ++49 / 89 / 57 08 22 38~%")
  (format f " *~%")
  (format f " * caroshi ECMAScript obfuscator~%")
  (format f " */~%")
  (format f "var _I_ = 0; while (1) {switch (_I_) {case 0: ~%")
   (when (transpiler-lambda-export? *js-transpiler*)
	 (transpiler-add-wanted-function *js-transpiler* 'array-copy))
  (with (tr *js-transpiler*
		 ; Expand.
		 base (transpiler-sighten tr *js-base*)
    	 base2 (transpiler-sighten tr *js-base2*)
		 tests (when (eq t *have-environment-tests*)
				 (transpiler-sighten tr (make-environment-tests)))
	 	 user (transpiler-sighten-files tr files)
		 deps (progn
				(format t "; Collecting dependencies...~%")
				(transpiler-import-from-environment tr)))
      (when (transpiler-lambda-export? *js-transpiler*)
        (format f (+ "function __manualArrayCopy (x) { "
					 "var a = [];"
					 "for (var i = 0; i < x.length; i++)"
						"a[i] = x[i];"
					 "return a;"
					 "}"
					 "function T37funref (f, g) { "
						"var r=function () {"
							"var a = __manualArrayCopy (arguments);"
							"a.unshift (g);"
							"return f.apply (null, a);"
							"};"
						"r.treArgs = cdr (f.treArgs);"
						"return r;"
					 "}~%")))
	  ; Generate.
	  (format t "; Let me think. Hmm")
	  (force-output)
      (princ (transpiler-concat-string-tree
 		       (transpiler-transpile tr base)
		       (transpiler-transpile tr deps)
 		       (transpiler-transpile tr base2)
			   (transpiler-transpile tr tests)
 		       (transpiler-transpile tr user))
	         f))
    (format f "}break;}~%")
    (format t "~%; Everything OK. Done.~%"))

(defun js-transpile (out files &key (obfuscate? nil))
  (transpiler-reset *js-transpiler*)
  (transpiler-switch-obfuscator *js-transpiler* obfuscate?)
  (js-transpile-0 out files))

;; XXX defunct
{'fraction_non_alphanumeric': 0.18449258836944127, 'fraction_numerical': 0.0209806157354618, 'mean_word_length': 2.86431718061674, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '956411', 'n_tokens_mistral': 1961, 'n_tokens_neox': 1623, 'n_words': 398}