@Override public void exitConCall(ConCallContext ctx) { List<ExpressionContext> es = ctx.argumentList().expressionList().expression(); Expression[] args = new Expression[es.size()]; for (int i = 0; i < args.length; i++) { args[i] = getAsType(es.get(i), Expression.class); } try { set(ctx, new ConFunction(args)); } catch (NodeException ex) { messages.error(ctx.getStart(), ex.getError()); } }
@Override public void exitConCall(ConCallContext ctx) { List<ExpressionContext> es = ctx.argumentList().expressionList().expression(); Expression[] args = new Expression[es.size()]; for (int i = 0; i < args.length; i++) { args[i] = getAsType(es.get(i), Expression.class); } try { set(ctx, new ConFunction(args)); } catch (NodeException ex) { messages.error(ctx.getStart(), ex.getError()); } }
@Test public void conFunction() throws Exception { Expression[] args = { mockDExpr("a"), mockDExpr("b"), mockDExpr("c") }; String[] argStrs = {"a", "b", "c"}; Node node = new ConFunction(args); String expected = DirectSources.conCall(argStrs); assertThat(node.toString(), is(expected)); }
@Override public void exitTernaryExpr(TernaryExprContext ctx) { Expression[] args = { getAsType(ctx.expression(0), Expression.class), getAsType(ctx.expression(1), Expression.class), getAsType(ctx.expression(2), Expression.class) }; try { set(ctx, new ConFunction(args)); } catch (NodeException ex) { messages.error(ctx.getStart(), ex.getError()); } }
@Override public void exitTernaryExpr(TernaryExprContext ctx) { Expression[] args = { getAsType(ctx.expression(0), Expression.class), getAsType(ctx.expression(1), Expression.class), getAsType(ctx.expression(2), Expression.class) }; try { set(ctx, new ConFunction(args)); } catch (NodeException ex) { messages.error(ctx.getStart(), ex.getError()); } }