use of org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCStatement in project ceylon by eclipse.
the class NamedArgumentInvocation method bindObjectArgument.
private void bindObjectArgument(Tree.ObjectArgument objectArg, Parameter declaredParam, Naming.SyntheticName argName) {
ListBuffer<JCStatement> statements;
List<JCTree> object = gen.classGen().transformObjectArgument(objectArg);
// No need to worry about boxing (it cannot be a boxed type)
JCVariableDecl varDecl = gen.makeLocalIdentityInstance(argName.getName(), Naming.quoteClassName(objectArg.getIdentifier().getText()), false);
statements = toStmts(objectArg, object).append(varDecl);
bind(declaredParam, argName, gen.makeJavaType(objectArg.getType().getTypeModel()), statements.toList());
}
use of org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCStatement in project ceylon by eclipse.
the class AbstractTransformer method makeGetterBlock.
JCBlock makeGetterBlock(final JCExpression expression) {
List<JCStatement> stats = List.<JCStatement>of(make().Return(expression));
JCBlock getterBlock = make().Block(0, stats);
return getterBlock;
}
use of org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCStatement 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