Search in sources :

Example 71 with JCStatement

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());
}
Also used : JCTree(org.eclipse.ceylon.langtools.tools.javac.tree.JCTree) JCStatement(org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCStatement) JCVariableDecl(org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCVariableDecl)

Example 72 with JCStatement

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;
}
Also used : JCBlock(org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCBlock) JCStatement(org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCStatement)

Example 73 with JCStatement

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;
}
Also used : JCExpression(org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCExpression) SyntheticName(org.eclipse.ceylon.compiler.java.codegen.Naming.SyntheticName) JCStatement(org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCStatement)

Aggregations

JCStatement (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCStatement)73 JCExpression (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCExpression)52 JCTree (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree)38 Tree (org.eclipse.ceylon.compiler.typechecker.tree.Tree)31 Type (org.eclipse.ceylon.model.typechecker.model.Type)29 SyntheticName (org.eclipse.ceylon.compiler.java.codegen.Naming.SyntheticName)25 ListBuffer (org.eclipse.ceylon.langtools.tools.javac.util.ListBuffer)21 TypeParameter (org.eclipse.ceylon.model.typechecker.model.TypeParameter)18 JCVariableDecl (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCVariableDecl)16 Parameter (org.eclipse.ceylon.model.typechecker.model.Parameter)15 TypedDeclaration (org.eclipse.ceylon.model.typechecker.model.TypedDeclaration)13 Value (org.eclipse.ceylon.model.typechecker.model.Value)13 Function (org.eclipse.ceylon.model.typechecker.model.Function)12 HasErrorException (org.eclipse.ceylon.compiler.java.codegen.recovery.HasErrorException)11 FunctionOrValue (org.eclipse.ceylon.model.typechecker.model.FunctionOrValue)11 CustomTree (org.eclipse.ceylon.compiler.typechecker.tree.CustomTree)10 Expression (org.eclipse.ceylon.compiler.typechecker.tree.Tree.Expression)10 JCBlock (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCBlock)10 JCPrimitiveTypeTree (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCPrimitiveTypeTree)10 Declaration (org.eclipse.ceylon.model.typechecker.model.Declaration)10