com.redhat.ceylon.compiler.java.codegen.LiteralAnnotationTerm Maven / Gradle / Ivy
package com.redhat.ceylon.compiler.java.codegen;
import com.redhat.ceylon.langtools.tools.javac.tree.JCTree.JCAnnotation;
import com.redhat.ceylon.langtools.tools.javac.tree.JCTree.JCExpression;
import com.redhat.ceylon.langtools.tools.javac.util.ListBuffer;
/**
* An argument to an annotation class instantiation that is a 'literal'.
* Despite the name this is used for the top level objects {@code true}
* and {@code false} as well as Number, Float, Character and
* String literals.
*/
public abstract class LiteralAnnotationTerm extends AnnotationTerm {
public LiteralAnnotationTerm() {}
public abstract String toString();
@Override
public int encode(AbstractTransformer gen, ListBuffer instantiations) {
return Short.MIN_VALUE;
}
@Override
public JCExpression makeAnnotationArgumentValue(
ExpressionTransformer exprGen, AnnotationInvocation ai,
com.redhat.ceylon.langtools.tools.javac.util.List fieldPath) {
return makeLiteral(exprGen);
}
@Override
public com.redhat.ceylon.langtools.tools.javac.util.List makeDpmAnnotations(
ExpressionTransformer exprGen) {
return makeAtValue(exprGen, null, makeLiteral(exprGen));
}
protected abstract JCExpression makeLiteral(ExpressionTransformer exprGen);
protected abstract com.redhat.ceylon.langtools.tools.javac.util.List makeAtValue(ExpressionTransformer exprGen, String name, JCExpression value);
@Override
public final com.redhat.ceylon.langtools.tools.javac.util.List makeExprAnnotations(
ExpressionTransformer exprGen, AnnotationInvocation toplevel,
com.redhat.ceylon.langtools.tools.javac.util.List fieldPath) {
return makeAtValue(exprGen, Naming.getAnnotationFieldName(fieldPath), makeLiteral(exprGen));
}
@Override
public abstract com.redhat.ceylon.langtools.tools.javac.util.List makeExprs(ExpressionTransformer exprGen, com.redhat.ceylon.langtools.tools.javac.util.List value);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy