use of org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCExpression in project ceylon by eclipse.
the class AbstractTransformer method makeAtLocalContainer.
protected List<JCAnnotation> makeAtLocalContainer(List<String> path, String companionClassName) {
if (path.isEmpty())
return List.nil();
ListBuffer<JCExpression> array = new ListBuffer<JCTree.JCExpression>();
for (String val : path) array.add(make().Literal(val));
JCExpression pathAttr = make().Assign(naming.makeUnquotedIdent("path"), make().NewArray(null, null, array.toList()));
JCExpression companionAttr = make().Assign(naming.makeUnquotedIdent("companionClassName"), make().Literal(companionClassName == null ? "" : companionClassName));
return makeModelAnnotation(syms().ceylonAtLocalContainerType, List.of(pathAttr, companionAttr));
}
use of org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCExpression in project ceylon by eclipse.
the class AbstractTransformer method makeNonEmptyTest.
JCExpression makeNonEmptyTest(JCExpression firstTimeExpr) {
Interface sequence = typeFact().getSequenceDeclaration();
JCExpression sequenceType = makeJavaType(sequence.getType(), JT_NO_PRIMITIVES | JT_RAW);
return make().TypeTest(firstTimeExpr, sequenceType);
}
use of org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCExpression in project ceylon by eclipse.
the class AbstractTransformer method makeAtClass.
List<JCAnnotation> makeAtClass(Type thisType, Type extendedType, boolean hasConstructors) {
boolean isBasic = true;
boolean isIdentifiable = true;
boolean isAnything = extendedType == null && thisType != null && thisType.isExactly(typeFact().getAnythingType());
if (isAnything) {
// special for Anything
isBasic = isIdentifiable = false;
} else if (thisType != null) {
isBasic = thisType.getSupertype(typeFact.getBasicDeclaration()) != null;
// if isBasic, then isIdentifiable remains true
if (!isBasic)
isIdentifiable = thisType.getSupertype(typeFact.getIdentifiableDeclaration()) != null;
}
String extendedTypeSig = null;
if (isAnything) {
extendedTypeSig = "";
} else if (extendedType != null && !extendedType.isExactly(typeFact.getBasicType())) {
extendedTypeSig = serialiseTypeSignature(extendedType);
}
List<JCExpression> attributes = List.nil();
if (extendedTypeSig != null) {
JCExpression extendsAttribute = make().Assign(naming.makeUnquotedIdent("extendsType"), make().Literal(extendedTypeSig));
attributes = attributes.prepend(extendsAttribute);
}
if (!isBasic) {
JCExpression basicAttribute = make().Assign(naming.makeUnquotedIdent("basic"), makeBoolean(false));
attributes = attributes.prepend(basicAttribute);
}
if (!isIdentifiable) {
JCExpression identifiableAttribute = make().Assign(naming.makeUnquotedIdent("identifiable"), makeBoolean(false));
attributes = attributes.prepend(identifiableAttribute);
}
if (hasConstructors) {
JCExpression constructorsAttribute = make().Assign(naming.makeUnquotedIdent("constructors"), makeBoolean(true));
attributes = attributes.prepend(constructorsAttribute);
}
return makeModelAnnotation(syms().ceylonAtClassType, attributes);
}
use of org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCExpression in project ceylon by eclipse.
the class AbstractTransformer method makeLocalIdentityInstance.
// Creates a "foo foo = new foo(parameter);"
JCTree.JCVariableDecl makeLocalIdentityInstance(JCExpression typeExpr, String varName, String className, boolean isShared, JCTree.JCExpression parameter) {
JCExpression initValue = makeNewClass(className, false, parameter);
int modifiers = isShared ? 0 : FINAL;
JCTree.JCVariableDecl var = make().VarDef(make().Modifiers(modifiers), names().fromString(Naming.quoteLocalValueName(varName)), typeExpr, initValue);
return var;
}
use of org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCExpression in project ceylon by eclipse.
the class AbstractTransformer method unboxOptionalString.
private JCExpression unboxOptionalString(JCExpression value) {
if (isStringLiteral(value)) {
// If it's already a String literal, why call .toString on it?
return value;
}
Naming.SyntheticName name = naming.temp();
JCExpression type = makeJavaType(typeFact().getStringType(), JT_NO_PRIMITIVES);
JCExpression expr = make().Conditional(make().Binary(JCTree.Tag.NE, name.makeIdent(), makeNull()), unboxString(name.makeIdent()), makeNull());
return makeLetExpr(name, null, type, value, expr);
}
Aggregations