From 24ccbdeee987c9e08653acf198f708017913100d Mon Sep 17 00:00:00 2001 From: David Vazquez Date: Wed, 23 Jan 2013 23:49:00 +0000 Subject: [PATCH] Create a first parameter VALUES (unused by now) in each function and each funcall --- ecmalisp.html | 8 ++++---- ecmalisp.lisp | 21 +++++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/ecmalisp.html b/ecmalisp.html index 378eb99..9610883 100644 --- a/ecmalisp.html +++ b/ecmalisp.html @@ -77,23 +77,23 @@ var startPrompt = function () { // Start the prompt with history enabled. - jqconsole.Write(lisp.evalString('(CL:PACKAGE-NAME CL:*PACKAGE*)') + '> ', 'jqconsole-prompt'); + jqconsole.Write(lisp.evalString(id, '(CL:PACKAGE-NAME CL:*PACKAGE*)') + '> ', 'jqconsole-prompt'); jqconsole.Prompt(true, function (input) { // Output input with the class jqconsole-return. if (input[0] != ','){ try { - jqconsole.Write(lisp.print(lisp.evalString(input)) + '\n', 'jqconsole-return'); + jqconsole.Write(lisp.print(id, lisp.evalString(id, input)) + '\n', 'jqconsole-return'); } catch(error) { jqconsole.Write('ERROR: ' + (error.message || error) + '\n', 'jqconsole-error'); } } else { - jqconsole.Write(lisp.compileString(input.slice(1)) + '\n', 'jqconsole-return'); + jqconsole.Write(lisp.compileString(id, input.slice(1)) + '\n', 'jqconsole-return'); } // Restart the prompt. startPrompt(); }, function(input){ try { - lisp.read(input[0]==','? input.slice(1): input); + lisp.read(id, input[0]==','? input.slice(1): input); } catch(error) { return 0; } diff --git a/ecmalisp.lisp b/ecmalisp.lisp index a6a0948..6a7e019 100644 --- a/ecmalisp.lisp +++ b/ecmalisp.lisp @@ -1148,24 +1148,25 @@ (lambda-docstring-wrapper documentation "(function (" - (join (mapcar #'translate-variable - (append required-arguments optional-arguments)) + (join (cons "values" + (mapcar #'translate-variable + (append required-arguments optional-arguments))) ",") "){" *newline* ;; Check number of arguments (indent (if required-arguments - (concat "if (arguments.length < " (integer-to-string n-required-arguments) + (concat "if (arguments.length < " (integer-to-string (1+ n-required-arguments)) ") throw 'too few arguments';" *newline*) "") (if (not rest-argument) (concat "if (arguments.length > " - (integer-to-string (+ n-required-arguments n-optional-arguments)) + (integer-to-string (+ 1 n-required-arguments n-optional-arguments)) ") throw 'too many arguments';" *newline*) "") ;; Optional arguments (if optional-arguments - (concat "switch(arguments.length){" *newline* + (concat "switch(arguments.length-1){" *newline* (let ((optional-and-defaults (lambda-list-optional-arguments-with-default lambda-list)) (cases nil) @@ -1190,7 +1191,7 @@ (let ((js!rest (translate-variable rest-argument))) (concat "var " js!rest "= " (ls-compile nil) ";" *newline* "for (var i = arguments.length-1; i>=" - (integer-to-string (+ n-required-arguments n-optional-arguments)) + (integer-to-string (+ 1 n-required-arguments n-optional-arguments)) "; i--)" *newline* (indent js!rest " = " "{car: arguments[i], cdr: ") js!rest "};" @@ -1824,7 +1825,7 @@ (define-raw-builtin funcall (func &rest args) (concat "(" (ls-compile func) ")(" - (join (mapcar #'ls-compile args) + (join (cons "id" (mapcar #'ls-compile args)) ", ") ")")) @@ -1835,7 +1836,7 @@ (last (car (last args)))) (js!selfcall "var f = " (ls-compile func) ";" *newline* - "var args = [" (join (mapcar #'ls-compile args) + "var args = [" (join (cons "id" (mapcar #'ls-compile args)) ", ") "];" *newline* "var tail = (" (ls-compile last) ");" *newline* @@ -1933,11 +1934,11 @@ (if (and (symbolp function) (claimp function 'function 'non-overridable)) (concat (ls-compile `',function) ".fvalue(" - (join (mapcar #'ls-compile args) + (join (cons "id" (mapcar #'ls-compile args)) ", ") ")") (concat (ls-compile `#',function) "(" - (join (mapcar #'ls-compile args) + (join (cons "id" (mapcar #'ls-compile args)) ", ") ")"))) -- 1.7.10.4