3 ;; Copyright (C) 2012, 2013 David Vazquez
4 ;; Copyright (C) 2012 Raimon Grau
6 ;; JSCL is free software: you can redistribute it and/or
7 ;; modify it under the terms of the GNU General Public License as
8 ;; published by the Free Software Foundation, either version 3 of the
9 ;; License, or (at your option) any later version.
11 ;; JSCL is distributed in the hope that it will be useful, but
12 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ;; General Public License for more details.
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with JSCL. If not, see <http://www.gnu.org/licenses/>.
21 (js-eval (ls-compile-toplevel x t)))
34 (defun eval-interactive (x)
36 (let ((results (multiple-value-list (eval x))))
44 ;; FIXME: Handle error
51 (export '(&body &key &optional &rest * ** *** *features* *gensym-counter*
52 *package* *print-circle* + ++ +++ - / // /// 1+ 1- < <= = = > >= acons
53 adjoin alpha-char-p and append apply aref arrayp assoc atom block
54 boundp butlast caaaar caaadr caaar caadar caaddr caadr caar cadaar
55 cadadr cadar caddar cadddr caddr cadr car car case catch cdaaar
56 cdaadr cdaar cdadar cdaddr cdadr cdar cddaar cddadr cddar cdddar
57 cddddr cdddr cddr cdr cdr char char-code char= code-char complement
58 cond cons consp constantly copy-alist copy-list copy-tree decf declaim
59 declare defconstant define-setf-expander define-symbol-macro defmacro
60 defparameter defun defvar destructuring-bind digit-char digit-char-p
61 disassemble do do* documentation dolist dotimes do-all-symbols
62 do-external-symbols do-symbols ecase eighth eq eql
63 equal error eval every export expt fdefinition fifth find find-all-symbols
64 find-package find-symbol first flet format fourth fboundp fset funcall
65 function functionp gensym get-internal-real-time get-setf-expansion
66 get-universal-time go identity if in-package incf integerp intern
67 intersection keywordp labels lambda last length let let*
68 lisp-implementation-type list list* list-all-packages listp loop
69 make-array make-package make-symbol mapc mapcar member minusp mod
70 multiple-value-bind multiple-value-call multiple-value-list
71 multiple-value-prog1 nconc nil ninth not nreconc nth nthcdr null
72 numberp or otherwise package-name package-use-list packagep pairlis
73 parse-integer plusp pop prin1-to-string print proclaim prog prog1
74 prog2 progn psetq push pushnew quote rassoc read-from-string remove remove-if
75 remove-if-not return return-from revappend reverse rplaca rplacd
76 second set setf setq seventh sixth some string string-upcase string=
77 string< stringp subseq subst symbol-function symbol-name symbol-package
78 symbol-plist symbol-value symbolp t tagbody tailp tenth third throw
79 time trace tree-equal truncate unless untrace unwind-protect values
80 values-list variable vector-push-extend warn when write-line write-string
83 (setq *package* *user-package*)
85 ;;; Set some external entry point to the Lisp implementation to the
86 ;;; console. It would not be necessary when FFI is finished.
88 (%js-vset "lisp" (new))
89 (%js-vset "lisp.read" #'ls-read-from-string)
90 (%js-vset "lisp.print" #'prin1-to-string)
91 (%js-vset "lisp.eval" #'eval)
92 (%js-vset "lisp.compile" (lambda (s) (ls-compile-toplevel s t)))
93 (%js-vset "lisp.evalString" (lambda (str) (eval (ls-read-from-string str))))
94 (%js-vset "lisp.evalInput" (lambda (str) (eval-interactive (ls-read-from-string str))))
95 (%js-vset "lisp.compileString" (lambda (str) (ls-compile-toplevel (ls-read-from-string str) t)))