Skip to content

Commit 89bebe9

Browse files
committed
C#: Re-factor local variable populate.
1 parent ad4ae1c commit 89bebe9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Entities/LocalVariable.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,22 @@ public override void Populate(TextWriter trapFile) { }
2323
public void PopulateManual(Expression parent, bool isVar)
2424
{
2525
var trapFile = Context.TrapWriter.Writer;
26-
var (kind, type) = Symbol is ILocalSymbol l
27-
? (l.IsRef ? 3 : l.IsConst ? 2 : 1, l.GetAnnotatedType())
28-
: (1, parent.Type);
29-
trapFile.localvars(this, kind, Symbol.Name, isVar ? 1 : 0, Type.Create(Context, type).TypeRef, parent);
26+
var @var = isVar ? 1 : 0;
3027

3128
if (Symbol is ILocalSymbol local)
3229
{
30+
var @const = local.IsRef ? 3 : local.IsConst ? 2 : 1;
31+
var type = local.GetAnnotatedType();
32+
trapFile.localvars(this, @const, Symbol.Name, @var, Type.Create(Context, type).TypeRef, parent);
33+
3334
PopulateNullability(trapFile, local.GetAnnotatedType());
3435
if (local.IsRef)
3536
trapFile.type_annotation(this, Kinds.TypeAnnotation.Ref);
3637
}
38+
else
39+
{
40+
trapFile.localvars(this, 1, Symbol.Name, @var, Type.Create(Context, parent.Type).TypeRef, parent);
41+
}
3742

3843
trapFile.localvar_location(this, Location);
3944

0 commit comments

Comments
 (0)