Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1de3ef2f724f
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: bae45f672290
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Aug 16, 2016

  1. Copy the full SHA
    ccfc9df View commit details
  2. Copy the full SHA
    bae45f6 View commit details
Original file line number Diff line number Diff line change
@@ -188,20 +188,20 @@ public static abstract class RegexpSetBlockLastMatchPrimitiveNode extends Primit
@Specialization(guards = { "isRubyProc(block)", "isSuitableMatchDataType(getContext(), matchData)" })
public Object setBlockLastMatch(DynamicObject block, DynamicObject matchData) {

Frame callerFrame = Layouts.PROC.getDeclarationFrame(block);
Frame methodFrame = Layouts.PROC.getDeclarationFrame(block);

if (callerFrame == null) {
if (methodFrame == null) {
return matchData;
}

Frame tempFrame = RubyArguments.getDeclarationFrame(callerFrame);
Frame tempFrame = RubyArguments.getDeclarationFrame(methodFrame);

while (tempFrame != null) {
callerFrame = tempFrame;
tempFrame = RubyArguments.getDeclarationFrame(callerFrame);
methodFrame = tempFrame;
tempFrame = RubyArguments.getDeclarationFrame(methodFrame);
}

final FrameDescriptor callerFrameDescriptor = callerFrame.getFrameDescriptor();
final FrameDescriptor callerFrameDescriptor = methodFrame.getFrameDescriptor();

try {
final FrameSlot frameSlot = callerFrameDescriptor.findFrameSlot("$~");
@@ -210,12 +210,12 @@ public Object setBlockLastMatch(DynamicObject block, DynamicObject matchData) {
return matchData;
}

final Object matchDataHolder = callerFrame.getObject(frameSlot);
final Object matchDataHolder = methodFrame.getObject(frameSlot);

if (matchDataHolder instanceof ThreadLocalObject) {
((ThreadLocalObject) matchDataHolder).set(matchData);
} else {
callerFrame.setObject(frameSlot, ThreadLocalObject.wrap(getContext(), matchData));
methodFrame.setObject(frameSlot, ThreadLocalObject.wrap(getContext(), matchData));
}
} catch (FrameSlotTypeException e) {
throw new IllegalStateException(e);
Original file line number Diff line number Diff line change
@@ -572,18 +572,7 @@ public Object slice1(
Object capture,
@Cached("createMethodCallIgnoreVisibility()") CallDispatchHeadNode callNode,
@Cached("create()") RegexpPrimitiveNodes.RegexpSetLastMatchPrimitiveNode setLastMatchNode) {
final Object matchStrPair = callNode.call(frame, string, "subpattern", regexp, 0);

if (matchStrPair == nil()) {
setLastMatchNode.executeSetLastMatch(nil());
return nil();
}

final Object[] array = (Object[]) Layouts.ARRAY.getStore((DynamicObject) matchStrPair);

setLastMatchNode.executeSetLastMatch(array[0]);

return array[1];
return sliceCapture(frame, string, regexp, 0, callNode, setLastMatchNode);
}

@Specialization(guards = {"isRubyRegexp(regexp)", "wasProvided(capture)"})