home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mitsch75.zip / scheme-7_5_17-src.zip / scheme-7.5.17 / src / compiler / back / insseq.scm < prev    next >
Encoding:
Text File  |  1999-01-02  |  1.8 KB  |  58 lines

  1. #| -*-Scheme-*-
  2.  
  3. $Id: insseq.scm,v 4.4 1999/01/02 06:06:43 cph Exp $
  4.  
  5. Copyright (c) 1987, 1988, 1990, 1999 Massachusetts Institute of Technology
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or (at
  10. your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. |#
  21.  
  22. ;;;; Lap instruction sequences
  23.  
  24. (declare (usual-integrations))
  25.  
  26. (define (instruction-sequence->directives instruction-sequence)
  27.   (if (null? instruction-sequence)
  28.       '()
  29.       (car instruction-sequence)))
  30.  
  31. (define empty-instruction-sequence
  32.   '())
  33.  
  34. (define (directive->instruction-sequence directive)
  35.   (let ((pair (cons directive '())))
  36.     (cons pair pair)))
  37.  
  38. (define (instruction->instruction-sequence directives)
  39.   ;; This procedure is expanded in the syntaxer.  See "syerly".
  40.   (cons directives (last-pair directives)))
  41.  
  42. (define (copy-instruction-sequence instruction-sequence)
  43.   (if (null? instruction-sequence)
  44.       '()
  45.       (let with-last-pair ((l (car instruction-sequence)) (receiver cons))
  46.     (if (null? (cdr l))
  47.         (receiver l l)
  48.         (with-last-pair (cdr l)
  49.           (lambda (rest last)
  50.         (receiver (cons (car l) rest) last)))))))
  51.  
  52. (define (append-instruction-sequences! x y)
  53.   (cond ((null? x) y)
  54.     ((null? y) x)
  55.     (else
  56.      (set-cdr! (cdr x) (car y))
  57.      (set-cdr! x (cdr y))
  58.      x)))