com.sun.tools.javac.comp
Class Lower.EnumMapping
java.lang.Object
com.sun.tools.javac.comp.Lower.EnumMapping
- Enclosing class:
- Lower
class Lower.EnumMapping
- extends java.lang.Object
This map gives a translation table to be used for enum
switches.
For each enum that appears as the type of a switch
expression, we maintain an EnumMapping to assist in the
translation, as exemplified by the following example:
we translate
switch(colorExpression) {
case red: stmt1;
case green: stmt2;
}
into
switch(Outer$0.$EnumMap$Color[colorExpression.ordinal()]) {
case 1: stmt1;
case 2: stmt2
}
with the auxilliary table intialized as follows:
class Outer$0 {
synthetic final int[] $EnumMap$Color = new int[Color.values().length];
static {
try { $EnumMap$Color[red.ordinal()] = 1; } catch (NoSuchFieldError ex) {}
try { $EnumMap$Color[green.ordinal()] = 2; } catch (NoSuchFieldError ex) {}
}
}
class EnumMapping provides mapping data and support methods for this translation.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
pos
JCDiagnostic.DiagnosticPosition pos
next
int next
forEnum
final Symbol.TypeSymbol forEnum
mapVar
final Symbol.VarSymbol mapVar
values
final java.util.Map<Symbol.VarSymbol,java.lang.Integer> values
Lower.EnumMapping
Lower.EnumMapping(JCDiagnostic.DiagnosticPosition pos,
Symbol.TypeSymbol forEnum)
forConstant
JCTree.JCLiteral forConstant(Symbol.VarSymbol v)
translate
void translate()