c-util.scm 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. ;;; Ported from Scheme 48 1.9. See file COPYING for notices and license.
  2. ;;;
  3. ;;; Port Author: Andrew Whatson
  4. ;;;
  5. ;;; Original Authors: Richard Kelsey, Timo Harter
  6. ;;;
  7. ;;; scheme48-1.9.2/ps-compiler/prescheme/c-decl.scm
  8. (define-module (ps-compiler prescheme c-util)
  9. #:use-module (ps-compiler node node)
  10. #:use-module (ps-compiler node node-util)
  11. #:use-module (ps-compiler node variable)
  12. #:use-module (ps-compiler prescheme spec)
  13. #:use-module (ps-compiler prescheme type)
  14. #:use-module (ps-compiler prescheme type-var)
  15. #:export (*local-vars*
  16. goto-call?
  17. final-variable-type))
  18. ;;------------------------------------------------------------
  19. ;; Collecting local variables. Each is added to this list when it is first
  20. ;; used.
  21. (define *local-vars* '())
  22. ;;----------------------------------------------------------------
  23. ;; Random utility here for historical reasons.
  24. (define (goto-call? call)
  25. (and (calls-this-primop? call 'unknown-tail-call)
  26. (goto-protocol? (literal-value (call-arg call 2)))))
  27. ;;----------------------------------------------------------------
  28. ;; random type stuff
  29. (define (reference-type node)
  30. (finalize-variable-type (reference-variable node)))
  31. (define (finalize-variable-type var)
  32. (let* ((type (finalize-type (variable-type var)))
  33. (type (if (uvar? type)
  34. type/null
  35. type)))
  36. (set-variable-type! var type)
  37. type))
  38. (define final-variable-type finalize-variable-type)