deep

a Cross Development Platform for Java

User Tools

Site Tools


dev:crosscompiler:type_checking

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dev:crosscompiler:type_checking [2016/02/25 13:33] – external edit 127.0.0.1dev:crosscompiler:type_checking [2022/12/20 11:43] (current) ursgraf
Line 14: Line 14:
  
 ==== Special Case 'Object' ==== ==== Special Case 'Object' ====
-When you check against //Object//, the result must be ''true'' if the object is an array.\\+When you check against //Object//, the result must be ''true'' if the object is an array (of any type).\\
 A check against an array of //Object// leads to two cases: A check against an array of //Object// leads to two cases:
   - The reference points to an array of regular classes: the check returns ''true'' if the dimension (of the type to check against) is lower or equal than the actual dimension.   - The reference points to an array of regular classes: the check returns ''true'' if the dimension (of the type to check against) is lower or equal than the actual dimension.
Line 22: Line 22:
 All the explanations above were for //instanceof//. For //checkcast// there are some modifications:  All the explanations above were for //instanceof//. For //checkcast// there are some modifications: 
   - The check against //Object// is never necessary. It will be eliminated already in the Bytecode.   - The check against //Object// is never necessary. It will be eliminated already in the Bytecode.
-  - Bei einer misslungenen Prüfung wird eine Trap-Instruktion ausgelöst.+  - A failing check has to cause an exception.
   - A ''null'' reference results in a positive check.   - A ''null'' reference results in a positive check.
  
Line 71: Line 71:
 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. \\ 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. \\
 [{{ .:interfacetypecheck2.png?300&direct | // Type descriptor with //checkIds// of its interfaces //}}] [{{ .:interfacetypecheck2.png?300&direct | // Type descriptor with //checkIds// of its interfaces //}}]
-All the affected interfaces get numbered (//chkId//) and will be inserted into the table starting with the highest number. The checking can now run as follows: the compiler knows the //chkId// of the interface to check against. It will search //chkId// in the table. If found the check returns ''true'' else ''false''. The last entry must be 0 in order to end the search.\\ +All the affected interfaces get numbered (//chkId//) and will be inserted into the table starting with the highest number. The checking can now run as follows: the compiler knows the //chkId// of the interface to check against. It will search //chkId// in the table. If foundthe check returns ''true'' else ''false''. The last entry must be 0 in order to end the search.\\ 
-Here again, //checkcast// and//instanceof// differ slightly.+Here again, //checkcast// and //instanceof// differ slightly.
  
 ==== Complex Use Case ==== ==== Complex Use Case ====
 The following code  The following code 
 <code java> <code java>
-  Object[][][] a1 = new Object[2][3][4];+  Object[][][] = new Object[2][3][4]; 
   A[] x = new AA[5];   A[] x = new AA[5];
-  a1[0][0] = x; +  o[0][0] = x; 
-  a1[0][1][2] = x;+  o[0][1][2] = x;
   short[][] y = new short[2][3];   short[][] y = new short[2][3];
-  a1[1][0] = y; +  o[1][0] = y; 
-  a1[1][1][0] = y;+  o[1][1][0] = y;
 </code> </code>
 leads to\\ leads to\\
 [{{ .:typecheckexample1.png?600|//Type descriptors for complex use case//}}]\\ [{{ .:typecheckexample1.png?600|//Type descriptors for complex use case//}}]\\
-This example can be found in the test cases (//ch.ntb.inf.deep.comp.targettest.arrays.ArrayInstanceTest.testInstance4//).+This example can be found in the test cases (//org.deepjava.comp.targettest.arrays.ArrayInstanceTest.testInstance4//).
dev/crosscompiler/type_checking.1456403585.txt.gz · Last modified: 2016/02/25 13:33 by 127.0.0.1