scm-record.scm 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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
  6. ;;;
  7. ;;; scheme48-1.9.2/ps-compiler/prescheme/primop/scm-record.scm
  8. (define-module (ps-compiler prescheme primop scm-record)
  9. #:use-module (ps-compiler prescheme primop scm-scheme))
  10. (define-complex-primitive (make-record symbol?)
  11. (lambda (type)
  12. (bug "no evaluator for MAKE-RECORD"))
  13. (lambda (args node depth return?)
  14. (let ((type-id (cadr (node-form (car args)))))
  15. (make-pointer-type (get-record-type type-id))))
  16. #f ;; no closed form
  17. (lambda (args type)
  18. (make-primop-call-node (get-prescheme-primop 'make-record) args type)))
  19. (define-complex-primitive (record-ref any? ;; no RECORD? available
  20. symbol? symbol?)
  21. (lambda (thing type field)
  22. (bug "no evaluator for RECORD-REF"))
  23. (lambda (args node depth return?)
  24. (let ((type-id (cadr (node-form (cadr args))))
  25. (field-id (cadr (node-form (caddr args)))))
  26. (let ((record-type (make-pointer-type (get-record-type type-id)))
  27. (field-type (record-field-type
  28. (get-record-type-field type-id field-id))))
  29. (check-arg-type args 0 record-type depth node)
  30. field-type)))
  31. #f ;; no closed form
  32. (lambda (args type)
  33. (make-primop-call-node (get-prescheme-primop 'record-ref) args type)))
  34. (define-complex-primitive (record-set! any? ;; no RECORD? available
  35. any? symbol? symbol?)
  36. (lambda (thing value type field)
  37. (bug "no evaluator for RECORD-SET!"))
  38. (lambda (args node depth return?)
  39. (let ((type-id (cadr (node-form (caddr args))))
  40. (field-id (cadr (node-form (cadddr args)))))
  41. (let ((record-type (make-pointer-type (get-record-type type-id)))
  42. (field-type (record-field-type
  43. (get-record-type-field type-id field-id))))
  44. (check-arg-type args 0 record-type depth node)
  45. (check-arg-type args 1 field-type depth node)
  46. type/unit)))
  47. #f ;; no closed form
  48. (lambda (args type)
  49. (make-primop-call-node (get-prescheme-primop 'record-set!) args type)))
  50. ;; (x->union value 'union-type 'variant)
  51. ;;
  52. ;;(define-complex-primitive (x->union any?
  53. ;; symbol? ;; union type
  54. ;; symbol?) ;; variant
  55. ;; (lambda (thing type field)
  56. ;; (bug "no evaluator for X->UNION"))
  57. ;; (lambda (args node depth return?)
  58. ;; (let ((type-id (cadr (node-form (cadr args))))
  59. ;; (member-id (cadr (node-form (caddr args)))))
  60. ;; (let ((union-type (make-pointer-type (get-union-type type-id)))
  61. ;; (field-type (union-member-type
  62. ;; (get-union-type-member type-id member-id))))
  63. ;; (check-arg-type args 0 field-type depth node)
  64. ;; union-type)))
  65. ;; #f ;; no closed form
  66. ;; (lambda (args type)
  67. ;; (make-primop-call-node (get-prescheme-primop 'x->union) args type)))