From c296885ca974898925b89af066b1b14a6fca0f57 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Fri, 21 Jun 2013 17:16:49 +0200 Subject: [PATCH 1/1] Add debugging information --- src/array.lisp | 2 ++ src/backquote.lisp | 2 ++ src/boot.lisp | 2 ++ src/char.lisp | 2 ++ src/compat.lisp | 3 +++ src/compiler-codegen.lisp | 2 ++ src/compiler.lisp | 12 ++++++++---- src/defstruct.lisp | 2 ++ src/ffi.lisp | 2 ++ src/lambda-list.lisp | 3 +++ src/list.lisp | 2 ++ src/misc.lisp | 2 ++ src/numbers.lisp | 2 ++ src/package.lisp | 2 ++ src/print.lisp | 2 ++ src/read.lisp | 1 + src/sequence.lisp | 2 ++ src/stream.lisp | 2 ++ src/string.lisp | 2 ++ src/toplevel.lisp | 1 + src/utils.lisp | 2 ++ 21 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/array.lisp b/src/array.lisp index 20912c2..a15b4eb 100644 --- a/src/array.lisp +++ b/src/array.lisp @@ -13,6 +13,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with JSCL. If not, see . +(/debug "loading array.lisp!") + (defun upgraded-array-element-type (typespec &optional environment) (declare (ignore environment)) (if (eq typespec 'character) diff --git a/src/backquote.lisp b/src/backquote.lisp index 97da02f..3db0388 100644 --- a/src/backquote.lisp +++ b/src/backquote.lisp @@ -13,6 +13,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with JSCL. If not, see . +(/debug "loading backquote.lisp!") + ;;; Backquote implementation. ;;; ;;; Author: Guy L. Steele Jr. Date: 27 December 1985 diff --git a/src/boot.lisp b/src/boot.lisp index 9b8a2e0..d045186 100644 --- a/src/boot.lisp +++ b/src/boot.lisp @@ -22,6 +22,8 @@ ;;; Lisp world from scratch. This code has to define enough language ;;; to the compiler to be able to run. +(/debug "loading boot.lisp!") + (eval-when-compile (let ((defmacro-macroexpander '#'(lambda (form) diff --git a/src/char.lisp b/src/char.lisp index 08ca9d1..cad81a2 100644 --- a/src/char.lisp +++ b/src/char.lisp @@ -1,3 +1,5 @@ +(/debug "loading char.lisp!") + ;; These comparison functions heavily borrowed from SBCL/CMUCL (public domain). (defun char= (character &rest more-characters) diff --git a/src/compat.lisp b/src/compat.lisp index 3eaf4ff..d682604 100644 --- a/src/compat.lisp +++ b/src/compat.lisp @@ -44,3 +44,6 @@ (eval-when-compile (defun concat (&rest strs) (apply #'concatenate 'string strs))) + +(defun /debug (x) + (write-line x)) diff --git a/src/compiler-codegen.lisp b/src/compiler-codegen.lisp index 2d8f11d..50f33af 100644 --- a/src/compiler-codegen.lisp +++ b/src/compiler-codegen.lisp @@ -22,6 +22,8 @@ ;;; It is intended to be used with the new compiler. However, it is ;;; quite independent so it has been integrated early in JSCL. +(/debug "loading compiler-codegen.lisp!") + (defvar *js-output* t) ;;; Two seperate functions are needed for escaping strings: diff --git a/src/compiler.lisp b/src/compiler.lisp index 3b3d0c9..44ccbe7 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -18,6 +18,8 @@ ;;;; Compiler +(/debug "loading compiler.lisp!") + ;;; Translate the Lisp code to Javascript. It will compile the special ;;; forms. Some primitive functions are compiled as special forms ;;; too. The respective real functions are defined in the target (see @@ -933,8 +935,8 @@ ,@(mapcar (lambda (form) `(code "vs = " ,(ls-compile form t) ";" "if (typeof vs === 'object' && 'multiple-value' in vs)" - (code "args = args.concat(vs);" ) - "else" + (code " args = args.concat(vs);" ) + " else " (code "args.push(vs);" ))) forms)) "args[1] = args.length-2;" @@ -1006,8 +1008,7 @@ (t (let ((v (format nil "x~d" (incf counter)))) (push v fargs) (push `(code "var " ,v " = " ,(ls-compile x) ";" - "if (typeof " v " !== 'number') throw 'Not a number!';" - ) + "if (typeof " ,v " !== 'number') throw 'Not a number!';") prelude))))) (js!selfcall `(code ,@(reverse prelude)) @@ -1243,6 +1244,9 @@ (define-builtin %write-string (x) `(code "lisp.write(" ,x ")")) +(define-builtin /debug (x) + `(code "console.log(xstring(" ,x "))")) + ;;; Storage vectors. They are used to implement arrays and (in the ;;; future) structures. diff --git a/src/defstruct.lisp b/src/defstruct.lisp index 1872585..7de9c81 100644 --- a/src/defstruct.lisp +++ b/src/defstruct.lisp @@ -13,6 +13,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with JSCL. If not, see . +(/debug "loading defstruct.lisp!") + ;; A very simple defstruct built on lists. It supports just slot with ;; an optional default initform, and it will create a constructor, ;; predicate and accessors for you. diff --git a/src/ffi.lisp b/src/ffi.lisp index be5048a..db6a23e 100644 --- a/src/ffi.lisp +++ b/src/ffi.lisp @@ -13,6 +13,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with JSCL. If not, see . +(/debug "loading ffi.lisp!") + (define-setf-expander oget (object key &rest keys) (let* ((keys (cons key keys)) (g!object (gensym)) diff --git a/src/lambda-list.lisp b/src/lambda-list.lisp index 19cc98d..1a0a6eb 100644 --- a/src/lambda-list.lisp +++ b/src/lambda-list.lisp @@ -15,6 +15,9 @@ ;; You should have received a copy of the GNU General Public License ;; along with JSCL. If not, see . +(/debug "loading lambda-list.lisp!") + + (defvar !lambda-list-keywords '(&optional &rest &key &aux &allow-other-keys &body &optional)) diff --git a/src/list.lisp b/src/list.lisp index ad0e7a6..3726f7c 100644 --- a/src/list.lisp +++ b/src/list.lisp @@ -13,6 +13,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with JSCL. If not, see . +(/debug "loading list.lisp!") + ;;;; Various list functions (defun cons (x y) (cons x y)) diff --git a/src/misc.lisp b/src/misc.lisp index 3f4c5de..a040067 100644 --- a/src/misc.lisp +++ b/src/misc.lisp @@ -13,6 +13,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with JSCL. If not, see . +(/debug "loading misc.lisp!") + (defparameter *features* '(:jscl :common-lisp)) (defun lisp-implementation-type () diff --git a/src/numbers.lisp b/src/numbers.lisp index 578d0b1..f5dee9a 100644 --- a/src/numbers.lisp +++ b/src/numbers.lisp @@ -13,6 +13,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with JSCL. If not, see . +(/debug "loading numbers.lisp!") + ;;;; Various numeric functions and constants (macrolet ((def (operator initial-value) diff --git a/src/package.lisp b/src/package.lisp index ebbd6bf..317ab41 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -13,6 +13,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with JSCL. If not, see . +(/debug "loading package.lisp!") + (defvar *package-list* nil) (defun list-all-packages () diff --git a/src/print.lisp b/src/print.lisp index 48af786..a8ac834 100644 --- a/src/print.lisp +++ b/src/print.lisp @@ -16,6 +16,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with JSCL. If not, see . +(/debug "loading print.lisp!") + ;;; Printer (defun lisp-escape-string (string) diff --git a/src/read.lisp b/src/read.lisp index 59838d7..6e9eb68 100644 --- a/src/read.lisp +++ b/src/read.lisp @@ -16,6 +16,7 @@ ;; You should have received a copy of the GNU General Public License ;; along with JSCL. If not, see . +(/debug "loading read.lisp!") ;;;; Reader diff --git a/src/sequence.lisp b/src/sequence.lisp index 8b3708b..be36e99 100644 --- a/src/sequence.lisp +++ b/src/sequence.lisp @@ -13,6 +13,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with JSCL. If not, see . +(/debug "loading sequence.lisp!") + (defun not-seq-error (thing) (error "`~S' is not of type SEQUENCE" thing)) diff --git a/src/stream.lisp b/src/stream.lisp index b563338..086b145 100644 --- a/src/stream.lisp +++ b/src/stream.lisp @@ -19,6 +19,8 @@ ;;; TODO: Use structures to represent streams, but we would need ;;; inheritance. +(/debug "loading stream.lisp!") + (defvar *standard-output* (vector 'stream (lambda (ch) (%write-string (string ch))) diff --git a/src/string.lisp b/src/string.lisp index 1a27867..8aba28e 100644 --- a/src/string.lisp +++ b/src/string.lisp @@ -13,6 +13,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with JSCL. If not, see . +(/debug "loading string.lisp!") + (defun stringp (s) (stringp s)) diff --git a/src/toplevel.lisp b/src/toplevel.lisp index 497d4a0..99d3b39 100644 --- a/src/toplevel.lisp +++ b/src/toplevel.lisp @@ -16,6 +16,7 @@ ;; You should have received a copy of the GNU General Public License ;; along with JSCL. If not, see . +(/debug "loading toplevel.lisp!") (defun eval (x) (js-eval (ls-compile-toplevel x t))) diff --git a/src/utils.lisp b/src/utils.lisp index aa097af..5cb702c 100644 --- a/src/utils.lisp +++ b/src/utils.lisp @@ -16,6 +16,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with JSCL. If not, see . +(/debug "loading utils.lisp!") + (defvar *newline* " ") -- 1.7.10.4