| 1 |
;;; Ikarus Scheme -- A compiler for R6RS Scheme. |
| 2 |
;;; Copyright (C) 2006,2007,2008 Abdulaziz Ghuloum |
| 3 |
;;; |
| 4 |
;;; This program is free software: you can redistribute it and/or modify |
| 5 |
;;; it under the terms of the GNU General Public License version 3 as |
| 6 |
;;; published by the Free Software Foundation. |
| 7 |
;;; |
| 8 |
;;; This program is distributed in the hope that it will be useful, but |
| 9 |
;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
;;; General Public License for more details. |
| 12 |
;;; |
| 13 |
;;; You should have received a copy of the GNU General Public License |
| 14 |
;;; along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
|
| 16 |
|
| 17 |
(library (psyntax compat) |
| 18 |
(export define-record make-parameter parameterize format gensym |
| 19 |
eval-core symbol-value set-symbol-value! |
| 20 |
make-struct-type read-annotated |
| 21 |
annotation? annotation-expression annotation-source |
| 22 |
annotation-stripped |
| 23 |
read-library-source-file |
| 24 |
library-version-mismatch-warning |
| 25 |
library-stale-warning |
| 26 |
file-locator-resolution-error |
| 27 |
label-binding set-label-binding! remove-location |
| 28 |
make-source-position-condition) |
| 29 |
(import |
| 30 |
(only (ikarus.compiler) eval-core) |
| 31 |
(only (ikarus.reader.annotated) read-library-source-file) |
| 32 |
(ikarus)) |
| 33 |
|
| 34 |
(define (library-version-mismatch-warning name depname filename) |
| 35 |
(fprintf (current-error-port) |
| 36 |
"WARNING: library ~s has an inconsistent dependency \ |
| 37 |
on library ~s; file ~s will be recompiled from \ |
| 38 |
source.\n" |
| 39 |
name depname filename)) |
| 40 |
|
| 41 |
(define (library-stale-warning name filename) |
| 42 |
(fprintf (current-error-port) |
| 43 |
"WARNING: library ~s is stale; file ~s will be recompiled from source.\n" |
| 44 |
name filename)) |
| 45 |
|
| 46 |
(define (file-locator-resolution-error libname failed-list pending-list) |
| 47 |
(define-condition-type &library-resolution &condition |
| 48 |
make-library-resolution-condition |
| 49 |
library-resolution-condition? |
| 50 |
(library condition-library) |
| 51 |
(files condition-files)) |
| 52 |
(define-condition-type &imported-from &condition |
| 53 |
make-imported-from-condition imported-from-condition? |
| 54 |
(importing-library importing-library)) |
| 55 |
|
| 56 |
(raise |
| 57 |
(apply condition (make-error) |
| 58 |
(make-who-condition 'expander) |
| 59 |
(make-message-condition |
| 60 |
"cannot locate library in library-path") |
| 61 |
(make-library-resolution-condition |
| 62 |
libname failed-list) |
| 63 |
(map make-imported-from-condition pending-list)))) |
| 64 |
|
| 65 |
(define-syntax define-record |
| 66 |
(syntax-rules () |
| 67 |
[(_ name (field* ...) printer) |
| 68 |
(begin |
| 69 |
(define-struct name (field* ...)) |
| 70 |
(module () |
| 71 |
(set-rtd-printer! (type-descriptor name) |
| 72 |
printer)))] |
| 73 |
[(_ name (field* ...)) |
| 74 |
(define-struct name (field* ...))])) |
| 75 |
|
| 76 |
(define (set-label-binding! label binding) |
| 77 |
(set-symbol-value! label binding)) |
| 78 |
|
| 79 |
(define (label-binding label) |
| 80 |
(and (symbol-bound? label) (symbol-value label))) |
| 81 |
|
| 82 |
(define (remove-location x) |
| 83 |
(import (ikarus system $symbols)) |
| 84 |
($unintern-gensym x))) |
| 85 |
|