org.jruby.Ruby.getCurrentLine()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中org.jruby.Ruby.getCurrentLine方法的一些代码示例,展示了Ruby.getCurrentLine的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getCurrentLine方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getCurrentLine

Ruby.getCurrentLine介绍

暂无

代码示例

代码示例来源:origin: org.jruby/jruby-complete

@Override
  public IRubyObject get() {
    return runtime.newFixnum(runtime.getCurrentLine());
  }
}

代码示例来源:origin: org.jruby/jruby-core

@Override
  public IRubyObject get() {
    return runtime.newFixnum(runtime.getCurrentLine());
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@Override
  public IRubyObject get() {
    return runtime.newFixnum(runtime.getCurrentLine());
  }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

@Override
  public IRubyObject get() {
    return runtime.newFixnum(runtime.getCurrentLine());
  }
}

代码示例来源:origin: org.jruby/jruby-complete

@JRubyMethod(name = "lineno")
public static IRubyObject lineno(ThreadContext context, IRubyObject recv) {
  return context.runtime.newFixnum(context.runtime.getCurrentLine());
}

代码示例来源:origin: org.jruby/jruby-core

@JRubyMethod(name = "lineno")
public static IRubyObject lineno(ThreadContext context, IRubyObject recv) {
  return context.runtime.newFixnum(context.runtime.getCurrentLine());
}

代码示例来源:origin: org.jruby/jruby-complete

public void incrementLineno(Ruby runtime, RubyIO io) {
  boolean locked = lock();
  try {
    lineno++;
    if (RubyArgsFile.ArgsFileData.getArgsFileData(runtime).isCurrentFile(io)) {
      runtime.setCurrentLine(runtime.getCurrentLine() + 1);
    } else {
      runtime.setCurrentLine(lineno);
    }
  } finally {
    if (locked) unlock();
  }
}

代码示例来源:origin: org.jruby/jruby-core

public void incrementLineno(Ruby runtime, RubyIO io) {
  boolean locked = lock();
  try {
    lineno++;
    if (RubyArgsFile.ArgsFileData.getArgsFileData(runtime).isCurrentFile(io)) {
      runtime.setCurrentLine(runtime.getCurrentLine() + 1);
    } else {
      runtime.setCurrentLine(lineno);
    }
  } finally {
    if (locked) unlock();
  }
}

代码示例来源:origin: org.jruby/jruby-complete

public void loadFromClassLoader(ClassLoader classLoader, String file, boolean wrap) {
  long startTime = loadTimer.startLoad("classloader:" + file);
  int currentLine = runtime.getCurrentLine();
  try {
    SearchState state = new SearchState(file);
    state.prepareLoadSearch(file);
    Library library = null;
    LoadServiceResource resource = getClassPathResource(classLoader, file);
    if (resource != null) {
      state.setLoadName(resolveLoadName(resource, file));
      library = createLibrary(state, resource);
    }
    if (library == null) {
      throw runtime.newLoadError("no such file to load -- " + file);
    }
    try {
      library.load(runtime, wrap);
    } catch (IOException e) {
      debugLoadException(runtime, e);
      throw newLoadErrorFromThrowable(runtime, file, e);
    }
  } finally {
    runtime.setCurrentLine(currentLine);
    loadTimer.endLoad("classloader:" + file, startTime);
  }
}

代码示例来源:origin: org.jruby/jruby-core

public void loadFromClassLoader(ClassLoader classLoader, String file, boolean wrap) {
  long startTime = loadTimer.startLoad("classloader:" + file);
  int currentLine = runtime.getCurrentLine();
  try {
    SearchState state = new SearchState(file);
    state.prepareLoadSearch(file);
    Library library = null;
    LoadServiceResource resource = getClassPathResource(classLoader, file);
    if (resource != null) {
      state.setLoadName(resolveLoadName(resource, file));
      library = createLibrary(state, resource);
    }
    if (library == null) {
      throw runtime.newLoadError("no such file to load -- " + file);
    }
    try {
      library.load(runtime, wrap);
    } catch (IOException e) {
      debugLoadException(runtime, e);
      throw newLoadErrorFromThrowable(runtime, file, e);
    }
  } finally {
    runtime.setCurrentLine(currentLine);
    loadTimer.endLoad("classloader:" + file, startTime);
  }
}

代码示例来源:origin: org.jruby/jruby-complete

@JRubyMethod
public RubyFixnum rewind(ThreadContext context) {
  Ruby runtime = context.runtime;
  OpenFile fptr;
  fptr = getOpenFileChecked();
  boolean locked = fptr.lock();
  try {
    if (fptr.seek(context, 0L, 0) == -1 && fptr.errno() != null) {
      throw runtime.newErrnoFromErrno(fptr.errno(), fptr.getPath());
    }
    if (RubyArgsFile.ArgsFileData.getArgsFileData(runtime).isCurrentFile(this)) {
      runtime.setCurrentLine(runtime.getCurrentLine() - fptr.getLineNumber());
    }
    fptr.setLineNumber(0);
    if (fptr.readconv != null) {
      fptr.clearReadConversion();
    }
  } finally {
    if (locked) fptr.unlock();
  }
  return RubyFixnum.zero(runtime);
}

代码示例来源:origin: org.jruby/jruby-core

@JRubyMethod
public RubyFixnum rewind(ThreadContext context) {
  Ruby runtime = context.runtime;
  OpenFile fptr;
  fptr = getOpenFileChecked();
  boolean locked = fptr.lock();
  try {
    if (fptr.seek(context, 0L, 0) == -1 && fptr.errno() != null) {
      throw runtime.newErrnoFromErrno(fptr.errno(), fptr.getPath());
    }
    if (RubyArgsFile.ArgsFileData.getArgsFileData(runtime).isCurrentFile(this)) {
      runtime.setCurrentLine(runtime.getCurrentLine() - fptr.getLineNumber());
    }
    fptr.setLineNumber(0);
    if (fptr.readconv != null) {
      fptr.clearReadConversion();
    }
  } finally {
    if (locked) fptr.unlock();
  }
  return RubyFixnum.zero(runtime);
}

代码示例来源:origin: org.jruby/jruby-complete

public void load(String file, boolean wrap) {
  long startTime = loadTimer.startLoad(file);
  int currentLine = runtime.getCurrentLine();
  try {
    if(!runtime.getProfile().allowLoad(file)) {
      throw runtime.newLoadError("no such file to load -- " + file, file);
    }
    SearchState state = new SearchState(file);
    state.prepareLoadSearch(file);
    Library library = findLibraryBySearchState(state);
    // load() will do a last chance look in current working directory for the file (see load.c:rb_f_load()).
    if (library == null) {
      FileResource fileResource = JRubyFile.createResourceAsFile(runtime, file);
      if (!fileResource.exists()) throw runtime.newLoadError("no such file to load -- " + file, file);
      library = LibrarySearcher.ResourceLibrary.create(file, file, fileResource);
    }
    try {
      library.load(runtime, wrap);
    } catch (IOException e) {
      debugLoadException(runtime, e);
      throw newLoadErrorFromThrowable(runtime, file, e);
    }
  } finally {
    runtime.setCurrentLine(currentLine);
    loadTimer.endLoad(file, startTime);
  }
}

代码示例来源:origin: org.jruby/jruby-core

public void load(String file, boolean wrap) {
  long startTime = loadTimer.startLoad(file);
  int currentLine = runtime.getCurrentLine();
  try {
    if(!runtime.getProfile().allowLoad(file)) {
      throw runtime.newLoadError("no such file to load -- " + file, file);
    }
    SearchState state = new SearchState(file);
    state.prepareLoadSearch(file);
    Library library = findLibraryBySearchState(state);
    // load() will do a last chance look in current working directory for the file (see load.c:rb_f_load()).
    if (library == null) {
      FileResource fileResource = JRubyFile.createResourceAsFile(runtime, file);
      if (!fileResource.exists()) throw runtime.newLoadError("no such file to load -- " + file, file);
      library = LibrarySearcher.ResourceLibrary.create(file, file, fileResource);
    }
    try {
      library.load(runtime, wrap);
    } catch (IOException e) {
      debugLoadException(runtime, e);
      throw newLoadErrorFromThrowable(runtime, file, e);
    }
  } finally {
    runtime.setCurrentLine(currentLine);
    loadTimer.endLoad(file, startTime);
  }
}

相关文章

微信公众号

最新文章

更多

Ruby类方法