use of org.eclipse.ceylon.compiler.java.codegen.Naming.SyntheticName in project ceylon by eclipse.
the class AttributeDefinitionBuilder method initValueField.
/**
* Generate the initializer statements where the field gets set to its initial value
*/
private List<JCStatement> initValueField() {
List<JCStatement> stmts = List.<JCStatement>nil();
JCExpression initValue = this.initialValue;
if (initValue == null) {
initValue = this.memoizedInitialValue;
}
if (initValue != null) {
if (useJavaBox && initialValueBoxing != BoxingStrategy.JAVA) {
SyntheticName temp = owner.naming.temp();
JCExpression type = owner.makeJavaType(attrType, initialValueBoxing == BoxingStrategy.BOXED ? AbstractTransformer.JT_NO_PRIMITIVES : 0);
initValue = owner.make().LetExpr(owner.makeVar(temp, type, initValue), owner.make().Conditional(owner.make().Binary(JCTree.Tag.EQ, temp.makeIdent(), owner.makeNull()), owner.makeNull(), owner.boxJavaType(owner.unboxType(temp.makeIdent(), owner.simplifyType(attrType)), owner.simplifyType(attrType))));
}
stmts = stmts.prepend(owner.make().Exec(owner.make().Assign(makeValueFieldAccess(), initValue)));
}
return stmts;
}
Aggregations