Search in sources :

Example 6 with Drop

use of com.redhat.ceylon.compiler.java.codegen.recovery.Drop in project ceylon-compiler by ceylon.

the class CeylonVisitor method visit.

public void visit(Tree.AnyMethod decl) {
    TransformationPlan plan = gen.errors().hasDeclarationAndMarkBrokenness(decl);
    if (plan instanceof Drop) {
        return;
    }
    if (!acceptDeclaration(decl))
        return;
    int annots = gen.checkCompilerAnnotations(decl, defs);
    if (Decl.withinClassOrInterface(decl) && (!Decl.isDeferred(decl) || Decl.isCaptured(decl))) {
        classBuilder.method(decl, plan);
    } else {
        appendList(gen.classGen().transformWrappedMethod(decl, plan));
    }
    gen.resetCompilerAnnotations(annots);
}
Also used : TransformationPlan(com.redhat.ceylon.compiler.java.codegen.recovery.TransformationPlan) Drop(com.redhat.ceylon.compiler.java.codegen.recovery.Drop)

Example 7 with Drop

use of com.redhat.ceylon.compiler.java.codegen.recovery.Drop in project ceylon-compiler by ceylon.

the class CeylonVisitor method visit.

public void visit(Tree.AttributeDeclaration decl) {
    TransformationPlan plan = gen.errors().hasDeclarationAndMarkBrokenness(decl);
    if (plan instanceof Drop) {
        return;
    }
    // To accept this method it is either not native, native for this
    // backend or it's a native header with an implementation and there
    // is no native implementation specifically for this backend
    boolean accept = acceptDeclaration(decl);
    if (!accept)
        return;
    int annots = gen.checkCompilerAnnotations(decl, defs);
    if (Decl.withinClassOrInterface(decl) && !Decl.isLocalToInitializer(decl)) {
        // Class attributes
        gen.classGen().transform(decl, classBuilder);
    } else if (Decl.isToplevel(decl)) {
        topattrBuilder.add(decl);
    } else if ((Decl.isLocal(decl)) && ((Decl.isCaptured(decl) && Decl.isVariable(decl)) || Decl.isTransient(decl) || Decl.hasSetter(decl))) {
        // Captured local attributes get turned into an inner getter/setter class
        appendList(gen.transform(decl));
    } else {
        // All other local attributes
        appendList(gen.statementGen().transform(decl));
    }
    gen.resetCompilerAnnotations(annots);
}
Also used : TransformationPlan(com.redhat.ceylon.compiler.java.codegen.recovery.TransformationPlan) Drop(com.redhat.ceylon.compiler.java.codegen.recovery.Drop)

Example 8 with Drop

use of com.redhat.ceylon.compiler.java.codegen.recovery.Drop in project ceylon-compiler by ceylon.

the class CeylonVisitor method visit.

public void visit(Tree.ObjectDefinition decl) {
    TransformationPlan plan = gen.errors().hasDeclarationAndMarkBrokenness(decl);
    if (plan instanceof Drop) {
        return;
    }
    if (skipHeaderMergeLater(decl)) {
        return;
    }
    // To accept this object it is either not native or native for this backend
    if (!acceptDeclaration(decl))
        return;
    int annots = gen.checkCompilerAnnotations(decl, defs);
    if (Decl.withinClass(decl)) {
        classBuilder.defs(gen.classGen().transformObjectDefinition(decl, classBuilder));
    } else {
        appendList(gen.classGen().transformObjectDefinition(decl, null));
    }
    gen.resetCompilerAnnotations(annots);
}
Also used : TransformationPlan(com.redhat.ceylon.compiler.java.codegen.recovery.TransformationPlan) Drop(com.redhat.ceylon.compiler.java.codegen.recovery.Drop)

Example 9 with Drop

use of com.redhat.ceylon.compiler.java.codegen.recovery.Drop in project ceylon-compiler by ceylon.

the class CeylonVisitor method visit.

public void visit(Tree.AttributeGetterDefinition decl) {
    TransformationPlan plan = gen.errors().hasDeclarationAndMarkBrokenness(decl);
    if (plan instanceof Drop) {
        return;
    }
    if (!acceptDeclaration(decl))
        return;
    int annots = gen.checkCompilerAnnotations(decl, defs);
    if (Decl.withinClass(decl) && !Decl.isLocalToInitializer(decl)) {
        classBuilder.attribute(gen.classGen().transform(decl, false));
    } else if (Decl.withinInterface(decl) && !Decl.isLocalToInitializer(decl)) {
        classBuilder.attribute(gen.classGen().transform(decl, false));
        AttributeDefinitionBuilder adb = gen.classGen().transform(decl, true);
        if (decl.getDeclarationModel().isShared()) {
            adb.ignoreAnnotations();
        }
        classBuilder.getCompanionBuilder((Interface) decl.getDeclarationModel().getContainer()).attribute(adb);
    } else if (Decl.isToplevel(decl)) {
        topattrBuilder.add(decl);
    } else {
        appendList(gen.transform(decl));
    }
    gen.resetCompilerAnnotations(annots);
}
Also used : TransformationPlan(com.redhat.ceylon.compiler.java.codegen.recovery.TransformationPlan) Drop(com.redhat.ceylon.compiler.java.codegen.recovery.Drop)

Example 10 with Drop

use of com.redhat.ceylon.compiler.java.codegen.recovery.Drop in project ceylon-compiler by ceylon.

the class CeylonVisitor method visit.

public void visit(final Tree.AttributeSetterDefinition decl) {
    TransformationPlan plan = gen.errors().hasDeclarationAndMarkBrokenness(decl);
    if (plan instanceof Drop) {
        return;
    }
    TransformationPlan getterPlan = gen.errors().hasDeclarationAndMarkBrokenness(getterSetterPairing.getGetter(decl));
    if (getterPlan instanceof Drop) {
        // because there's little chance we'll be able to generate a correct setter
        return;
    }
    if (!acceptDeclaration(decl))
        return;
    int annots = gen.checkCompilerAnnotations(decl, defs);
    if (Decl.withinClass(decl) && !Decl.isLocalToInitializer(decl)) {
        classBuilder.attribute(gen.classGen().transform(decl, false));
    } else if (Decl.withinInterface(decl)) {
        classBuilder.attribute(gen.classGen().transform(decl, false));
        AttributeDefinitionBuilder adb = gen.classGen().transform(decl, true);
        if (decl.getDeclarationModel().isShared()) {
            adb.ignoreAnnotations();
        }
        classBuilder.getCompanionBuilder((Interface) decl.getDeclarationModel().getContainer()).attribute(adb);
    } else if (Decl.isToplevel(decl)) {
        topattrBuilder.add(decl);
    } else {
        appendList(gen.transform(decl));
    }
    gen.resetCompilerAnnotations(annots);
}
Also used : TransformationPlan(com.redhat.ceylon.compiler.java.codegen.recovery.TransformationPlan) Drop(com.redhat.ceylon.compiler.java.codegen.recovery.Drop)

Aggregations

Drop (com.redhat.ceylon.compiler.java.codegen.recovery.Drop)10 TransformationPlan (com.redhat.ceylon.compiler.java.codegen.recovery.TransformationPlan)9 Tree (com.redhat.ceylon.compiler.typechecker.tree.Tree)3 ClassOrInterface (com.redhat.ceylon.model.typechecker.model.ClassOrInterface)3 Interface (com.redhat.ceylon.model.typechecker.model.Interface)3 JCTree (com.sun.tools.javac.tree.JCTree)3 CustomTree (com.redhat.ceylon.compiler.typechecker.tree.CustomTree)2 Declaration (com.redhat.ceylon.model.typechecker.model.Declaration)2 TypeDeclaration (com.redhat.ceylon.model.typechecker.model.TypeDeclaration)2 JCExpression (com.sun.tools.javac.tree.JCTree.JCExpression)2 JCStatement (com.sun.tools.javac.tree.JCTree.JCStatement)2 SyntheticName (com.redhat.ceylon.compiler.java.codegen.Naming.SyntheticName)1 HasErrorException (com.redhat.ceylon.compiler.java.codegen.recovery.HasErrorException)1 AttributeDeclaration (com.redhat.ceylon.compiler.typechecker.tree.Tree.AttributeDeclaration)1 MethodDeclaration (com.redhat.ceylon.compiler.typechecker.tree.Tree.MethodDeclaration)1 Return (com.redhat.ceylon.compiler.typechecker.tree.Tree.Return)1 Statement (com.redhat.ceylon.compiler.typechecker.tree.Tree.Statement)1 LazyInterface (com.redhat.ceylon.model.loader.model.LazyInterface)1 Class (com.redhat.ceylon.model.typechecker.model.Class)1 Constructor (com.redhat.ceylon.model.typechecker.model.Constructor)1