private void setFunctionCall(ParseTree ctx, String fnName, List<ExpressionContext> ecs) { try { set(ctx, FunctionCall.of(fnName, asExpressions(ecs))); } catch (NodeException ex) { throw new InternalCompilerException(); } }
public static FunctionCall of(String jiffleName, Expression ...args) throws NodeException { JiffleType[] argTypes = (args == null) ? new JiffleType[0] : new JiffleType[args.length]; for (int i = 0; i < argTypes.length; i++) { argTypes[i] = args[i].getType(); } try { FunctionInfo info = FunctionLookup.getInfo(jiffleName, argTypes); return new FunctionCall(info, args); } catch (UndefinedFunctionException ex) { throw new NodeException(Errors.UNKNOWN_FUNCTION); } }
private void setFunctionCall(ParseTree ctx, String fnName, List<ExpressionContext> ecs) { try { set(ctx, FunctionCall.of(fnName, asExpressions(ecs))); } catch (NodeException ex) { throw new InternalCompilerException(); } }
@Test public void mathFunction() throws Exception { String name = "min"; Expression[] args = { mockDExpr("a"), mockDExpr("b") }; JiffleType[] argTypes = { JiffleType.D, JiffleType.D }; FunctionCall fn = FunctionCall.of(name, args); FunctionInfo info = getFnInfo(name, argTypes); String expected = info.getRuntimeName() + String.format("(%s)", Strings.commas((Object[])args)); assertThat(fn.toString(), is(expected)); }
public static FunctionCall of(String jiffleName, Expression ...args) throws NodeException { JiffleType[] argTypes = (args == null) ? new JiffleType[0] : new JiffleType[args.length]; for (int i = 0; i < argTypes.length; i++) { argTypes[i] = args[i].getType(); } try { FunctionInfo info = FunctionLookup.getInfo(jiffleName, argTypes); return new FunctionCall(info, args); } catch (UndefinedFunctionException ex) { throw new NodeException(Errors.UNKNOWN_FUNCTION); } }
private BinaryExpression offsetLiteral(String pos, double offsetPos) throws NodeException { return new BinaryExpression( PLUS, FunctionCall.of(pos), new DoubleLiteral(String.valueOf(offsetPos))); } }
private BinaryExpression offsetVariable(String pos, String offsetVar) throws NodeException { return new BinaryExpression( PLUS, FunctionCall.of(pos), new Variable(offsetVar, JiffleType.D)); }
@Test public void pixel() throws Exception { Expression x = new IntLiteral("42"); Expression y = FunctionCall.of("y"); Pixel p = new Pixel(x, y); String expected = Strings.commas(x, y); assertThat( p.toString(), is(expected) ); }