Ruby getGlobalRuntime(AbstractLocalContextProvider provider) { if ( isGlobalRuntimeReady() ) { return Ruby.getGlobalRuntime(); } return Ruby.newInstance(provider.config); }
@Override public RubyInstanceConfig getRubyInstanceConfig() { if (Ruby.isGlobalRuntimeReady()) return Ruby.getGlobalRuntime().getInstanceConfig(); else return config; }
@Override public RubyInstanceConfig getRubyInstanceConfig() { if (Ruby.isGlobalRuntimeReady()) return Ruby.getGlobalRuntime().getInstanceConfig(); else return config; }
@Override public RubyInstanceConfig getRubyInstanceConfig() { if (Ruby.isGlobalRuntimeReady()) return Ruby.getGlobalRuntime().getInstanceConfig(); else return config; }
public Ruby getRuntime() { if (!Ruby.isGlobalRuntimeReady()) { return Ruby.newInstance(config); } return Ruby.getGlobalRuntime(); }
public Ruby getRuntime() { if (!Ruby.isGlobalRuntimeReady()) { return Ruby.newInstance(config); } return Ruby.getGlobalRuntime(); }
Ruby getGlobalRuntime(AbstractLocalContextProvider provider) { if ( isGlobalRuntimeReady() ) { return Ruby.getGlobalRuntime(); } return Ruby.newInstance(provider.config); }
public Ruby getRuntime() { if (!Ruby.isGlobalRuntimeReady()) { return Ruby.newInstance(config); } return Ruby.getGlobalRuntime(); }
public Ruby getRuntime() { if (!Ruby.isGlobalRuntimeReady()) { return Ruby.newInstance(config); } return Ruby.getGlobalRuntime(); }
@Override public RubyInstanceConfig getRubyInstanceConfig() { if (Ruby.isGlobalRuntimeReady()) return Ruby.getGlobalRuntime().getInstanceConfig(); else return config; }
public static Node buildAST(boolean isCommandLineScript, String arg) { Ruby ruby = Ruby.getGlobalRuntime(); // inline script if (isCommandLineScript) return ruby.parse(ByteList.create(arg), "-e", null, 0, false); // from file FileInputStream fis = null; try { File file = new File(arg); fis = new FileInputStream(file); long size = file.length(); byte[] bytes = new byte[(int)size]; fis.read(bytes); System.out.println("-- processing " + arg + " --"); return ruby.parse(new ByteList(bytes), arg, null, 0, false); } catch (IOException ioe) { throw new RuntimeException(ioe); } finally { try { if (fis != null) fis.close(); } catch(Exception ignored) { } } }
public static Node buildAST(boolean isCommandLineScript, String arg) { Ruby ruby = Ruby.getGlobalRuntime(); // inline script if (isCommandLineScript) return ruby.parse(ByteList.create(arg), "-e", null, 0, false); // from file FileInputStream fis = null; try { File file = new File(arg); fis = new FileInputStream(file); long size = file.length(); byte[] bytes = new byte[(int)size]; fis.read(bytes); System.out.println("-- processing " + arg + " --"); return ruby.parse(new ByteList(bytes), arg, null, 0, false); } catch (IOException ioe) { throw new RuntimeException(ioe); } finally { try { if (fis != null) fis.close(); } catch(Exception ignored) { } } }
public ConcurrentLocalContextProvider(LocalVariableBehavior behavior, boolean lazy) { // To save startup time, Ruby runtime instantiation should be delayed as mush as possible // so, don't create runtime here. if (Ruby.isGlobalRuntimeReady()) config = Ruby.getGlobalRuntime().getInstanceConfig(); else config = new RubyInstanceConfig(); this.behavior = behavior; this.lazy = lazy; }
public static Node buildAST(boolean isCommandLineScript, String arg) { Ruby ruby = Ruby.getGlobalRuntime(); // set to IR mode, since we use different scopes, etc for IR ruby.getInstanceConfig().setCompileMode(CompileMode.OFFIR); // inline script if (isCommandLineScript) return ruby.parse(ByteList.create(arg), "-e", null, 0, false); // from file FileInputStream fis = null; try { File file = new File(arg); fis = new FileInputStream(file); long size = file.length(); byte[] bytes = new byte[(int)size]; fis.read(bytes); System.out.println("-- processing " + arg + " --"); return ruby.parse(new ByteList(bytes), arg, null, 0, false); } catch (IOException ioe) { throw new RuntimeException(ioe); } finally { try { if (fis != null) fis.close(); } catch(Exception e) { } } }
static RubyInstanceConfig getGlobalRuntimeConfigOrNew() { return Ruby.isGlobalRuntimeReady() ? Ruby.getGlobalRuntime().getInstanceConfig() : new RubyInstanceConfig(); }
static RubyInstanceConfig getGlobalRuntimeConfigOrNew() { return Ruby.isGlobalRuntimeReady() ? Ruby.getGlobalRuntime().getInstanceConfig() : new RubyInstanceConfig(); }
public ConcurrentLocalContextProvider(LocalVariableBehavior behavior, boolean lazy) { // To save startup time, Ruby runtime instantiation should be delayed as mush as possible // so, don't create runtime here. if (Ruby.isGlobalRuntimeReady()) config = Ruby.getGlobalRuntime().getInstanceConfig(); else config = new RubyInstanceConfig(); this.behavior = behavior; this.lazy = lazy; }
/** * Run the provided (required) block with the "global runtime" set to the current runtime, * for libraries that expect to operate against the global runtime. */ @JRubyMethod(module = true) public static IRubyObject with_current_runtime_as_global(ThreadContext context, IRubyObject recv, Block block) { final Ruby current = context.runtime; final Ruby global = Ruby.getGlobalRuntime(); try { if (current != global) { current.useAsGlobalRuntime(); } return block.yield(context, runtime(context, recv)); // previously yield (without an argument) } finally { if (Ruby.getGlobalRuntime() != global) { global.useAsGlobalRuntime(); } } }
/** * Run the provided (required) block with the "global runtime" set to the current runtime, * for libraries that expect to operate against the global runtime. */ @JRubyMethod(module = true) public static IRubyObject with_current_runtime_as_global(ThreadContext context, IRubyObject recv, Block block) { final Ruby current = context.runtime; final Ruby global = Ruby.getGlobalRuntime(); try { if (current != global) { current.useAsGlobalRuntime(); } return block.yield(context, runtime(context, recv)); // previously yield (without an argument) } finally { if (Ruby.getGlobalRuntime() != global) { global.useAsGlobalRuntime(); } } }
private void initLexer(String title) { LexerSource lexerSource = new ByteListLexerSource(title, 0, new ByteList(utf8Bytes), null); lexerSource.setEncoding(UTF8Encoding.INSTANCE); ParserSupport parserSupport = new ParserSupport(); lexer = new RubyLexer(parserSupport, lexerSource, new NullWarnings(Ruby.getGlobalRuntime())); parserSupport.setLexer(lexer); parserSupport.setConfiguration(new ParserConfiguration(Ruby.getGlobalRuntime(), 0, false, true, false)); parserSupport.setResult(new RubyParserResult()); parserSupport.setWarnings(new NullWarnings(Ruby.getGlobalRuntime())); parserSupport.initTopLocalVariables(); lexer.setState(LexingCommon.EXPR_BEG); }