public static Class compile(Ruby ruby, IRScope scope, JRubyClassLoader jrubyClassLoader) { // run compiler JVMVisitor target = new JVMVisitor(); target.codegen(scope); // try { // FileOutputStream fos = new FileOutputStream("tmp.class"); // fos.write(target.code()); // fos.close(); // } catch (Exception e) { // e.printStackTrace(); // } return jrubyClassLoader.defineClass(JVM.scriptToClass(scope.getName()), target.code()); }
public static Class compile(Ruby ruby, IRScope scope, JRubyClassLoader jrubyClassLoader) { // run compiler JVMVisitor target = new JVMVisitor(); target.codegen(scope); // try { // FileOutputStream fos = new FileOutputStream("tmp.class"); // fos.write(target.code()); // fos.close(); // } catch (Exception e) { // e.printStackTrace(); // } return jrubyClassLoader.defineClass(JVM.scriptToClass(scope.getName()), target.code()); }
JVMVisitor visitor = new JVMVisitor(runtime); JVMVisitorMethodContext context = new JVMVisitorMethodContext(); bytecode = visitor.compileToBytecode(scope, context);
JVMVisitor visitor = new JVMVisitor(runtime); JVMVisitorMethodContext context = new JVMVisitorMethodContext(); bytecode = visitor.compileToBytecode(scope, context);
try { String key = SexpMaker.sha1(body.getIRScope()); JVMVisitor visitor = new JVMVisitor(jitCompiler.runtime); BlockJITClassGenerator generator = new BlockJITClassGenerator(className, methodName, key, jitCompiler.runtime, body, visitor);
@JRubyMethod(module = true, name = "compile", required = 1, optional = 3) public static IRubyObject compile(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { // def compile(content = nil, filename = DEFAULT_FILENAME, extra_position_info = false, &block) final Ruby runtime = context.runtime; final RubyString content = args[0].convertToString(); args[0] = content; final RubyString filename = args.length > 1 ? args[1].convertToString() : RubyString.newEmptyString(runtime); IRScriptBody scope = compileIR(context, args, block); JVMVisitor visitor = new JVMVisitor(runtime); JVMVisitorMethodContext methodContext = new JVMVisitorMethodContext(); byte[] bytes = visitor.compileToBytecode(scope, methodContext); scope.getStaticScope().setModule( runtime.getTopSelf().getMetaClass() ); RubyClass CompiledScript = (RubyClass) runtime.getModule("JRuby").getConstantAt("CompiledScript"); // JRuby::CompiledScript#initialize(filename, class_name, content, bytes) return CompiledScript.newInstance(context, new IRubyObject[] { filename, scope.getName(), content, Java.getInstance(runtime, bytes) }, Block.NULL_BLOCK); }
try { String key = SexpMaker.sha1(body.getIRScope()); JVMVisitor visitor = new JVMVisitor(jitCompiler.runtime); BlockJITClassGenerator generator = new BlockJITClassGenerator(className, methodName, key, jitCompiler.runtime, body, visitor);
@JRubyMethod(module = true, name = "compile", required = 1, optional = 3) public static IRubyObject compile(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { // def compile(content = nil, filename = DEFAULT_FILENAME, extra_position_info = false, &block) final Ruby runtime = context.runtime; final RubyString content = args[0].convertToString(); args[0] = content; final RubyString filename = args.length > 1 ? args[1].convertToString() : RubyString.newEmptyString(runtime); IRScriptBody scope = compileIR(context, args, block); JVMVisitor visitor = new JVMVisitor(runtime); JVMVisitorMethodContext methodContext = new JVMVisitorMethodContext(); byte[] bytes = visitor.compileToBytecode(scope, methodContext); scope.getStaticScope().setModule( runtime.getTopSelf().getMetaClass() ); RubyClass CompiledScript = (RubyClass) runtime.getModule("JRuby").getConstantAt("CompiledScript"); // JRuby::CompiledScript#initialize(filename, class_name, content, bytes) return CompiledScript.newInstance(context, new IRubyObject[] { filename, scope.getName(), content, Java.getInstance(runtime, bytes) }, Block.NULL_BLOCK); }
JVMVisitor visitor = new JVMVisitor(runtime); MethodJITClassGenerator generator = new MethodJITClassGenerator(className, methodName, key, runtime, method, visitor);
JVMVisitor visitor = new JVMVisitor(runtime); MethodJITClassGenerator generator = new MethodJITClassGenerator(className, methodName, key, runtime, method, visitor);
JVMVisitor visitor = new JVMVisitor(runtime); MethodJITClassGenerator generator = new MethodJITClassGenerator(className, methodName, key, runtime, method, visitor);
JVMVisitor visitor = new JVMVisitor(runtime); MethodJITClassGenerator generator = new MethodJITClassGenerator(className, methodName, key, runtime, method, visitor);