public void writeDefaultValue(SourceWriter w) { if (!(left instanceof Variable)) { throw new IllegalStateException("Cannot write default value unless this is a declaration"); } w.indent().append("if (Double.isNaN(").append(left).append(")) {").newLine(); w.inc(); w.indent().append(this).append(";").newLine(); w.dec(); w.line("}"); }
public void write(SourceWriter w) { RuntimeModel runtimeModel = w.getRuntimeModel(); switch (runtimeModel) { case DIRECT: if (w.isInternalBaseClass()) { w.append("d_").append(destVar).append(".write(_x, _y, 0, ").append(expr).append(")"); } else { w.append("writeToImage(\"").append(destVar).append("\", _x, _y, 0, ").append(expr).append(")"); } break; case INDIRECT: w.append("result = ").append(expr); break; default: throw new IllegalArgumentException("Invalid runtime model: " + runtimeModel); } }
w.line("package " + packageName + ";"); w.newLine(); w.line("import java.util.List;"); w.line("import java.util.ArrayList;"); w.line("import java.util.Arrays;"); w.newLine(); String script = w.getScript(); if (script != null) { String[] lines = script.split("\n"); w.line("/**"); w.line(" * Java runtime class generated from the following Jiffle script: "); w.line(" *<code>"); for (String line : lines) { w.append(" * ").append(line).newLine(); w.line(" *</code>"); w.line(" */"); Jiffle.RuntimeModel model = w.getRuntimeModel(); if (model == Jiffle.RuntimeModel.DIRECT) { className = "JiffleDirectRuntimeImpl"; w.line(format(template, className, w.getBaseClassName())); w.inc(); if (w.isInternalBaseClass()) { for (String sourceImage : sourceImages) {
private String createRuntimeSource(RuntimeModel model, String baseClassName, boolean scriptInDocs) { if (scriptInDocs) { throw new RuntimeException("Do no know how to clean the block comments yet"); } SourceWriter writer = new SourceWriter(model); writer.setScript(stripComments(theScript)); writer.setBaseClassName(baseClassName); scriptModel.write(writer); return writer.getSource(); }
/** * Writes out a node to a SourceWriter and returns the resulting script * * @param node * @return */ public String writeToString(Expression node) { SourceWriter sw = new SourceWriter(runtimeModel); node.write(sw); return sw.getSource(); }
public void write(SourceWriter w) { if (declarationNeeded && left instanceof Variable) { String type = getJavaType(); w.append(type).append(" "); } String leftCode = w.writeToString(left); String rightCode = w.writeToString(right); w.append(String.format(op.getFormat(), leftCode, rightCode)); }
public SourceWriter indent() { sb.append(getIndentation()); return this; }
/** * Returns true if the runtime is either {@link it.geosolutions.jaiext.jiffle.runtime.AbstractDirectRuntime} * or {@link it.geosolutions.jaiext.jiffle.runtime.AbstractIndirectRuntime} * @return */ public boolean isInternalBaseClass() { String baseClassName = getBaseClassName(); return AbstractDirectRuntime.class.getName().equals(baseClassName) || AbstractIndirectRuntime.class.getName().equals(baseClassName); } }
w.line("package " + packageName + ";"); w.newLine(); w.line("import java.util.List;"); w.line("import java.util.ArrayList;"); w.line("import java.util.Arrays;"); w.newLine(); String script = w.getScript(); if (script != null) { String[] lines = script.split("\n"); w.line("/**"); w.line(" * Java runtime class generated from the following Jiffle script: "); w.line(" *<code>"); for (String line : lines) { w.append(" * ").append(line).newLine(); w.line(" *</code>"); w.line(" */"); Jiffle.RuntimeModel model = w.getRuntimeModel(); if (model == Jiffle.RuntimeModel.DIRECT) { className = "JiffleDirectRuntimeImpl"; w.line(format(template, className, w.getBaseClassName())); w.inc(); if (w.isInternalBaseClass()) { for (String sourceImage : sourceImages) {
private String createRuntimeSource(RuntimeModel model, String baseClassName, boolean scriptInDocs) { if (scriptInDocs) { throw new RuntimeException("Do no know how to clean the block comments yet"); } SourceWriter writer = new SourceWriter(model); writer.setScript(stripComments(theScript)); writer.setBaseClassName(baseClassName); scriptModel.write(writer); return writer.getSource(); }
/** * Writes out a node to a SourceWriter and returns the resulting script * * @param node * @return */ public String writeToString(Expression node) { SourceWriter sw = new SourceWriter(runtimeModel); node.write(sw); return sw.getSource(); }
public void write(SourceWriter w) { if (declarationNeeded && left instanceof Variable) { String type = getJavaType(); w.append(type).append(" "); } String leftCode = w.writeToString(left); String rightCode = w.writeToString(right); w.append(String.format(op.getFormat(), leftCode, rightCode)); }
public SourceWriter indent() { sb.append(getIndentation()); return this; }
/** * Returns true if the runtime is either {@link it.geosolutions.jaiext.jiffle.runtime.AbstractDirectRuntime} * or {@link it.geosolutions.jaiext.jiffle.runtime.AbstractIndirectRuntime} * @return */ public boolean isInternalBaseClass() { String baseClassName = getBaseClassName(); return AbstractDirectRuntime.class.getName().equals(baseClassName) || AbstractIndirectRuntime.class.getName().equals(baseClassName); } }