X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fmcs%2Fiterators.cs;h=df43ff38e8e09f0387a6810ad441a6d56c5d8457;hb=23fbdb66437357ec6d50f498ed8e88590cd89196;hp=8b45f88a911a054c4156b8d13f545f430d2e707a;hpb=10fa44a5e6ab5b6cc4c4a79da9a2a032d0901af5;p=mono.git diff --git a/mcs/mcs/iterators.cs b/mcs/mcs/iterators.cs index 8b45f88a911..df43ff38e8e 100644 --- a/mcs/mcs/iterators.cs +++ b/mcs/mcs/iterators.cs @@ -74,6 +74,9 @@ namespace Mono.CSharp public void RegisterResumePoint () { + if (resume_pc != 0) + return; + if (inside_try_block == null) { resume_pc = machine_initializer.AddResumePoint (this); } else { @@ -199,7 +202,6 @@ namespace Mono.CSharp Field pc_field; StateMachineMethod method; - int local_name_idx; protected StateMachine (ParametersBlock block, TypeDefinition parent, MemberBase host, TypeParameters tparams, string name, MemberKind kind) : base (block, parent, host, tparams, name, kind) @@ -241,12 +243,19 @@ namespace Mono.CSharp return base.DoDefineMembers (); } - protected override string GetVariableMangledName (LocalVariable local_info) + protected override string GetVariableMangledName (ResolveContext rc, LocalVariable local_info) { if (local_info.IsCompilerGenerated) - return base.GetVariableMangledName (local_info); + return base.GetVariableMangledName (rc, local_info); - return "<" + local_info.Name + ">__" + local_name_idx++.ToString ("X"); + // + // Special format which encodes original variable name and + // it's scope to support lifted variables debugging. This + // is same what csc does and allows to correctly set fields + // scope information (like ambiguity, our of scope, etc). + // + var id = rc.CurrentBlock.Explicit.GetDebugSymbolScopeIndex (); + return "<" + local_info.Name + ">__" + id; } } @@ -723,7 +732,7 @@ namespace Mono.CSharp // // The state as we generate the machine // - Label move_next_ok; + protected Label move_next_ok; protected Label move_next_error; LocalBuilder skip_finally; protected LocalBuilder current_pc; @@ -827,8 +836,15 @@ namespace Mono.CSharp BodyEnd = ec.DefineLabel (); + var async_init = this as AsyncInitializer; + if (async_init != null) + ec.BeginExceptionBlock (); + block.EmitEmbedded (ec); + if (async_init != null) + async_init.EmitCatchBlock (ec); + ec.MarkLabel (BodyEnd); EmitMoveNextEpilogue (ec); @@ -839,6 +855,8 @@ namespace Mono.CSharp ec.EmitInt (0); ec.Emit (OpCodes.Ret); } + + ec.MarkLabel (move_next_ok); } void EmitMoveNext (EmitContext ec) @@ -895,19 +913,7 @@ namespace Mono.CSharp ec.MarkLabel (BodyEnd); if (async_init != null) { - var catch_value = LocalVariable.CreateCompilerGenerated (ec.Module.Compiler.BuiltinTypes.Exception, block, Location); - - ec.BeginCatchBlock (catch_value.Type); - catch_value.EmitAssign (ec); - - ec.EmitThis (); - ec.EmitInt ((int) IteratorStorey.State.After); - ec.Emit (OpCodes.Stfld, storey.PC.Spec); - - ((AsyncTaskStorey) async_init.Storey).EmitSetException (ec, new LocalVariableReference (catch_value, Location)); - - ec.Emit (OpCodes.Leave, move_next_ok); - ec.EndExceptionBlock (); + async_init.EmitCatchBlock (ec); } ec.Mark (Block.Original.EndLocation);