getContainingEnvironment method
Search for the Environment which stores the value mapped to the given variable name (key). If a given key is not found in the current Environment, it may still be found in a higher up (parent) Environment, hence this function recursively searches for the parent Environment which contains this key.
Implementation
DartBlockEnvironment? getContainingEnvironment(String variableName) {
if (_memory.containsKey(variableName)) {
return this;
} else {
if (_parent != null) {
return _parent!.getContainingEnvironment(variableName);
} else {
return null;
}
}
}