PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/src/runtime-collections.scm

http://github.com/pablomarx/Thomas
Scheme | 94 lines | 19 code | 11 blank | 64 comment | 0 complexity | 1d04a37964b119f498abc5fe08056a82 MD5 | raw file
  1. ;* Copyright 1992 Digital Equipment Corporation
  2. ;* All Rights Reserved
  3. ;*
  4. ;* Permission to use, copy, and modify this software and its documentation is
  5. ;* hereby granted only under the following terms and conditions. Both the
  6. ;* above copyright notice and this permission notice must appear in all copies
  7. ;* of the software, derivative works or modified versions, and any portions
  8. ;* thereof, and both notices must appear in supporting documentation.
  9. ;*
  10. ;* Users of this software agree to the terms and conditions set forth herein,
  11. ;* and hereby grant back to Digital a non-exclusive, unrestricted, royalty-free
  12. ;* right and license under any changes, enhancements or extensions made to the
  13. ;* core functions of the software, including but not limited to those affording
  14. ;* compatibility with other hardware or software environments, but excluding
  15. ;* applications which incorporate this software. Users further agree to use
  16. ;* their best efforts to return to Digital any such changes, enhancements or
  17. ;* extensions that they make and inform Digital of noteworthy uses of this
  18. ;* software. Correspondence should be provided to Digital at:
  19. ;*
  20. ;* Director, Cambridge Research Lab
  21. ;* Digital Equipment Corp
  22. ;* One Kendall Square, Bldg 700
  23. ;* Cambridge MA 02139
  24. ;*
  25. ;* This software may be distributed (but not offered for sale or transferred
  26. ;* for compensation) to third parties, provided such third parties agree to
  27. ;* abide by the terms and conditions of this notice.
  28. ;*
  29. ;* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
  30. ;* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
  31. ;* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
  32. ;* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  33. ;* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  34. ;* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  35. ;* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  36. ;* SOFTWARE.
  37. ; $Id: runtime-collections.scm,v 1.19 1992/09/09 22:12:55 jmiller Exp $
  38. ;;;;; RUNTIME-COLLECTIONS.SCM
  39. ;;;;; The specializations of method based on collection type are in the file:
  40. ;;;;; runtime-collections-xxx.scm (where xxx is collection type)
  41. ;;; Class definitions on pages 111 and 112 imply specialization for
  42. ;;; the make operation.
  43. ;;;
  44. ;;; General theory of operation: some of the collection types are
  45. ;;; handled very, very specially to make them more efficient. In
  46. ;;; particular:
  47. ;;; <byte-string> : implemented as a Scheme string,
  48. ;;; <simple-object-vector> : implemented as a Scheme vector
  49. ;;; <list>, <pair>, <empty-list> : implemented in Scheme
  50. ;;;
  51. ;;; All other collection types are instances (in the sense of
  52. ;;; "created by calling make-instance in class.scm").
  53. ;;;
  54. ;;; Consequences of this decision: any generic operation on a class
  55. ;;; which is a superclass of one of the special classes MUST BE
  56. ;;; SPECIALIZED for the special case. This can either be done by
  57. ;;; conditionalizing the code that handles the superclass or by
  58. ;;; providing a specific method for the special subclass.
  59. ;;; KNOWN PROBLEMS
  60. ;;;
  61. ;;; UTILITY FUNCTIONS
  62. ;;;
  63. (define (one-arg name type fn)
  64. (dylan::function->method
  65. (make-param-list `((,name ,type)) #F #F #F) fn))
  66. (define (but-last list)
  67. (reverse (cdr (reverse list))))
  68. (define (create-private-slot owner type-restriction name continue)
  69. ;; Adds a new slot to an existing class, and returns the getter and
  70. ;; setter generic functions to be used for the slot.
  71. (define the-getter
  72. (dylan::generic-fn (new-name "dylan:" name "-getter")
  73. (make-param-list `((ARRAY ,<object>)) #F #F #F)
  74. #F))
  75. (define the-setter
  76. (dylan::generic-fn (new-name "dylan:" name "-setter!")
  77. (make-param-list `((ARRAY ,<object>) (VALUE ,<object>)) #F #F #F)
  78. #F))
  79. (dylan::add-slot owner
  80. type-restriction 'INSTANCE the-setter the-getter
  81. (new-name "" name "") #F #F #F #F #F)
  82. (continue the-setter the-getter))