Exemple #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));
   }
 }
Exemple #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();
      }
    }
    @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));
      }
    }