var da_false = new DefiniteAssignmentBitSet (fc.DefiniteAssignmentOnFalse);
fc.DefiniteAssignment = fc.DefiniteAssignmentOnTrue;
+ var labels = fc.CopyLabelStack ();
var res = TrueStatement.FlowAnalysis (fc);
+ fc.SetLabelStack (labels);
+
if (FalseStatement == null) {
+
var c = expr as Constant;
if (c != null && !c.IsDefaultValue)
return true_returns;
if (true_returns) {
fc.DefiniteAssignment = da_false;
- return FalseStatement.FlowAnalysis (fc);
+
+ res = FalseStatement.FlowAnalysis (fc);
+ fc.SetLabelStack (labels);
+ return res;
}
var da_true = fc.DefiniteAssignment;
fc.DefiniteAssignment = da_false;
+
res &= FalseStatement.FlowAnalysis (fc);
+ fc.SetLabelStack (labels);
+
if (!TrueStatement.IsUnreachable) {
if (false_returns || FalseStatement.IsUnreachable)
fc.DefiniteAssignment = da_true;
public override void Emit (EmitContext ec)
{
- if (Parent != null) {
- // TODO: It's needed only when scope has variable (normal or lifted)
- ec.BeginScope (GetDebugSymbolScopeIndex ());
+ // TODO: It's needed only when scope has variable (normal or lifted)
+ var scopeIndex = GetDebugSymbolScopeIndex ();
+ if (scopeIndex > 0) {
+ ec.BeginScope (scopeIndex);
}
EmitScopeInitialization (ec);
DoEmit (ec);
- if (Parent != null)
+ if (scopeIndex > 0)
ec.EndScope ();
if (ec.EmitAccurateDebugInfo && HasReachableClosingBrace && !(this is ParametersBlock) &&
storey.Parent.PartialContainer.AddCompilerGeneratedClass (storey);
}
- public int GetDebugSymbolScopeIndex ()
+ public void DisableDebugScopeIndex ()
+ {
+ debug_scope_index = -1;
+ }
+
+ public virtual int GetDebugSymbolScopeIndex ()
{
if (debug_scope_index == 0)
debug_scope_index = ++ParametersBlock.debug_scope_index;
return res;
}
+ public override int GetDebugSymbolScopeIndex ()
+ {
+ return 0;
+ }
+
public LabeledStatement GetLabel (string name, Block block)
{
//
ec.LoopBegin = ec.DefineLabel ();
ec.LoopEnd = ec.DefineLabel ();
- if (!(Statement is Block))
- ec.BeginCompilerScope (variable.Block.Explicit.GetDebugSymbolScopeIndex ());
+ ec.BeginCompilerScope (variable.Block.Explicit.GetDebugSymbolScopeIndex ());
+ body.Explicit.DisableDebugScopeIndex ();
variable.CreateBuilder (ec);
Statement.Emit (ec);
- if (!(Statement is Block))
- ec.EndScope ();
+ ec.EndScope ();
ec.LoopBegin = old_begin;
ec.LoopEnd = old_end;