constructor TMethodEnumerator.Create(AClass: TClass);
type
TMethodTable = packed record
count: SmallInt;
//[...methods...]
end;
var
table: ^TMethodTable;
name : ^ShortString;
i, j : Integer;
begin
inherited Create;
while aclass <> nil do
begin
// *** HACK ALERT *** !!!
// Review System.MethodName to grok how this method works
asm
mov EAX, [aclass]
mov EAX,[EAX].vmtMethodTable { fetch pointer to method table }
mov [table], EAX
end;
if table <> nil then
begin
name := Pointer(PChar(table) + 8);
for i := 1 to table.count do
begin
// check if we've seen the method name
j := Low(FMethodNameList);
while (j <= High(FMethodNameList))
and (name^ <> FMethodNameList[j]) do
inc(j);
// if we've seen the name, then the method has probably been overridden
if j <= High(FMethodNameList) then
CONTINUE;
SetLength(FMethodNameList,length(FMethodNameList)+1);
FMethodNameList[j] := name^;
name := Pointer(PChar(name) + length(name^) + 7)
end;
end;
aclass := aclass.ClassParent;
end;
End; |