scm-record.scm 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. ; Part of Scheme 48 1.9. See file COPYING for notices and license.
  2. ; Authors: Richard Kelsey
  3. (define-complex-primitive (make-record symbol?)
  4. (lambda (type)
  5. (bug "no evaluator for MAKE-RECORD"))
  6. (lambda (args node depth return?)
  7. (let ((type-id (cadr (node-form (car args)))))
  8. (make-pointer-type (get-record-type type-id))))
  9. #f ; no closed form
  10. (lambda (args type)
  11. (make-primop-call-node (get-prescheme-primop 'make-record) args type)))
  12. (define-complex-primitive (record-ref any? ; no RECORD? available
  13. symbol? symbol?)
  14. (lambda (thing type field)
  15. (bug "no evaluator for RECORD-REF"))
  16. (lambda (args node depth return?)
  17. (let ((type-id (cadr (node-form (cadr args))))
  18. (field-id (cadr (node-form (caddr args)))))
  19. (let ((record-type (make-pointer-type (get-record-type type-id)))
  20. (field-type (record-field-type
  21. (get-record-type-field type-id field-id))))
  22. (check-arg-type args 0 record-type depth node)
  23. field-type)))
  24. #f ; no closed form
  25. (lambda (args type)
  26. (make-primop-call-node (get-prescheme-primop 'record-ref) args type)))
  27. (define-complex-primitive (record-set! any? ; no RECORD? available
  28. any? symbol? symbol?)
  29. (lambda (thing value type field)
  30. (bug "no evaluator for RECORD-SET!"))
  31. (lambda (args node depth return?)
  32. (let ((type-id (cadr (node-form (caddr args))))
  33. (field-id (cadr (node-form (cadddr args)))))
  34. (let ((record-type (make-pointer-type (get-record-type type-id)))
  35. (field-type (record-field-type
  36. (get-record-type-field type-id field-id))))
  37. (check-arg-type args 0 record-type depth node)
  38. (check-arg-type args 1 field-type depth node)
  39. type/unit)))
  40. #f ; no closed form
  41. (lambda (args type)
  42. (make-primop-call-node (get-prescheme-primop 'record-set!) args type)))
  43. ; (x->union value 'union-type 'variant)
  44. ;
  45. ;(define-complex-primitive (x->union any?
  46. ; symbol? ; union type
  47. ; symbol?) ; variant
  48. ; (lambda (thing type field)
  49. ; (bug "no evaluator for X->UNION"))
  50. ; (lambda (args node depth return?)
  51. ; (let ((type-id (cadr (node-form (cadr args))))
  52. ; (member-id (cadr (node-form (caddr args)))))
  53. ; (let ((union-type (make-pointer-type (get-union-type type-id)))
  54. ; (field-type (union-member-type
  55. ; (get-union-type-member type-id member-id))))
  56. ; (check-arg-type args 0 field-type depth node)
  57. ; union-type)))
  58. ; #f ; no closed form
  59. ; (lambda (args type)
  60. ; (make-primop-call-node (get-prescheme-primop 'x->union) args type)))