Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
software:deep:dev:rts:enums [2014-04-25 17:27] grafsoftware:deep:dev:rts:enums [Unbekanntes Datum] (aktuell) – gelöscht - Externe Bearbeitung (Unbekanntes Datum) 127.0.0.1
Zeile 1: Zeile 1:
-====== Enumerations ====== +
-Enumerations are supported. In an enum class two synthetic methods are created in the Bystecode. +
-  * values(): returns an array with all values, uses //System.arraycopy// +
-  * valueOf(String name): returns the value with the name //name//. This method calls //valueOf// of the class //Enum//. Though with a slightly different signature than what is present in our runtime library. That's why this case must be specially handled by the class file reader. Further, in the SSA a reference to the field //ENUM$VALUES// (which is synthetic as well) must be loaded. Finally, during code generation the address of this field has to be loaded and the reference to it must be fetched. +
-\\ +
-If enum values are used in a switch statement, a special field //$SWITCH_TABLE$CLASSNAME// will be created in the class with the switch statement. Further, a method is generated with the signature //static int[] $SWITCH_TABLE$CLASSNAME()//. This method is called before the first use of the switch statement. It initializes an int-array with the ordinal numbers of the enum entries. \\ +
-An excellent reference to the internals of enums can be found at [[http://www.straub.as/java/basic/enums.html]].+