Skip to content

Commit

Permalink
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -37,9 +37,7 @@ public ReadDeclarationVariableNode(RubyContext context, SourceSection sourceSect

@Override
public Object execute(VirtualFrame frame) {
checkReadFrameSlotNode();
final MaterializedFrame declarationFrame = RubyArguments.getDeclarationFrame(frame, frameDepth);
return readFrameSlotNode.executeRead(declarationFrame);
return readFrameSlot(frame);
}


@@ -50,9 +48,7 @@ public Object isDefined(VirtualFrame frame) {
return coreStrings().LOCAL_VARIABLE.createInstance();

case FRAME_LOCAL_GLOBAL:
checkReadFrameSlotNode();

if (readFrameSlotNode.executeRead(frame) != nil()) {
if (readFrameSlot(frame) != nil()) {
return coreStrings().GLOBAL_VARIABLE.createInstance();
} else {
return nil();
@@ -66,11 +62,14 @@ public Object isDefined(VirtualFrame frame) {
}
}

private void checkReadFrameSlotNode() {
private Object readFrameSlot(VirtualFrame frame) {
if (readFrameSlotNode == null) {
CompilerDirectives.transferToInterpreter();
readFrameSlotNode = insert(ReadFrameSlotNodeGen.create(frameSlot));
}

final MaterializedFrame declarationFrame = RubyArguments.getDeclarationFrame(frame, frameDepth);

This comment has been minimized.

Copy link
@eregon

eregon Feb 25, 2016

Member

I would pass declarationFrame as an argument to readFrameSlot, otherwise the helper is doing more than just calling the helper node.

This comment has been minimized.

Copy link
@chrisseaton

chrisseaton Feb 25, 2016

Author Contributor

Well it doesn't say it only does one thing. And that'd be duplicated code then.

This comment has been minimized.

Copy link
@eregon

eregon Feb 26, 2016

Member

I would argue with separation of concerns then 😄 (reading from the frame with the slot versus getting the frame). But yeah in this case it's fine, I would have a stronger objection if a lot of code got in there.

return readFrameSlotNode.executeRead(declarationFrame);
}

@Override

0 comments on commit 938d3c0

Please sign in to comment.