what're the Label_xxxx in decompiled code?

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

I was looking at some of the Framework code using the .NET Reflector.
There're some places where there're these Label_xxxx lines, e.g.:

......
if (string.IsNullOrEmpty(this.Url))
{
goto Label_0174;
}
Label_00C2:
if (base.DataSources.Count == 0)
{
goto Label_0189;
}
goto Label_0194;
Label_00D7:
.......................

What would these labels be in the original code? I guess the compiler
rearranged the branching logics and the decompiler simply wouldn't know what
the original code looks like?
 
Bob said:
I was looking at some of the Framework code using the .NET Reflector.
There're some places where there're these Label_xxxx lines, e.g.:

.....
if (string.IsNullOrEmpty(this.Url))
{
goto Label_0174;
}
Label_00C2:
if (base.DataSources.Count == 0)
{
goto Label_0189;
}
goto Label_0194;
Label_00D7:
......................

What would these labels be in the original code?

What you're seeing is a limitation of the decompilation support of
Reflector. In general, arbitrary code can be decomposed into switch
statements, if statements, jumps, assignments and method calls.
Extracting higher-level structures such as while / for / foreach etc.
relies on pattern-matching, heuristics, etc.
I guess the compiler
rearranged the branching logics and the decompiler simply wouldn't know what
the original code looks like?

It's also possible that goto was used to escape from deeply nested
loops, or to perform some other control flow not possible with purely
structured programming primitives.

-- Barry
 
Back
Top