return new JDeclarationStatement(program, info, new JLocalRef(program,
info, local), value);
}
private JField createEnumValueMap(JEnumType type) {
JsonObject map = new JsonObject(program);
for (JEnumField field : type.enumList) {
// JSON maps require leading underscores to prevent collisions.
JStringLiteral key = program.getLiteralString("_" + field.getName());
JFieldRef value = new JFieldRef(program, null, null, field, type);
map.propInits.add(new JsonObject.JsonPropInit(program, key, value));
}
JField mapField = program.createField(null, "enum$map".toCharArray(),
type, map.getType(), true, Disposition.FINAL);
// Initialize in clinit.
JMethodBody clinitBody = (JMethodBody) type.methods.get(0).getBody();
JExpressionStatement assignment = program.createAssignmentStmt(null,
createVariableRef(null, mapField), map);