// Special case hoisted return value (happens in try/finally scenario)
//
if (ec.TryFinallyUnwind != null) {
- if (storey.HoistedReturnValue is VariableReference) {
- storey.HoistedReturnValue = ec.GetTemporaryField (storey.HoistedReturnValue.Type);
- }
-
exit_label = TryFinally.EmitRedirectedReturn (ec, async_body);
}
public class ExplicitBlock : Block
{
protected AnonymousMethodStorey am_storey;
+ int debug_scope_index;
public ExplicitBlock (Block parent, Location start, Location end)
: this (parent, (Flags) 0, start, end)
public override void Emit (EmitContext ec)
{
- if (Parent != null)
- ec.BeginScope ();
+ if (Parent != null) {
+ // TODO: It's needed only when scope has variable (normal or lifted)
+ ec.BeginScope (GetDebugSymbolScopeIndex ());
+ }
EmitScopeInitialization (ec);
storey.Parent.PartialContainer.AddCompilerGeneratedClass (storey);
}
+ public int GetDebugSymbolScopeIndex ()
+ {
+ if (debug_scope_index == 0)
+ debug_scope_index = ++ParametersBlock.debug_scope_index;
+
+ return debug_scope_index;
+ }
+
public void RegisterAsyncAwait ()
{
var block = this;
for_each.variable.Type = var_type;
+ var prev_block = ec.CurrentBlock;
+ ec.CurrentBlock = variables_block;
var variable_ref = new LocalVariableReference (for_each.variable, loc).Resolve (ec);
+ ec.CurrentBlock = prev_block;
+
if (variable_ref == null)
return false;
return false;
}
+ var prev_block = ec.CurrentBlock;
+ ec.CurrentBlock = for_each.variable.Block;
var variable_ref = new LocalVariableReference (variable, loc).Resolve (ec);
+ ec.CurrentBlock = prev_block;
if (variable_ref == null)
return false;
ec.LoopEnd = ec.DefineLabel ();
if (!(Statement is Block))
- ec.BeginCompilerScope ();
+ ec.BeginCompilerScope (variable.Block.Explicit.GetDebugSymbolScopeIndex ());
variable.CreateBuilder (ec);