From 763395d72ba78f2b8042434e1f2841db8fada2be Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Fri, 21 Jun 2013 04:48:50 +0200 Subject: [PATCH] Remove `indent' --- src/compiler.lisp | 121 ++++++++++++++++++++--------------------------------- 1 file changed, 46 insertions(+), 75 deletions(-) diff --git a/src/compiler.lisp b/src/compiler.lisp index 66a734c..9ebbbf3 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -44,41 +44,12 @@ ;;; It could be defined as function, but we could do some ;;; preprocessing in the future. (defmacro js!selfcall (&body body) - `(code "(function(){" *newline* (indent ,@body) "})()")) + `(code "(function(){" *newline* (code ,@body) "})()")) ;;; Like CODE, but prefix each line with four spaces. Two versions ;;; of this function are available, because the Ecmalisp version is ;;; very slow and bootstraping was annoying. -#+jscl -(defun indent (&rest string) - (let ((input (apply #'code string))) - (let ((output "") - (index 0) - (size (length input))) - (when (plusp (length input)) (concatf output " ")) - (while (< index size) - (let ((str - (if (and (char= (char input index) #\newline) - (< index (1- size)) - (not (char= (char input (1+ index)) #\newline))) - (concat (string #\newline) " ") - (string (char input index))))) - (concatf output str)) - (incf index)) - output))) - -#-jscl -(defun indent (&rest string) - (with-output-to-string (*standard-output*) - (with-input-from-string (input (apply #'code string)) - (loop - for line = (read-line input nil) - while line - do (write-string " ") - do (write-line line))))) - - ;;; A Form can return a multiple values object calling VALUES, like ;;; values(arg1, arg2, ...). It will work in any context, as well as ;;; returning an individual object. However, if the special variable @@ -301,14 +272,14 @@ (while (< idx n-optional-arguments) (let ((arg (nth idx optional-arguments))) (push (code "case " (+ idx n-required-arguments) ":" *newline* - (indent (translate-variable (car arg)) - "=" - (ls-compile (cadr arg)) ";" *newline*) + (code (translate-variable (car arg)) + "=" + (ls-compile (cadr arg)) ";" *newline*) (when (third arg) - (indent (translate-variable (third arg)) - "=" - (ls-compile nil) - ";" *newline*))) + (code (translate-variable (third arg)) + "=" + (ls-compile nil) + ";" *newline*))) cases) (incf idx))) (push (code "default: break;" *newline*) cases) @@ -324,7 +295,7 @@ (code "var " js!rest "= " (ls-compile nil) ";" *newline* "for (var i = nargs-1; i>=" (+ n-required-arguments n-optional-arguments) "; i--)" *newline* - (indent js!rest " = {car: arguments[i+2], cdr: " js!rest "};" *newline*)))))) + (code js!rest " = {car: arguments[i+2], cdr: " js!rest "};" *newline*)))))) (defun compile-lambda-parse-keywords (ll) (let ((n-required-arguments @@ -348,20 +319,20 @@ ;; ((keyword-name var) init-form) (code "for (i=" (+ n-required-arguments n-optional-arguments) "; i