Search in sources :

Example 11 with TransformationPlan

use of org.eclipse.ceylon.compiler.java.codegen.recovery.TransformationPlan in project ceylon by eclipse.

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);
    Value dec = decl.getDeclarationModel();
    if (dec.isClassOrInterfaceMember() && !ModelUtil.isLocalToInitializer(dec) || dec.isStatic()) {
        // Class attributes
        gen.classGen().transform(decl, classBuilder);
    } else if (dec.isToplevel()) {
        topattrBuilder.add(decl);
    } else if (Decl.isLocal(dec) && (ModelUtil.isCaptured(dec) && Decl.isVariable(dec) || dec.isTransient() || Decl.hasSetter(dec))) {
        // 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 : FunctionOrValue(org.eclipse.ceylon.model.typechecker.model.FunctionOrValue) Value(org.eclipse.ceylon.model.typechecker.model.Value) TransformationPlan(org.eclipse.ceylon.compiler.java.codegen.recovery.TransformationPlan) Drop(org.eclipse.ceylon.compiler.java.codegen.recovery.Drop)

Aggregations

TransformationPlan (org.eclipse.ceylon.compiler.java.codegen.recovery.TransformationPlan)11 Drop (org.eclipse.ceylon.compiler.java.codegen.recovery.Drop)9 Tree (org.eclipse.ceylon.compiler.typechecker.tree.Tree)4 JCTree (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree)4 ClassOrInterface (org.eclipse.ceylon.model.typechecker.model.ClassOrInterface)4 Interface (org.eclipse.ceylon.model.typechecker.model.Interface)4 JCPrimitiveTypeTree (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCPrimitiveTypeTree)3 FunctionOrValue (org.eclipse.ceylon.model.typechecker.model.FunctionOrValue)3 ThrowerCatchallConstructor (org.eclipse.ceylon.compiler.java.codegen.recovery.ThrowerCatchallConstructor)2 JCExpression (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCExpression)2 JCNewClass (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCNewClass)2 JCStatement (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCStatement)2 ListBuffer (org.eclipse.ceylon.langtools.tools.javac.util.ListBuffer)2 LazyInterface (org.eclipse.ceylon.model.loader.model.LazyInterface)2 Class (org.eclipse.ceylon.model.typechecker.model.Class)2 TypeAlias (org.eclipse.ceylon.model.typechecker.model.TypeAlias)2 Value (org.eclipse.ceylon.model.typechecker.model.Value)2 SyntheticName (org.eclipse.ceylon.compiler.java.codegen.Naming.SyntheticName)1 Generate (org.eclipse.ceylon.compiler.java.codegen.recovery.Generate)1 PrivateConstructorOnly (org.eclipse.ceylon.compiler.java.codegen.recovery.PrivateConstructorOnly)1