Skip to content

Commit db81738

Browse files
committed
[Truffle] Implemented BasicObject#instance_exec.
1 parent c5f856b commit db81738

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

spec/truffle/tags/core/basicobject/instance_exec_tags.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

truffle/src/main/java/org/jruby/truffle/nodes/core/BasicObjectNodes.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,24 @@ public Object instanceEval(VirtualFrame frame, Object receiver, UndefinedPlaceho
221221

222222
}
223223

224+
@CoreMethod(names = "instance_exec", needsBlock = true, argumentsAsArray = true)
225+
public abstract static class InstanceExecNode extends YieldingCoreMethodNode {
226+
227+
public InstanceExecNode(RubyContext context, SourceSection sourceSection) {
228+
super(context, sourceSection);
229+
}
230+
231+
public InstanceExecNode(InstanceExecNode prev) {
232+
super(prev);
233+
}
234+
235+
@Specialization
236+
public Object instanceExec(VirtualFrame frame, Object receiver, Object[] arguments, RubyProc block) {
237+
return yieldWithModifiedSelf(frame, block, receiver, arguments);
238+
}
239+
240+
}
241+
224242
@CoreMethod(names = "method_missing", needsBlock = true, argumentsAsArray = true, visibility = Visibility.PRIVATE)
225243
public abstract static class MethodMissingNode extends CoreMethodNode {
226244

truffle/src/main/java/org/jruby/truffle/nodes/core/YieldingCoreMethodNode.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,8 @@ public boolean yieldIsTruthy(VirtualFrame frame, RubyProc block, Object... argum
4949
return booleanCast(frame, yield(frame, block, arguments));
5050
}
5151

52+
public Object yieldWithModifiedSelf(VirtualFrame frame, RubyProc block, Object self, Object... arguments) {
53+
return dispatchNode.dispatchWithModifiedSelf(frame, block, self, arguments);
54+
}
55+
5256
}

truffle/src/main/ruby/core/shims.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,6 @@ def _offset_to_milliseconds
135135

136136
ENV['TZ'] = 'UTC'
137137

138-
class BasicObject
139-
140-
def instance_exec(*args)
141-
# TODO (nirvdrum 06-Mar-15) Properly implement this. The stub is just to get the specs even loading.
142-
end
143-
144-
end
145-
146138
class Method
147139

148140
def to_proc

0 commit comments

Comments
 (0)