Java 类org.mozilla.javascript.optimizer.ClassCompiler 实例源码

项目:scripturian    文件:RhinoAdapter.java   
/**
 * Constructor.
 * 
 * @throws LanguageAdapterException
 *         In case of an initialization error
 */
public RhinoAdapter() throws LanguageAdapterException
{
    super( "Rhino", getImplementationVersion(), "JavaScript", getLanguageVersion(), Arrays.asList( "js", "javascript", "rhino" ), "js", Arrays.asList( "javascript", "js", "rhino" ), "rhino" );

    CompilerEnvirons compilerEnvirons = new CompilerEnvirons();
    compilerEnvirons.setOptimizationLevel( getOptimizationLevel() );
    classCompiler = new ClassCompiler( compilerEnvirons );
    Context context = enterContext();
    try
    {
        generatedClassLoader = context.createClassLoader( RhinoAdapter.class.getClassLoader() );
    }
    finally
    {
        Context.exit();
    }
}
项目:whackpad    文件:Main.java   
public Main()
{
    reporter = new ToolErrorReporter(true);
    compilerEnv = new CompilerEnvirons();
    compilerEnv.setErrorReporter(reporter);
    compiler = new ClassCompiler(compilerEnv);
}
项目:jasperreports    文件:JavaScriptClassCompiler.java   
protected void compileScripts(JRCompilationUnit unit, CompilerEnvirons compilerEnv, 
        CompileSources compileSources, JavaScriptCompiledData compiledData)
{
    List<String> scripts = compileSources.getScripts();
    int scriptIndex = 0;
    for (String scriptSource : scripts)
    {
        String scriptClassName = unit.getName() + "_" + scriptIndex;

        if (log.isTraceEnabled())
        {
            log.trace("compiling script with name " + scriptClassName
                    + "\n" + scriptSource);
        }

        ClassCompiler compiler = new ClassCompiler(compilerEnv);
        // this should not fail since we've already separately compiled the default expression
        Object[] compilationResult = compiler.compileToClassFiles(scriptSource, unit.getName(), 0, scriptClassName);
        if (compilationResult.length != 2)
        {
            throw 
                new JRRuntimeException(
                    EXCEPTION_MESSAGE_KEY_UNEXPECTED_CLASSES_LENGTH,
                    new Object[]{compilationResult.length});
        }
        if (!scriptClassName.equals(compilationResult[0]))
        {
            throw 
                new JRRuntimeException(
                    EXCEPTION_MESSAGE_KEY_UNEXPECTED_CLASS_NAME,
                    new Object[]{compilationResult[0], scriptClassName});
        }

        byte[] compiledClass = (byte[]) compilationResult[1];
        compiledData.addClass(scriptClassName, compiledClass);

        ++scriptIndex;
    }
}
项目:code404    文件:Main.java   
public Main()
{
    reporter = new ToolErrorReporter(true);
    compilerEnv = new CompilerEnvirons();
    compilerEnv.setErrorReporter(reporter);
    compiler = new ClassCompiler(compilerEnv);
}
项目:S3F    文件:Main.java   
public Main()
{
    reporter = new ToolErrorReporter(true);
    compilerEnv = new CompilerEnvirons();
    compilerEnv.setErrorReporter(reporter);
    compiler = new ClassCompiler(compilerEnv);
}
项目:rhino-jscover    文件:Main.java   
public Main()
{
    reporter = new ToolErrorReporter(true);
    compilerEnv = new CompilerEnvirons();
    compilerEnv.setErrorReporter(reporter);
    compiler = new ClassCompiler(compilerEnv);
}
项目:astor    文件:Main.java   
public Main()
{
    reporter = new ToolErrorReporter(true);
    compilerEnv = new CompilerEnvirons();
    compilerEnv.setErrorReporter(reporter);
    compiler = new ClassCompiler(compilerEnv);
}
项目:Rhino-Prov-Mod    文件:Main.java   
public Main()
{
    reporter = new ToolErrorReporter(true);
    compilerEnv = new CompilerEnvirons();
    compilerEnv.setErrorReporter(reporter);
    compiler = new ClassCompiler(compilerEnv);
}
项目:closure-compiler-old    文件:Main.java   
public Main()
{
    reporter = new ToolErrorReporter(true);
    compilerEnv = new CompilerEnvirons();
    compilerEnv.setErrorReporter(reporter);
    compiler = new ClassCompiler(compilerEnv);
}
项目:closure-compiler-copy    文件:Main.java   
public Main()
{
    reporter = new ToolErrorReporter(true);
    compilerEnv = new CompilerEnvirons();
    compilerEnv.setErrorReporter(reporter);
    compiler = new ClassCompiler(compilerEnv);
}