1 Environment : IdentityDictionary {
5 ^this.new.make(function)
8 ^this.new.use(function)
12 // pushes the Envir, executes function, returns the Envir
13 // usually used to create an environment by adding new variables to it.
14 var result, saveEnvir;
16 saveEnvir = currentEnvironment;
17 currentEnvironment = this;
21 currentEnvironment = saveEnvir;
25 // temporarily replaces the currentEnvironment with this,
26 // executes function, returns the result of the function
27 var result, saveEnvir;
29 saveEnvir = currentEnvironment;
30 currentEnvironment = this;
32 result = function.value(this);
34 currentEnvironment = saveEnvir;
39 eventAt { arg key; ^this.at(key) }
40 composeEvents { arg event; ^this.copy.putAll(event) }
43 if(stack.notNil and: { stack.notEmpty }) { currentEnvironment = stack.pop };
46 stack = stack.add(currentEnvironment);
47 currentEnvironment = envir;
49 pop { ^this.class.pop }
50 push { this.class.push(this) }
52 linkDoc { arg doc, pushNow = true;
53 doc = doc ? Document.current;
55 if(pushNow and: { currentEnvironment !== this }) { this.push };
58 unlinkDoc { arg doc, popNow = false;
59 doc = doc ? Document.current;
60 if(doc.envir === this) { doc.envir_(nil) };
61 if(popNow and: { currentEnvironment === this }) { this.pop };