This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
dev:crosscompiler:type_checking [2015/04/06 09:05] – ursgraf | dev:crosscompiler:type_checking [2019/07/12 08:20] – ursgraf | ||
---|---|---|---|
Line 31: | Line 31: | ||
- this address must be identical with the address of the type descriptor of the actual object. | - this address must be identical with the address of the type descriptor of the actual object. | ||
The type descriptor of a class is constructed as follows: the base class 0 is always //Object//. The entry contains the address of the type descriptor of //Object//. This entry is followed by the other superclasses. The address of the own class is entered as the last entry. All derived classes must have the same order for the base classes. The example below shows the execution of a type check. | The type descriptor of a class is constructed as follows: the base class 0 is always //Object//. The entry contains the address of the type descriptor of //Object//. This entry is followed by the other superclasses. The address of the own class is entered as the last entry. All derived classes must have the same order for the base classes. The example below shows the execution of a type check. | ||
- | [{{ .: | + | [{{ .: |
For the java code | For the java code | ||
Line 68: | Line 68: | ||
Interface classes cannot be listed in the table with the standard classes. The reason is that interface classes do not have fixed offsets.\\ | Interface classes cannot be listed in the table with the standard classes. The reason is that interface classes do not have fixed offsets.\\ | ||
[{{ .: | [{{ .: | ||
- | Je nach Vererbungshierarchie belegt das Interface einen anderen Platz in der Tabelle und der Compiler kann keinen fixen Offset berechnen mit dem in der Tabelle geprüft werden könnte. \\ Aus diesem Grund gibt es eine Tabelle im Typdescriptor mit allen Interfaces, die diese Klasse implementiert und auf die überhaupt je ein Typtest gemacht wird. \\ | + | Depending on the extension hierarchy the interface occupies different places |
- | [{{ .: | + | For this reason the type descriptor has a table with all interfaces that this class implements. The compiler will determine at compile time for which interfaces there is ever a type check. Only these will be inserted into the table. \\ |
- | Die betroffenen Interfaces werden alle nummeriert | + | [{{ .: |
- | Auch hier muss wieder wie oben ein Unterschied zwischen | + | All the affected interfaces get numbered |
+ | Here again, | ||
==== Complex Use Case ==== | ==== Complex Use Case ==== | ||
The following code | The following code | ||
<code java> | <code java> | ||
- | Object[][][] a1 = new Object[2][3][4]; | + | Object[][][] a1 = new Object[2][3][4]; |
A[] x = new AA[5]; | A[] x = new AA[5]; | ||
a1[0][0] = x; | a1[0][0] = x; |