home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnusmalltalk / systemdictionary.st < prev    next >
Text File  |  1992-02-15  |  3KB  |  112 lines

  1. "======================================================================
  2. |
  3. |   SystemDictionary Method Definitions
  4. |
  5.  ======================================================================"
  6.  
  7.  
  8. "======================================================================
  9. |
  10. | Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
  11. | Written by Steve Byrne.
  12. |
  13. | This file is part of GNU Smalltalk.
  14. |
  15. | GNU Smalltalk is free software; you can redistribute it and/or modify it
  16. | under the terms of the GNU General Public License as published by the Free
  17. | Software Foundation; either version 1, or (at your option) any later version.
  18. | GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
  19. | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  20. | FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  21. | details.
  22. | You should have received a copy of the GNU General Public License along with
  23. | GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
  24. | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  
  25. |
  26.  ======================================================================"
  27.  
  28.  
  29. "
  30. |     Change Log
  31. | ============================================================================
  32. | Author       Date       Change 
  33. | sbb         20 Apr 91      Added some methods for testing and modifying
  34. |                         implementation specific features.
  35. |
  36. | sbb         16 Mar 91      Class creation now separate statement.
  37. |
  38. | sbyrne     22 Apr 90      Fixed Dependencies to be an IdentityDictionary
  39. |              instead of a regular Dictionary.  This has better
  40. |              semantics and is faster.
  41. |
  42. | sbyrne      4 Jul 89      added initBlocks methods.
  43. |
  44. | sbyrne     25 Apr 89      created.
  45. |
  46. "
  47.  
  48. Dictionary variableSubclass: #SystemDictionary
  49.        instanceVariableNames: ''
  50.        classVariableNames: ''
  51.        poolDictionaries: ''
  52.        category: nil
  53. !
  54.  
  55. SystemDictionary comment: 
  56. 'I am a special form of dictionary.  Typically I only have one instance,
  57. called "Smalltalk", which is known to the Smalltalk interpreter.  I define
  58. several methods that are "system" related, such as #quitPrimitive.
  59. My instance also helps keep track of dependencies between objects.' !
  60.  
  61.  
  62. ">>> See also builtins.st for some non-primitive but highly useful
  63. SystemDictionary method definitions."
  64.  
  65. !SystemDictionary methodsFor: 'basic'!
  66.  
  67. initialize
  68.     InitBlocks _ OrderedCollection new.
  69.     self at: #Dependencies put: (IdentityDictionary new) 
  70.                                              "### I don't think this is
  71.                                                   the right way to do this"
  72. !
  73.  
  74. addInit: aBlock
  75.     "Adds 'aBlock' to the array of blocks to be invoked after every start
  76.      of the system."
  77.     InitBlocks add: aBlock
  78. !
  79.  
  80. doInits
  81.     "Called after the system has loaded the image, this will invoke any
  82.      init blocks that have been installed."
  83.     InitBlocks do: [ :aBlock | aBlock value ]
  84. !
  85.  
  86. dependenciesAt: anObject
  87.     ^(Smalltalk at: #Dependencies) at: anObject
  88. !
  89.  
  90. hasFeatures: features
  91.     " Returns true if the feature or features in 'features' is one of the 
  92.       implementation dependent features present"
  93.     features class == Symbol
  94.     ifTrue: [ ^Features includes: features ]
  95.     ifFalse:
  96.         [ features do: [ :feature | (Features includes: feature)
  97.                         ifTrue: [ ^true ]].
  98.           ^false ]
  99. !
  100.  
  101. addFeature: aFeature
  102.     Features _ Features asSet.
  103.     Features add: aFeature
  104. !
  105.  
  106. removeFeature: aFeature
  107.     Features _ Features asSet.
  108.     Features remove: aFeature
  109. !!
  110.