use of com.redhat.ceylon.compiler.typechecker.tree.Tree.SequencedArgument in project ceylon-compiler by ceylon.
the class NamedArgumentInvocation method buildVars.
/**
* Constructs the vars used in the Let expression
*/
private void buildVars() {
if (getPrimaryDeclaration() == null) {
return;
}
boolean prev = gen.expressionGen().withinInvocation(false);
java.util.List<Tree.NamedArgument> namedArguments = namedArgumentList.getNamedArguments();
SequencedArgument sequencedArgument = namedArgumentList.getSequencedArgument();
java.util.List<ParameterList> paramLists = ((Functional) getPrimaryDeclaration()).getParameterLists();
java.util.List<Parameter> declaredParams = paramLists.get(0).getParameters();
appendVarsForNamedArguments(namedArguments, declaredParams);
appendVarsForReifiedTypeArguments();
if (sequencedArgument != null)
appendVarsForSequencedArguments(sequencedArgument, declaredParams);
boolean hasDefaulted = appendVarsForDefaulted(declaredParams);
if (hasDefaulted && !Strategy.defaultParameterMethodStatic(getPrimaryDeclaration()) && !Strategy.defaultParameterMethodOnOuter(getPrimaryDeclaration())) {
vars.prepend(makeThis());
}
gen.expressionGen().withinInvocation(prev);
}
use of com.redhat.ceylon.compiler.typechecker.tree.Tree.SequencedArgument in project ceylon-compiler by ceylon.
the class ClassTransformer method transformAnnotationParameterDefault.
private JCExpression transformAnnotationParameterDefault(Tree.Parameter p) {
Tree.SpecifierOrInitializerExpression defaultArgument = Decl.getDefaultArgument(p);
Tree.Expression defaultExpression = defaultArgument.getExpression();
Tree.Term term = defaultExpression.getTerm();
JCExpression defaultLiteral = null;
if (term instanceof Tree.Literal && !(term instanceof Tree.QuotedLiteral)) {
defaultLiteral = expressionGen().transform((Tree.Literal) term);
} else if (term instanceof Tree.BaseMemberExpression) {
Tree.BaseMemberExpression bme = (Tree.BaseMemberExpression) term;
Declaration decl = bme.getDeclaration();
if (isBooleanTrue(decl)) {
defaultLiteral = makeBoolean(true);
} else if (isBooleanFalse(decl)) {
defaultLiteral = makeBoolean(false);
} else if (typeFact().isEmptyType(bme.getTypeModel())) {
defaultLiteral = make().NewArray(null, null, List.<JCExpression>nil());
} else if (Decl.isAnonCaseOfEnumeratedType(bme)) {
defaultLiteral = makeClassLiteral(bme.getTypeModel());
} else {
defaultLiteral = make().Literal(bme.getDeclaration().getQualifiedNameString());
}
} else if (term instanceof Tree.MemberOrTypeExpression) {
Tree.MemberOrTypeExpression mte = (Tree.MemberOrTypeExpression) term;
defaultLiteral = make().Literal(mte.getDeclaration().getQualifiedNameString());
} else if (term instanceof Tree.SequenceEnumeration) {
Tree.SequenceEnumeration seq = (Tree.SequenceEnumeration) term;
SequencedArgument sequencedArgument = seq.getSequencedArgument();
defaultLiteral = makeArrayInitializer(sequencedArgument);
} else if (term instanceof Tree.Tuple) {
Tree.Tuple seq = (Tree.Tuple) term;
SequencedArgument sequencedArgument = seq.getSequencedArgument();
defaultLiteral = makeArrayInitializer(sequencedArgument);
} else if (term instanceof Tree.InvocationExpression) {
// Allow invocations of annotation constructors, so long as they're
// themselves being invoked with permitted arguments
Tree.InvocationExpression invocation = (Tree.InvocationExpression) term;
try {
defaultLiteral = AnnotationInvocationVisitor.transform(expressionGen(), invocation);
} catch (BugException e) {
defaultLiteral = e.makeErroneous(this, invocation);
}
} else if (term instanceof Tree.MemberLiteral) {
defaultLiteral = expressionGen().makeMetaLiteralStringLiteralForAnnotation((Tree.MemberLiteral) term);
} else if (term instanceof Tree.TypeLiteral) {
defaultLiteral = expressionGen().makeMetaLiteralStringLiteralForAnnotation((Tree.TypeLiteral) term);
}
if (defaultLiteral == null) {
defaultLiteral = makeErroneous(p, "compiler bug: " + p.getParameterModel().getName() + " has an unsupported defaulted parameter expression");
}
return defaultLiteral;
}
Aggregations