internal override void TranslateToIL(ILGenerator il, Type rtype){
//This assumes that rtype == Void.class
this.context.EmitLineInfo(il);
Globals.ScopeStack.Push(new WithObject(Globals.ScopeStack.Peek(), new JSObject(null, false)));
bool savedInsideProtectedRegion = compilerGlobals.InsideProtectedRegion;
compilerGlobals.InsideProtectedRegion = true;
Label lab = il.DefineLabel();
compilerGlobals.BreakLabelStack.Push(lab);
compilerGlobals.ContinueLabelStack.Push(lab);
this.obj.TranslateToIL(il, Typeob.Object);
this.EmitILToLoadEngine(il);
il.Emit(OpCodes.Call, CompilerGlobals.jScriptWithMethod); // JScriptWith returns the with object as an 'Object' (used by the debugger EE)
// define a local named 'with()' that the debugger EE will use to bind to the with object
LocalBuilder withObj = null;
if (context.document.debugOn){
il.BeginScope(); // used by the debugger to mark a with block
withObj = il.DeclareLocal(Typeob.Object);
withObj.SetLocalSymInfo("with()");
il.Emit(OpCodes.Stloc, withObj);
}else
il.Emit(OpCodes.Pop);
il.BeginExceptionBlock();
this.block.TranslateToILInitializer(il);
this.block.TranslateToIL(il, Typeob.Void);
il.BeginFinallyBlock();
if (context.document.debugOn){
// null the local used by the debugger EE
il.Emit(OpCodes.Ldnull);
il.Emit(OpCodes.Stloc, withObj);
}
this.EmitILToLoadEngine(il);
il.Emit(OpCodes.Call, CompilerGlobals.popScriptObjectMethod);
il.Emit(OpCodes.Pop);
il.EndExceptionBlock();
if (context.document.debugOn)
il.EndScope(); // used by the debugger to mark a with block
il.MarkLabel(lab);
compilerGlobals.BreakLabelStack.Pop();
compilerGlobals.ContinueLabelStack.Pop();
compilerGlobals.InsideProtectedRegion = savedInsideProtectedRegion;
Globals.ScopeStack.Pop();
}