Commit | Line | Data |
---|---|---|
691697de | 1 | ;;; Bytecode |
43f768f4 AW |
2 | |
3 | ;; Copyright (C) 2013 Free Software Foundation, Inc. | |
4 | ||
5 | ;;;; This library is free software; you can redistribute it and/or | |
6 | ;;;; modify it under the terms of the GNU Lesser General Public | |
7 | ;;;; License as published by the Free Software Foundation; either | |
8 | ;;;; version 3 of the License, or (at your option) any later version. | |
9 | ;;;; | |
10 | ;;;; This library is distributed in the hope that it will be useful, | |
11 | ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | ;;;; Lesser General Public License for more details. | |
14 | ;;;; | |
15 | ;;;; You should have received a copy of the GNU Lesser General Public | |
16 | ;;;; License along with this library; if not, write to the Free Software | |
17 | ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
18 | ||
19 | ;;; Code: | |
20 | ||
691697de | 21 | (define-module (language bytecode spec) |
43f768f4 | 22 | #:use-module (system base language) |
4cbc95f1 | 23 | #:use-module (system vm loader) |
43f768f4 | 24 | #:use-module (ice-9 binary-ports) |
691697de | 25 | #:export (bytecode)) |
43f768f4 | 26 | |
691697de | 27 | (define (bytecode->value x e opts) |
b73a2ee0 AW |
28 | (let ((thunk (load-thunk-from-memory x))) |
29 | (if (eq? e (current-module)) | |
30 | ;; save a cons in this case | |
31 | (values (thunk) e e) | |
32 | (save-module-excursion | |
33 | (lambda () | |
34 | (set-current-module e) | |
35 | (values (thunk) e e)))))) | |
36 | ||
691697de AW |
37 | (define-language bytecode |
38 | #:title "Bytecode" | |
39 | #:compilers `((value . ,bytecode->value)) | |
40 | #:printer (lambda (bytecode port) (put-bytevector port bytecode)) | |
43f768f4 AW |
41 | #:reader get-bytevector-all |
42 | #:for-humans? #f) |