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 * ** ***
53 *gensym-counter* *package* *features*
55 + ++ +++ - / // /// 1+ 1- < <= = = > >=
57 acons adjoin and append apply aref
58 arrayp assoc atom block boundp butlast cadar caaar caadr cdaar cdadr
59 cddar caaaar caaadr caadar caaddr cadaar cadadr caddar cdaaar
60 cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr caar cadddr caddr
61 cadr car car case catch cdar cdddr cddr cdr cdr char
62 char-code char= code-char cond cons consp constantly
63 copy-alist copy-list copy-tree decf declaim declare defconstant
64 define-setf-expander define-symbol-macro defmacro defparameter defun
65 defvar destructuring-bind digit-char digit-char-p disassemble do do* documentation
66 dolist dotimes ecase eighth eq eql equal error eval every export expt
67 fdefinition fifth find-package find find-symbol first flet format fourth
68 fset funcall function functionp gensym get-internal-real-time
69 get-setf-expansion get-universal-time go identity if in-package
70 incf integerp intern intersection keywordp labels lambda last length
71 let let* list list* list-all-packages listp loop make-array
72 make-package make-symbol mapcar member minusp mod multiple-value-bind
73 multiple-value-call multiple-value-list multiple-value-prog1
74 nconc nil ninth not nreconc nth nthcdr null numberp or otherwise
75 package-name package-use-list packagep pairlis parse-integer plusp
76 pop prin1-to-string print proclaim prog prog1 prog2 progn psetq push
77 quote rassoc read-from-string remove remove-if remove-if-not return
78 return-from revappend reverse rplaca rplacd second set setf seventh
79 setq sixth some string string-upcase string= stringp subseq subst
80 symbol-function symbol-name symbol-package symbol-plist
81 symbol-value symbolp t tagbody tailp tenth third throw tree-equal
82 truncate unless unwind-protect values values-list variable vector-push-extend warn when
83 write-line write-string zerop))
85 (setq *package* *user-package*)
87 ;;; Set some external entry point to the Lisp implementation to the
88 ;;; console. It would not be necessary when FFI is finished.
90 (%js-vset "lisp" (new))
91 (%js-vset "lisp.read" #'ls-read-from-string)
92 (%js-vset "lisp.print" #'prin1-to-string)
93 (%js-vset "lisp.eval" #'eval)
94 (%js-vset "lisp.compile" (lambda (s) (ls-compile-toplevel s t)))
95 (%js-vset "lisp.evalString" (lambda (str) (eval (ls-read-from-string str))))
96 (%js-vset "lisp.evalInput" (lambda (str) (eval-interactive (ls-read-from-string str))))
97 (%js-vset "lisp.compileString" (lambda (str) (ls-compile-toplevel (ls-read-from-string str) t)))