public static void emitShader(TranslationUnit shader, Optional<String> license, PrintStream stream, int indentationWidth, Supplier<String> newlineSupplier, boolean emitGraphicsFuzzDefines) { new PrettyPrinterVisitor(stream, indentationWidth, newlineSupplier, emitGraphicsFuzzDefines, license).visit(shader); }
/** * Returns, via pretty printing, a string representation of the given node. * * @param node Node for which string representation is required * @return String representation of the node */ public static String prettyPrintAsString(IAstNode node) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); new PrettyPrinterVisitor(new PrintStream(bytes)).visit(node); return new String(bytes.toByteArray(), StandardCharsets.UTF_8); }
/** * Uses the pretty printer to turn a node into a text representation. * @return Text representation of a node */ default String getText() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (PrintStream stream = new PrintStream(baos)) { new PrettyPrinterVisitor(stream).visit(this); return baos.toString("UTF8"); } catch (UnsupportedEncodingException exception) { return "<unknown>"; } }
private static void prettyPrintShader(Namespace ns, TranslationUnit tu) throws FileNotFoundException { try (PrintStream stream = new PrintStream(new FileOutputStream(new File(ns.getString("output"))))) { if (getGlslVersion(ns) != null) { throw new RuntimeException(); //Helper.emitDefines(stream, new ShadingLanguageVersion(getGlslVersion(ns), false), // false); } PrettyPrinterVisitor ppv = new PrettyPrinterVisitor(stream); ppv.visit(tu); } }
public static void main(String[] args) throws IOException, ParseTimeoutException { TranslationUnit tu = ParseHelper.parse(new File(args[0])); new PrettyPrinterVisitor(System.out).visit(transform(tu)); }
public static void main(String[] args) { if (args.length != 1) { System.err.print("Usage: seed"); System.exit(1); } new PrettyPrinterVisitor(System.out) .visit(new Fuzzer(new FuzzingContext(), ShadingLanguageVersion.GLSL_440, new RandomWrapper(Integer.parseInt(args[0])), GenerationParams.normal(ShaderKind.FRAGMENT, true)).fuzzTranslationUnit()); }
public static void main(String[] args) throws IOException, ParseTimeoutException { if (args.length != 1) { System.err.println("Usage: Simplifier <file>.json"); System.exit(1); } File inputShaderJobFile = new File(args[0]); ShaderJobFileOperations fileOps = new ShaderJobFileOperations(); ShaderJob shaderJob = fileOps.readShaderJobFile(inputShaderJobFile); // TODO: Warning: assumes only one shader fragment shader. LOGGER.warn("WARNING: assumes only fragment shaders."); shaderJob = new GlslShaderJob( shaderJob.getLicense(), shaderJob.getUniformsInfo(), Simplify.simplify(shaderJob.getShaders().get(0))); String[] firstTwoLines = fileOps.getFirstTwoLinesOfShader(inputShaderJobFile, ShaderKind.FRAGMENT); PrintStream ps = fileOps.getStdOut(); new PrettyPrinterVisitor(ps, PrettyPrinterVisitor.DEFAULT_INDENTATION_WIDTH, PrettyPrinterVisitor.DEFAULT_NEWLINE_SUPPLIER, true, Optional.empty()).visit(shaderJob.getFragmentShader().get()); ps.flush(); } }