Search in sources :

Example 1 with StatefulVisitor

use of org.apache.sling.scripting.sightly.compiler.commands.StatefulVisitor in project sling by apache.

the class JavaClassBackendCompiler method handle.

@Override
public void handle(CommandStream stream) {
    StatefulVisitor statefulVisitor = new StatefulVisitor();
    final CodeGenVisitor visitor = new CodeGenVisitor(unitBuilder, statefulVisitor.getControl());
    statefulVisitor.initializeWith(visitor);
    stream.addHandler(new CommandVisitorHandler(statefulVisitor) {

        @Override
        public void onDone() {
            super.onDone();
            visitor.finish();
        }
    });
}
Also used : CommandVisitorHandler(org.apache.sling.scripting.sightly.java.compiler.impl.CommandVisitorHandler) StatefulVisitor(org.apache.sling.scripting.sightly.compiler.commands.StatefulVisitor) CodeGenVisitor(org.apache.sling.scripting.sightly.java.compiler.impl.CodeGenVisitor)

Example 2 with StatefulVisitor

use of org.apache.sling.scripting.sightly.compiler.commands.StatefulVisitor in project sling by apache.

the class DeadCodeRemoval method transformer.

// this could be merged with constant folding for better accuracy
public static StreamTransformer transformer() {
    return new StreamTransformer() {

        @Override
        public CommandStream transform(CommandStream inStream) {
            StatefulVisitor visitor = new StatefulVisitor();
            DeadCodeRemoval dcr = new DeadCodeRemoval(visitor.getControl());
            visitor.initializeWith(dcr);
            Streams.connect(inStream, dcr.getOutputStream(), visitor);
            return dcr.getOutputStream();
        }
    };
}
Also used : CommandStream(org.apache.sling.scripting.sightly.compiler.commands.CommandStream) StatefulVisitor(org.apache.sling.scripting.sightly.compiler.commands.StatefulVisitor)

Aggregations

StatefulVisitor (org.apache.sling.scripting.sightly.compiler.commands.StatefulVisitor)2 CommandStream (org.apache.sling.scripting.sightly.compiler.commands.CommandStream)1 CodeGenVisitor (org.apache.sling.scripting.sightly.java.compiler.impl.CodeGenVisitor)1 CommandVisitorHandler (org.apache.sling.scripting.sightly.java.compiler.impl.CommandVisitorHandler)1