예제 #1
0
  private Object lookupRestKeywordArgumentHash(VirtualFrame frame) {
    CompilerDirectives.transferToInterpreter();

    final DynamicObject hash = RubyArguments.getUserKeywordsHash(frame.getArguments(), minimum);

    if (hash == null) {
      return Layouts.HASH.createHash(
          getContext().getCoreLibrary().getHashFactory(), null, null, null, 0, null, null, false);
    }

    final List<Map.Entry<Object, Object>> entries = new ArrayList<>();

    outer:
    for (Map.Entry<Object, Object> keyValue : HashOperations.iterableKeyValues(hash)) {
      for (String excludedKeyword : excludedKeywords) {
        if (excludedKeyword.equals(keyValue.getKey().toString())) {
          continue outer;
        }
      }

      entries.add(keyValue);
    }

    return BucketsStrategy.create(getContext(), entries, Layouts.HASH.getCompareByIdentity(hash));
  }
예제 #2
0
  @CompilerDirectives.TruffleBoundary
  private Object lookupKeywordInHash(RubyHash hash) {
    for (KeyValue keyValue : HashOperations.verySlowToKeyValues(hash)) {
      if (keyValue.getKey().toString().equals(name)) {
        return keyValue.getValue();
      }
    }

    return null;
  }