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

项目:rhino-android    文件:Bug782363Test.java   
/**
 * Compiles {@code source} and returns the transformed and optimized
 * {@link ScriptNode}
 */
protected ScriptNode compile(CharSequence source) {
    final String mainMethodClassName = "Main";
    final String scriptClassName = "Main";

    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    Parser p = new Parser(compilerEnv);
    AstRoot ast = p.parse(source.toString(), "<eval>", 1);
    IRFactory irf = new IRFactory(compilerEnv);
    ScriptNode tree = irf.transformTree(ast);

    Codegen codegen = new Codegen();
    codegen.setMainMethodClass(mainMethodClassName);
    codegen.compileToClassFile(compilerEnv, scriptClassName, tree, tree.getEncodedSource(),
            false);

    return tree;
}
项目:rhino-android    文件:Bug708801Test.java   
/**
 * Compiles {@code source} and returns the transformed and optimized
 * {@link ScriptNode}
 */
protected ScriptNode compile(CharSequence source) {
    final String mainMethodClassName = "Main";
    final String scriptClassName = "Main";

    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv
            .getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    AstRoot ast = p.parse(source.toString(), "<eval>", 1);
    IRFactory irf = new IRFactory(compilerEnv);
    ScriptNode tree = irf.transformTree(ast);

    Codegen codegen = new Codegen();
    codegen.setMainMethodClass(mainMethodClassName);
    codegen.compileToClassFile(compilerEnv, scriptClassName, tree,
            tree.getEncodedSource(), false);

    return tree;
}
项目:jasperreports    文件:JavaScriptEvaluatorScope.java   
protected ProtectionDomain getProtectionDomain()
{
    ProtectionDomain domain = protectionDomain;
    if (domain == null)
    {
        synchronized (this)
        {
            domain = protectionDomain;
            if (domain == null)
            {
                ProtectionDomainFactory protectionDomainFactory = JRClassLoader.getProtectionDomainFactory();
                domain = protectionDomain = protectionDomainFactory.getProtectionDomain(
                        Codegen.class.getClassLoader());
            }
        }
    }
    return domain;
}
项目:code404    文件:Bug708801Test.java   
/**
 * Compiles {@code source} and returns the transformed and optimized
 * {@link ScriptNode}
 */
protected ScriptNode compile(CharSequence source) {
    final String mainMethodClassName = "Main";
    final String scriptClassName = "Main";

    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv
            .getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    AstRoot ast = p.parse(source.toString(), "<eval>", 1);
    IRFactory irf = new IRFactory(compilerEnv);
    ScriptNode tree = irf.transformTree(ast);

    Codegen codegen = new Codegen();
    codegen.setMainMethodClass(mainMethodClassName);
    codegen.compileToClassFile(compilerEnv, scriptClassName, tree,
            tree.getEncodedSource(), false);

    return tree;
}
项目:rhino-jscover    文件:Bug708801Test.java   
/**
 * Compiles {@code source} and returns the transformed and optimized
 * {@link ScriptNode}
 */
protected ScriptNode compile(CharSequence source) {
    final String mainMethodClassName = "Main";
    final String scriptClassName = "Main";

    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv
            .getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    AstRoot ast = p.parse(source.toString(), "<eval>", 1);
    IRFactory irf = new IRFactory(compilerEnv);
    ScriptNode tree = irf.transformTree(ast);

    Codegen codegen = new Codegen();
    codegen.setMainMethodClass(mainMethodClassName);
    codegen.compileToClassFile(compilerEnv, scriptClassName, tree,
            tree.getEncodedSource(), false);

    return tree;
}
项目:Rhino-Prov-Mod    文件:Bug708801Test.java   
/**
 * Compiles {@code source} and returns the transformed and optimized
 * {@link ScriptNode}
 */
protected ScriptNode compile(CharSequence source) {
    final String mainMethodClassName = "Main";
    final String scriptClassName = "Main";

    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv
            .getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    AstRoot ast = p.parse(source.toString(), "<eval>", 1);
    IRFactory irf = new IRFactory(compilerEnv);
    ScriptNode tree = irf.transformTree(ast);

    Codegen codegen = new Codegen();
    codegen.setMainMethodClass(mainMethodClassName);
    codegen.compileToClassFile(compilerEnv, scriptClassName, tree,
            tree.getEncodedSource(), false);

    return tree;
}
项目:jasperreports    文件:JavaScriptClassLoader.java   
public JavaScriptClassLoader()
{
    super(Codegen.class.getClassLoader());
}