Skip to content

Commit 3a1a052

Browse files
committed
CIL: Also handle the implicit 'this' in the extractor.
1 parent 156495a commit 3a1a052

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

binary/extractor/cil/Semmle.Extraction.CSharp.IL/ILExtractor.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,22 @@ private void ExtractMethod(MethodDefinition method, int typeId) {
8686
ExtractMethodBody(method, methodId);
8787
}
8888

89+
// If it's an instance method we generate a 'this' parameter and
90+
// place it at index 0.
91+
int paramStartIndex = 0;
92+
if (!method.IsStatic)
93+
{
94+
var thisId = trap.GetId();
95+
trap.WriteTuple("il_parameter", thisId, methodId, 0, "#this");
96+
// We set the index for the actual parameters to start at 1
97+
// so that we don't get overlapping indices.
98+
paramStartIndex = 1;
99+
}
100+
89101
for(int i = 0; i < method.Parameters.Count; i++) {
90102
var param = method.Parameters[i];
91103
var paramId = trap.GetId();
92-
trap.WriteTuple("il_parameter", paramId, methodId, i, param.Name);
104+
trap.WriteTuple("il_parameter", paramId, methodId, i + paramStartIndex, param.Name);
93105
}
94106
}
95107

0 commit comments

Comments
 (0)