Skip to content

Commit

Permalink
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/runtime/RubyArguments.java
Original file line number Diff line number Diff line change
@@ -152,6 +152,26 @@ public static MaterializedFrame tryGetDeclarationFrame(Object[] arguments) {
return null;
}

public static Object tryGetSelf(Object[] arguments) {
if (SELF_INDEX >= arguments.length) {
return null;
}
return arguments[SELF_INDEX];
}

public static DynamicObject tryGetBlock(Object[] arguments) {
if (BLOCK_INDEX >= arguments.length) {
return null;
}

final Object block = arguments[BLOCK_INDEX];
if (block instanceof DynamicObject) {
return (DynamicObject) block;
} else {
return null;
}
}

public static MaterializedFrame getCallerFrame(Object[] arguments) {
return (MaterializedFrame) arguments[CALLER_FRAME_INDEX];
}
Original file line number Diff line number Diff line change
@@ -161,12 +161,12 @@ public static Set<DynamicObject> getObjectsInFrame(Frame frame) {
objects.addAll(getObjectsInFrame(lexicalParentFrame));
}

final Object self = RubyArguments.getSelf(arguments);
final Object self = RubyArguments.tryGetSelf(arguments);
if (self instanceof DynamicObject) {
objects.add((DynamicObject) self);
}

final DynamicObject block = RubyArguments.getBlock(arguments);
final DynamicObject block = RubyArguments.tryGetBlock(arguments);
if (block != null) {
objects.add(block);
}

0 comments on commit 0c35d5b

Please sign in to comment.