示例#1
0
 private Object timeToUnit(long time, DynamicObject unit) {
   assert RubyGuards.isRubySymbol(unit);
   if (unit == nanosecondSymbol) {
     return time;
   } else if (unit == floatSecondSymbol) {
     return time / 1e9;
   } else {
     throw new UnsupportedOperationException(Layouts.SYMBOL.getString(unit));
   }
 }
示例#2
0
    @TruffleBoundary
    @Specialization(guards = "isRubySymbol(signalName)")
    public int kill(DynamicObject signalName, int pid) {
      int self = posix().getpid();

      if (self == pid) {
        return raise(Layouts.SYMBOL.getString(signalName));
      } else {
        throw new UnsupportedOperationException();
      }
    }
示例#3
0
    @Specialization(guards = "isRubySymbol(index)")
    public Object getIndexSymbol(DynamicObject matchData, DynamicObject index, NotProvided length) {
      CompilerDirectives.transferToInterpreter();

      try {
        final int i = getBackrefNumber(matchData, Layouts.SYMBOL.getByteList(index));

        return getIndex(matchData, i, NotProvided.INSTANCE);
      } catch (final ValueException e) {
        CompilerDirectives.transferToInterpreter();

        throw new RaiseException(
            getContext()
                .getCoreLibrary()
                .indexError(
                    String.format(
                        "undefined group name reference: %s", Layouts.SYMBOL.getString(index)),
                    this));
      }
    }