}
private JField createEnumValueMap(JEnumType type) {
SourceInfo sourceInfo = type.getSourceInfo().makeChild(
JavaASTGenerationVisitor.class, "enum value lookup map");
JsonObject map = new JsonObject(sourceInfo, program.getJavaScriptObject());
for (JEnumField field : type.getEnumList()) {
// JSON maps require leading underscores to prevent collisions.
JStringLiteral key = program.getLiteralString(field.getSourceInfo(),
"_" + field.getName());
JFieldRef value = new JFieldRef(sourceInfo, null, field, type);
map.propInits.add(new JsonObject.JsonPropInit(sourceInfo, key, value));
}
JField mapField = program.createField(sourceInfo,
"enum$map".toCharArray(), type, map.getType(), true,
Disposition.FINAL);
// Initialize in clinit.
JMethodBody clinitBody = (JMethodBody) type.getMethods().get(0).getBody();
JExpressionStatement assignment = program.createAssignmentStmt(