/** * 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; }
/** * 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; }
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; }
public JavaScriptClassLoader() { super(Codegen.class.getClassLoader()); }