use of org.eclipse.ceylon.compiler.typechecker.tree.Tree.PositionalArgument in project ceylon by eclipse.
the class SequenceGenerator method tuple.
static void tuple(final Tree.Tuple that, final GenerateJsVisitor gen) {
SequencedArgument sarg = that.getSequencedArgument();
if (sarg == null) {
gen.out(gen.getClAlias(), "empty()");
} else {
final List<PositionalArgument> positionalArguments = sarg.getPositionalArguments();
final boolean spread = SequenceGenerator.isSpread(positionalArguments);
int lim = positionalArguments.size() - 1;
gen.out(gen.getClAlias(), "tpl$([");
int count = 0;
for (PositionalArgument expr : positionalArguments) {
if (!(count == lim && spread)) {
if (count > 0) {
gen.out(",");
}
expr.visit(gen);
}
count++;
}
gen.out("]");
if (spread) {
gen.out(",");
positionalArguments.get(lim).visit(gen);
}
gen.out(")");
}
}
use of org.eclipse.ceylon.compiler.typechecker.tree.Tree.PositionalArgument in project ceylon by eclipse.
the class NamedArgumentInvocation method getTransformedArgumentExpression.
@Override
protected JCExpression getTransformedArgumentExpression(int argIndex) {
PositionalArgument arg = getPositional().getPositionalArguments().get(argIndex);
// FIXME: I don't like much this weird special case here
if (arg instanceof Tree.ListedArgument) {
Tree.Expression expr = ((Tree.ListedArgument) arg).getExpression();
if (expr.getTerm() instanceof FunctionArgument) {
FunctionArgument farg = (FunctionArgument) expr.getTerm();
Type parameterType = getParameterType(argIndex);
if (isParameterJavaVariadic(argIndex) && parameterType.isSequential()) {
parameterType = gen.typeFact().getSequentialElementType(parameterType);
}
return gen.expressionGen().transform(farg, parameterType);
}
}
// special case for comprehensions which are not expressions
if (arg instanceof Tree.Comprehension) {
Type type = getParameterType(argIndex);
return gen.expressionGen().comprehensionAsSequential((Comprehension) arg, type);
}
return gen.expressionGen().transformArg(this, argIndex);
}
Aggregations