Eliminate non-hygienic macros.
authorChris Hanson <org/chris-hanson/cph>
Thu, 7 Feb 2002 05:58:14 +0000 (05:58 +0000)
committerChris Hanson <org/chris-hanson/cph>
Thu, 7 Feb 2002 05:58:14 +0000 (05:58 +0000)
v7/src/compiler/back/asmmac.scm
v7/src/compiler/back/lapgn3.scm
v7/src/compiler/base/crsend.scm
v7/src/compiler/base/lvalue.scm

index 2668e9445780ec7c26e335790954af39a2e35153..84175aa7b263baf4f00cf20140c6ddb744070ce7 100644 (file)
@@ -1,8 +1,8 @@
 #| -*-Scheme-*-
 
-$Id: asmmac.scm,v 1.10 2001/12/23 17:20:57 cph Exp $
+$Id: asmmac.scm,v 1.11 2002/02/07 05:57:44 cph Exp $
 
-Copyright (c) 1988, 1990, 1999, 2001 Massachusetts Institute of Technology
+Copyright (c) 1988, 1990, 1999, 2001, 2002 Massachusetts Institute of Technology
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -25,16 +25,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 (declare (usual-integrations))
 \f
 (define-syntax define-instruction
-  (non-hygienic-macro-transformer
-   (lambda (keyword . rules)
-     `(ADD-INSTRUCTION!
-       ',keyword
-       ,(compile-database rules
-         (lambda (pattern actions)
-           pattern
-           (if (not (pair? actions))
-               (error "DEFINE-INSTRUCTION: Too few forms."))
-           (parse-instruction (car actions) (cdr actions) #f)))))))
+  (sc-macro-transformer
+   (lambda (form environment)
+     (if (syntax-match? '(SYMBOL * DATUM) (cdr form))
+        `(ADD-INSTRUCTION!
+          ',(cadr form)
+          ,(compile-database (cddr form)
+             (lambda (pattern actions)
+               pattern
+               (if (not (pair? actions))
+                   (error "DEFINE-INSTRUCTION: Too few forms."))
+               (parse-instruction (car actions) (cdr actions) #f))))
+        (ill-formed-syntax form)))))
 
 (define (compile-database cases procedure)
   `(LIST
index 6c4a298785da6451a734311cd5a05f686ac8fe9d..5e51e77462fd886a2e0e9164fff04152de2b7346 100644 (file)
@@ -1,8 +1,8 @@
 #| -*-Scheme-*-
 
-$Id: lapgn3.scm,v 4.14 2001/12/23 17:20:57 cph Exp $
+$Id: lapgn3.scm,v 4.15 2002/02/07 05:57:54 cph Exp $
 
-Copyright (c) 1987-1999, 2001 Massachusetts Institute of Technology
+Copyright (c) 1987-1999, 2001, 2002 Massachusetts Institute of Technology
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -39,54 +39,58 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
   (let ((label
         (string->uninterned-symbol
          (string-append prefix (number->string *next-constant*)))))
-    (set! *next-constant* (1+ *next-constant*))
+    (set! *next-constant* (+ *next-constant* 1))
     label))
 
 (define (allocate-constant-label)
   (allocate-named-label "CONSTANT-"))
 
 (define (warning-assoc obj pairs)
-  (define (local-eqv? obj1 obj2)
-    (or (eqv? obj1 obj2)
-       (and (string? obj1)
-            (string? obj2)
-            (zero? (string-length obj1))
-            (zero? (string-length obj2)))))
-
   (let ((pair (assoc obj pairs)))
     (if (and compiler:coalescing-constant-warnings?
             (pair? pair)
-            (not (local-eqv? obj (car pair))))
+            (not (let ((obj* (car pair)))
+                   (or (eqv? obj obj*)
+                       (and (string? obj)
+                            (string? obj*)
+                            (fix:= 0 (string-length obj))
+                            (fix:= 0 (string-length obj*)))))))
        (warn "Coalescing two copies of constant object" obj))
     pair))
 
-(define-integrable (object->label find read write allocate-label)
-  (lambda (object)
-    (let ((entry (find object (read))))
-      (if entry
-         (cdr entry)
-         (let ((label (allocate-label object)))
-           (write (cons (cons object label)
-                        (read)))
-           label)))))
+(define ((object->label find read write allocate-label) object)
+  (let ((entry (find object (read))))
+    (if entry
+       (cdr entry)
+       (let ((label (allocate-label object)))
+         (write (cons (cons object label) (read)))
+         label))))
 
 (let-syntax
     ((->label
-      (non-hygienic-macro-transformer
-       (lambda (find var #!optional suffix)
-        `(object->label ,find
-                        (lambda () ,var)
-                        (lambda (new)
-                          (declare (integrate new))
-                          (set! ,var new))
-                        ,(if (default-object? suffix)
-                             `(lambda (object)
-                                object ; ignore
-                                (allocate-named-label "OBJECT-"))
-                             `(lambda (object)
-                                (allocate-named-label
-                                 (string-append (symbol->string object)
-                                                ,suffix)))))))))
+      (sc-macro-transformer
+       (let ((pattern `(EXPRESSION IDENTIFIER ? ,string?)))
+        (lambda (form environment)
+          (if (syntax-match? pattern (cdr form))
+              (let ((find (close-syntax (cadr form) environment))
+                    (var (close-syntax (caddr form) environment))
+                    (suffix (and (pair? (cdddr form)) (cadddr form))))
+                `(OBJECT->LABEL ,find
+                                (LAMBDA () ,var)
+                                (LAMBDA (NEW)
+                                  (DECLARE (INTEGRATE NEW))
+                                  (SET! ,var NEW))
+                                ,(if suffix
+                                     `(LAMBDA (OBJECT)
+                                        (ALLOCATE-NAMED-LABEL
+                                         (STRING-APPEND
+                                          (SYMBOL->STRING OBJECT)
+                                          ,suffix)))
+                                     `(LAMBDA (OBJECT)
+                                        OBJECT ; ignore
+                                        (ALLOCATE-NAMED-LABEL "OBJECT-")))))
+              (ill-formed-syntax form)))))))
+
 (define constant->label
   (->label warning-assoc *interned-constants*))
 
@@ -99,7 +103,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 (define free-static-label
   (->label assq *interned-static-variables* "-HOME-"))
 
-;; End of let-syntax
 )
 \f
 ;; These are different because different uuo-links are used for different
index 5d17fb7d49ee59f083713b30814fc66f0a0f9e61..fa44299fb5152ee5ca8d700b0a22c9e9a16a1b49 100644 (file)
@@ -1,8 +1,8 @@
 #| -*-Scheme-*-
 
-$Id: crsend.scm,v 1.12 2001/12/23 17:20:57 cph Exp $
+$Id: crsend.scm,v 1.13 2002/02/07 05:58:04 cph Exp $
 
-Copyright (c) 1988-1999, 2001 Massachusetts Institute of Technology
+Copyright (c) 1988-1999, 2001, 2002 Massachusetts Institute of Technology
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -26,6 +26,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
 (declare (usual-integrations))
 \f
+(define-syntax ucode-primitive
+  (sc-macro-transformer
+   (lambda (form environment)
+     environment
+     (apply make-primitive-procedure (cdr form)))))
+
+(define-syntax ucode-type
+  (sc-macro-transformer
+   (lambda (form environment)
+     environment
+     (apply microcode-type (cdr form)))))
+
 (define (cross-compile-bin-file-end input-string #!optional output-string)
   (compiler-pathnames input-string
                      (and (not (default-object? output-string)) output-string)
@@ -118,20 +130,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
                   label
                   (with-absolutely-no-interrupts
                     (lambda ()
-                      (let-syntax ((ucode-primitive
-                                    (non-hygienic-macro-transformer
-                                     (lambda (name)
-                                       (make-primitive-procedure name))))
-                                   (ucode-type
-                                    (non-hygienic-macro-transformer
-                                     (lambda (name)
-                                       (microcode-type name)))))
-                        ((ucode-primitive PRIMITIVE-OBJECT-SET-TYPE)
-                         (ucode-type COMPILED-ENTRY)
-                         (make-non-pointer-object
-                          (+ (cdr (or (assq label label-bindings)
-                                      (error "Missing entry point" label)))
-                             (object-datum code-vector)))))))))
+                      ((ucode-primitive primitive-object-set-type)
+                       (ucode-type compiled-entry)
+                       (make-non-pointer-object
+                        (+ (cdr (or (assq label label-bindings)
+                                    (error "Missing entry point" label)))
+                           (object-datum code-vector))))))))
                (cc-vector/entry-points cc-vector)))))
     (let ((label->expression
           (lambda (label)
@@ -145,32 +149,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
        expression))))
 \f
 (define (cross-link/finish-assembly code-block objects scheme-object-width)
-  (let-syntax ((ucode-primitive
-               (non-hygienic-macro-transformer
-                (lambda (name)
-                  (make-primitive-procedure name))))
-              (ucode-type
-               (non-hygienic-macro-transformer
-                (lambda (name)
-                  (microcode-type name)))))
-    (let* ((bl (quotient (bit-string-length code-block)
-                        scheme-object-width))
-          (non-pointer-length
-           ((ucode-primitive make-non-pointer-object) bl))
-          (output-block (make-vector (1+ (+ (length objects) bl)))))
-      (with-absolutely-no-interrupts
-       (lambda ()
-         (vector-set! output-block 0
-                      ((ucode-primitive primitive-object-set-type)
-                       (ucode-type manifest-nm-vector)
-                       non-pointer-length))))
-      (write-bits! output-block
-                  ;; After header just inserted.
-                  (* scheme-object-width 2)
-                  code-block)
-      (insert-objects! output-block objects (1+ bl))
-      (object-new-type (ucode-type compiled-code-block)
-                      output-block))))
+  (let* ((bl (quotient (bit-string-length code-block)
+                      scheme-object-width))
+        (non-pointer-length
+         ((ucode-primitive make-non-pointer-object) bl))
+        (output-block (make-vector (1+ (+ (length objects) bl)))))
+    (with-absolutely-no-interrupts
+      (lambda ()
+       (vector-set! output-block 0
+                    ((ucode-primitive primitive-object-set-type)
+                     (ucode-type manifest-nm-vector)
+                     non-pointer-length))))
+    (write-bits! output-block
+                ;; After header just inserted.
+                (* scheme-object-width 2)
+                code-block)
+    (insert-objects! output-block objects (1+ bl))
+    (object-new-type (ucode-type compiled-code-block)
+                    output-block)))
 
 (define (insert-objects! v objects where)
   (cond ((not (null? objects))
index cb620507f70c05f2055b2bc6d8f93c0b0edeb38b..8b27c9d8ec60af6dd56a7d1e6d28627845adcf55 100644 (file)
@@ -1,8 +1,8 @@
 #| -*-Scheme-*-
 
-$Id: lvalue.scm,v 4.24 2001/12/23 17:20:57 cph Exp $
+$Id: lvalue.scm,v 4.25 2002/02/07 05:58:14 cph Exp $
 
-Copyright (c) 1988-1990, 1999, 2001 Massachusetts Institute of Technology
+Copyright (c) 1988-1990, 1999, 2001, 2002 Massachusetts Institute of Technology
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -103,10 +103,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
 (let-syntax
     ((define-named-variable
-      (non-hygienic-macro-transformer
-       (lambda (name)
-        (let ((symbol
-               (intern (string-append "#[" (symbol->string name) "]"))))
+      (sc-macro-transformer
+       (lambda (form environment)
+        environment
+        (let* ((name (cadr form))
+               (symbol
+                (intern (string-append "#[" (symbol->string name) "]"))))
           `(BEGIN (DEFINE-INTEGRABLE
                     (,(symbol-append 'MAKE- name '-VARIABLE) BLOCK)
                     (MAKE-VARIABLE BLOCK ',symbol))