private void TranslateToILToCopyOuterScopeLocals(ILGenerator il, bool copyToNested, JSLocalField[] notToBeRestored){
if (this.own_scope.ProvidesOuterScopeLocals == null || this.own_scope.ProvidesOuterScopeLocals.count == 0)
return;
this.TranslateToILToLoadEngine(il);
il.Emit(OpCodes.Call, CompilerGlobals.scriptObjectStackTopMethod);
ScriptObject scope = globals.ScopeStack.Peek();
while (scope is WithObject || scope is BlockScope){
il.Emit(OpCodes.Call, CompilerGlobals.getParentMethod);
scope = scope.GetParent();
}
scope = this.enclosing_scope;
while (scope != null){
//Run through the scope chain, copying locals from outer scopes that provide them.
il.Emit(OpCodes.Call, CompilerGlobals.getParentMethod);
if (scope is FunctionScope && ((FunctionScope)scope).owner != null && this.own_scope.ProvidesOuterScopeLocals[scope] != null){
il.Emit(OpCodes.Dup);
il.Emit(OpCodes.Castclass, Typeob.StackFrame);
il.Emit(OpCodes.Ldfld, CompilerGlobals.localVarsField);
if (copyToNested)
((FunctionScope)scope).owner.TranslateToILToCopyLocalsToNestedScope(il, this.own_scope, notToBeRestored);
else
((FunctionScope)scope).owner.TranslateToILToCopyLocalsFromNestedScope(il, this.own_scope);
}else if (scope is GlobalScope || scope is ClassScope)
break;
scope = scope.GetParent();
}
il.Emit(OpCodes.Pop);
}