Search in sources :

Example 1 with InvocationAnnotationTerm

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

the class AnnotationLoader method loadAnnotationConstructorDefaultedParameter.

private AnnotationTerm loadAnnotationConstructorDefaultedParameter(LazyFunction method, MethodMirror meth, Parameter ctorParam, AnnotationConstructorParameter acp) {
    // Find the method mirror for the DPM
    for (MethodMirror mm : method.classMirror.getDirectMethods()) {
        if (mm.getName().equals(Naming.getDefaultedParamMethodName(method, ctorParam))) {
            // Create the appropriate AnnotationTerm
            if (mm.getAnnotation(AbstractModelLoader.CEYLON_ANNOTATION_INSTANTIATION_ANNOTATION) != null) {
                // If the DPM has a @AnnotationInstantiation
                // then it must be an invocation term so recurse
                InvocationAnnotationTerm invocationTerm = new InvocationAnnotationTerm();
                invocationTerm.setInstantiation(loadAnnotationInvocation(method, mm, meth));
                return invocationTerm;
            } else {
                return loadLiteralAnnotationTerm(method, ctorParam, mm);
            }
        }
    }
    return null;
}
Also used : MethodMirror(com.redhat.ceylon.model.loader.mirror.MethodMirror) InvocationAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.InvocationAnnotationTerm)

Example 2 with InvocationAnnotationTerm

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

the class AnnotationLoader method decode.

private AnnotationTerm decode(Module moduleScope, List<Parameter> sourceParameters, AnnotationInvocation info, Parameter parameter, AnnotatedMirror dpm, List<AnnotationFieldName> path, int code) {
    AnnotationTerm result;
    if (code == Short.MIN_VALUE) {
        return findLiteralAnnotationTerm(moduleScope, path, parameter, dpm);
    } else if (code < 0) {
        InvocationAnnotationTerm invocation = new InvocationAnnotationTerm();
        result = invocation;
    } else if (code >= 0 && code < 512) {
        ParameterAnnotationTerm parameterArgument = new ParameterAnnotationTerm();
        boolean spread = false;
        if (code >= 256) {
            spread = true;
            code -= 256;
        }
        parameterArgument.setSpread(spread);
        Parameter sourceParameter = sourceParameters.get(code);
        parameterArgument.setSourceParameter(sourceParameter);
        // result.setTargetParameter(sourceParameter);
        result = parameterArgument;
    } else {
        throw new RuntimeException();
    }
    return result;
}
Also used : ParameterAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.ParameterAnnotationTerm) Parameter(com.redhat.ceylon.model.typechecker.model.Parameter) AnnotationConstructorParameter(com.redhat.ceylon.compiler.java.codegen.AnnotationConstructorParameter) InvocationAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.InvocationAnnotationTerm) ObjectLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.ObjectLiteralAnnotationTerm) CollectionLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm) DeclarationLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.DeclarationLiteralAnnotationTerm) StringLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.StringLiteralAnnotationTerm) BooleanLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.BooleanLiteralAnnotationTerm) CharacterLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.CharacterLiteralAnnotationTerm) LiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.LiteralAnnotationTerm) ParameterAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.ParameterAnnotationTerm) AnnotationTerm(com.redhat.ceylon.compiler.java.codegen.AnnotationTerm) InvocationAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.InvocationAnnotationTerm) FloatLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.FloatLiteralAnnotationTerm) IntegerLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.IntegerLiteralAnnotationTerm)

Example 3 with InvocationAnnotationTerm

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

the class AnnotationLoader method loadAnnotationArgumentTerm.

private AnnotationTerm loadAnnotationArgumentTerm(List<AnnotationFieldName> path, LazyFunction method, AnnotationInvocation ai, Parameter parameter, List<AnnotationMirror> annotationTree, AnnotatedMirror dpm, short code) {
    if (code < 0 && code != Short.MIN_VALUE) {
        AnnotationMirror i = annotationTree.get(-code);
        AnnotationInvocation nested = new AnnotationInvocation();
        setPrimaryFromAnnotationInvocationAnnotation(i, nested);
        loadAnnotationInvocationArguments(path, method, nested, i, annotationTree, dpm);
        InvocationAnnotationTerm term = new InvocationAnnotationTerm();
        term.setInstantiation(nested);
        return term;
    } else {
        AnnotationTerm term = decode(Decl.getModuleContainer(method), method.getFirstParameterList().getParameters(), ai, parameter, dpm, path, code);
        return term;
    }
}
Also used : AnnotationMirror(com.redhat.ceylon.model.loader.mirror.AnnotationMirror) AnnotationInvocation(com.redhat.ceylon.compiler.java.codegen.AnnotationInvocation) InvocationAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.InvocationAnnotationTerm) ObjectLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.ObjectLiteralAnnotationTerm) CollectionLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm) DeclarationLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.DeclarationLiteralAnnotationTerm) StringLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.StringLiteralAnnotationTerm) BooleanLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.BooleanLiteralAnnotationTerm) CharacterLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.CharacterLiteralAnnotationTerm) LiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.LiteralAnnotationTerm) ParameterAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.ParameterAnnotationTerm) AnnotationTerm(com.redhat.ceylon.compiler.java.codegen.AnnotationTerm) InvocationAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.InvocationAnnotationTerm) FloatLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.FloatLiteralAnnotationTerm) IntegerLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.IntegerLiteralAnnotationTerm)

Aggregations

InvocationAnnotationTerm (com.redhat.ceylon.compiler.java.codegen.InvocationAnnotationTerm)3 AnnotationTerm (com.redhat.ceylon.compiler.java.codegen.AnnotationTerm)2 BooleanLiteralAnnotationTerm (com.redhat.ceylon.compiler.java.codegen.BooleanLiteralAnnotationTerm)2 CharacterLiteralAnnotationTerm (com.redhat.ceylon.compiler.java.codegen.CharacterLiteralAnnotationTerm)2 CollectionLiteralAnnotationTerm (com.redhat.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm)2 DeclarationLiteralAnnotationTerm (com.redhat.ceylon.compiler.java.codegen.DeclarationLiteralAnnotationTerm)2 FloatLiteralAnnotationTerm (com.redhat.ceylon.compiler.java.codegen.FloatLiteralAnnotationTerm)2 IntegerLiteralAnnotationTerm (com.redhat.ceylon.compiler.java.codegen.IntegerLiteralAnnotationTerm)2 LiteralAnnotationTerm (com.redhat.ceylon.compiler.java.codegen.LiteralAnnotationTerm)2 ObjectLiteralAnnotationTerm (com.redhat.ceylon.compiler.java.codegen.ObjectLiteralAnnotationTerm)2 ParameterAnnotationTerm (com.redhat.ceylon.compiler.java.codegen.ParameterAnnotationTerm)2 StringLiteralAnnotationTerm (com.redhat.ceylon.compiler.java.codegen.StringLiteralAnnotationTerm)2 AnnotationConstructorParameter (com.redhat.ceylon.compiler.java.codegen.AnnotationConstructorParameter)1 AnnotationInvocation (com.redhat.ceylon.compiler.java.codegen.AnnotationInvocation)1 AnnotationMirror (com.redhat.ceylon.model.loader.mirror.AnnotationMirror)1 MethodMirror (com.redhat.ceylon.model.loader.mirror.MethodMirror)1 Parameter (com.redhat.ceylon.model.typechecker.model.Parameter)1