Squeak Class Documentation category index | class index  
 
Environment
  category: System-Support
  superclass: SystemDictionary
  subclasses: SmalltalkEnvironment

Environments are used to provide separate name spaces in Squeak. Each one operates pretty much the same way that the Smalltalk systemDictionary is used in a non-partitioned Squeak.

Each class has a direct-access environment in which it is compiled. Its environment slot points to an instance of this class, and it is there where the bindings of global variables are sought. The compiler looks up these bindings using normal dictionary protocol (at:, etc). If a binding is not found, then the name is looked up in the environment from which that one inherits, if any. In this way a class may be compiled in a context that consists of several nested name spaces, and direct reference may be made to any of the objects resident in those spaces.

Various methods may need to refer to objects that reside in environnments that are not a part of their direct-access environment. For these references, a simple global reference,
Thing
may not be used, and instead the construct,
Envt Thing
must be used. In this case Envt is a gloabl reference to another environment, and the global name, Thing, is sent as a message to that environment.

Obviously, such a foreign reference cannot be resolved unless the environment in question implements a method of that name. This is how environmental variables are exported.

Each environment has its own unique class. With this structure, each environment can have its own instance-specific messeages to provide access to its exported symbols. Note that this mechanism provides much faster runtime access than the Dictionary at: protocol. Also note that inheritance provides a trivial implementation of nested name scope by the same token.

In the early stages of installing partitioned environments in Squeak, interpreted access will be provided in several ways. To begin with, environments will intercept the doesNotUnderstand: message and, if the message begins with a capital letter, it will look up the corresponding name using #at:, and return the value if found. A refinement to this feature will be to compile an export method on the spot, so that subsequent accesses to that variable run much faster.

Note that there is no Environmental access pattern analogous to 'Envt Thing'. If an implementor wishes to store into environmental variables, he must do so by defining, eg, a SetThingTo: method and using a call to that method in his code. We may choose to only allow one certain pattern of access to be compiled in any subclass of Environment to enforce some understandable style of coding.

instance methods
  dictionary access
  =
allClassesAnywhereDo:
associationAtOrAbove:ifAbsent:
at:
at:ifAbsent:
atOrAbove:ifAbsent:
atOrBelow:ifAbsent:
deepAssociationsDo:
environmentForCategory:
exportMethodFor:
lenientScopeHas:ifTrue:
scopeFor:from:envtAndPathIfFound:

  fileIn/out
  isInMemory
stillOut
storeAll
storeSegment

  instance creation
  makeSubEnvironmentNamed:
setName:inOuterEnvt:
setName:outerEnvt:

  printing
  name
printOn:

  system conversion
  browseIndirectRefs
rewriteIndirectRefs
rewriteSourceForSelector:inClass:using:
tallyIndirectRefs
transferBindingsNamedIn:from:

class methods
  system conversion
  computePrerequisites
reorganizeEverything

instance methods
  dictionary access top  
 

=

Environments should only be compared on the basis of identity


 

allClassesAnywhereDo:


 

associationAtOrAbove:ifAbsent:

Look up an association with this key here or in an outer environment.


 

at:

Compatibility hack for starting up Environments


 

at:ifAbsent:

Compatibility hack for starting up Environments


 

atOrAbove:ifAbsent:

Look up the value iof this key here or in an outer environment.


 

atOrBelow:ifAbsent:

Compatibility hack -- find things in sub environments for now.
Adjusted to not fault on every environment.


 

deepAssociationsDo:

Compatibility hack -- find things in sub environments for now


 

environmentForCategory:

Smalltalk environmentForCategory:'Morphic'


 

exportMethodFor:


 

lenientScopeHas:ifTrue:

Compatibility hack -- find things in sub environments for now


 

scopeFor:from:envtAndPathIfFound:

Look up varName here or in any sub-environments, and also in any sub-environments of the outer environment. If found, evaluate pathBlock with a string giving the path for the access, and return the environment in which the variable was found. Return nil if the variable is not found.

Call from outside with prior == nil.
prior ~= nil prevents revisiting prior parts of the tree.


  fileIn/out top  
 

isInMemory

All normal objects are.


 

stillOut

Smalltalk stillOut


 

storeAll

Write all Environments except me and the top one out as image segments.


 

storeSegment

Store my project out on the disk as an ImageSegment. Keep the outPointers in memory. Name it <my name>.seg.


  instance creation top  
 

makeSubEnvironmentNamed:

Make a new environment (with its own class) of the given name.
Install it under that name in this environment, and point its outerEnvt link here as well.


 

setName:inOuterEnvt:


 

setName:outerEnvt:


  printing top  
 

name

Answer a name for the receiver. This is used generically in the title of certain inspectors, such as the referred-to inspector, and specificially by various subsystems. By default, we let the object just print itself out..


 

printOn:

Append a sequence of characters that identify the receiver to aStream.


  system conversion top  
 

browseIndirectRefs

Smalltalk browseIndirectRefs


 

rewriteIndirectRefs

Smalltalk rewriteIndirectRefs


 

rewriteSourceForSelector:inClass:using:

Rewrite the source code for the method in question so that all global references out of the direct access path are converted to indirect global references. This is done by parsing the source with a lenient parser able to find variables in any environment. Then the parse tree is consulted for the source code ranges of each reference that needs to be rewritten and the pattern to which it should be rewritten. Note that assignments, which will take the form
envt setValueOf: #GlobalName to: ...
may generate spurious message due to agglutination of keywords with the value expression.


 

tallyIndirectRefs

Smalltalk tallyIndirectRefs


 

transferBindingsNamedIn:from:


class methods
  system conversion top  
 

computePrerequisites

We say one environment is a prerequisite of another if classes defined
in the other inherit from classes in the first.
Compute a dictionary with an entry for every non-kernel environment.
That entry is another dictionary giving the names of any prerequisite
environments and the list of classes that require it.


 

reorganizeEverything

Undertake a grand reorganization.
Environment reorganizeEverything.