Skip to content

Commit a76b6ff

Browse files
committed
Add several improvements to DerivedClass_F
1 parent eeb1b52 commit a76b6ff

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

share/prolog/oorules/rules.pl

+13-2
Original file line numberDiff line numberDiff line change
@@ -1938,15 +1938,26 @@
19381938
DerivedClass, BaseClass, Offset)]).
19391939

19401940
% An easier to understand version of E that builds on concluded VBTable facts instead of RTTI.
1941+
reasonDerivedClass_F(DerivedClass, BaseClass, Offset) :-
19411942
reasonDerivedClass_F(DerivedClass, BaseClass, Offset) :-
19421943
factObjectInObject(DerivedClass, BaseClass, Offset),
19431944
% There's an entry in some VBTable somehere (only unified by Offset so far).
1944-
factVBTableEntry(VBTableAddress, _TableObjectOffset, Offset),
1945+
factVBTableEntry(VBTableAddress, TableOffset, OffsetFromVBPtr),
1946+
% The first offset of a VBTable is the offset from the vbptr to the object start.
1947+
TableOffset > 0,
19451948
% And that VBTable is installed into an object in some Method.
1946-
factVBTableWrite(_Insn, Method, _VBTableOffset, VBTableAddress),
1949+
factVBTableWrite(_Insn, Method, VBPtrOffset, VBTableAddress),
1950+
% Ensure that BaseClass is not empty. If it is, there could be multiple
1951+
% classes at the same offset.
1952+
notEmptyClass(BaseClass),
19471953
% Finally, check that the method is assigned to the Derived class.
19481954
% This is the unification that makes the VBTableEntry relevant.
19491955
find(Method, DerivedClass),
1956+
1957+
% ejs 8/13/22 The offsets in a vbtable are offsets from the location of the vbptr, not from
1958+
% the beginning of the class. Sometimes the vbptr is at offset zero, but not always.
1959+
Offset is OffsetFromVBPtr + VBPtrOffset,
1960+
19501961
% Debugging
19511962
logtraceln('~@~Q.', [not(factDerivedClass(DerivedClass, BaseClass, Offset)),
19521963
reasonDerivedClass_F(DerivedClass, BaseClass, Offset,

0 commit comments

Comments
 (0)