Skip to content

Commit

Permalink
Showing 5 changed files with 35 additions and 5 deletions.
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/binding/eval_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/binding/location_tags.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
fails:Binding#eval inherits __LINE__ from the enclosing scope
fails:Binding#eval preserves __LINE__ across multiple calls to eval
fails:Binding#eval increments __LINE__ on each line of a multiline eval
fails:Binding#eval starts with a __LINE__ of 1 if a filename is passed
fails:Binding#eval starts with a __LINE__ from the third argument if passed
fails:Binding#eval inherits __FILE__ from the enclosing scope
fails:Binding#eval uses the __FILE__ that is passed in
Original file line number Diff line number Diff line change
@@ -580,7 +580,7 @@ public Object evalNoBindingUncached(VirtualFrame frame, DynamicObject source, No
"isNil(noBinding)",
"isRubyString(filename)"
})
public Object evalNilBinding(VirtualFrame frame, DynamicObject source, Object noBinding,
public Object evalNilBinding(VirtualFrame frame, DynamicObject source, DynamicObject noBinding,
DynamicObject filename, int lineNumber) {
return evalNoBindingUncached(frame, source, NotProvided.INSTANCE, NotProvided.INSTANCE, NotProvided.INSTANCE);
}
@@ -594,6 +594,16 @@ public Object evalBinding(DynamicObject source, DynamicObject binding, NotProvid
return getContext().eval(Layouts.STRING.getByteList(source), binding, false, this);
}

@Specialization(guards = {
"isRubyString(source)",
"isRubyBinding(binding)",
"isNil(noFilename)",
"isNil(noLineNumber)"
})
public Object evalBinding(DynamicObject source, DynamicObject binding, DynamicObject noFilename, DynamicObject noLineNumber) {
return evalBinding(source, binding, NotProvided.INSTANCE, NotProvided.INSTANCE);
}

@TruffleBoundary
@Specialization(guards = {
"isRubyString(source)",
@@ -604,6 +614,16 @@ public Object evalBindingFilename(DynamicObject source, DynamicObject binding, D
return getContext().eval(Layouts.STRING.getByteList(source), binding, false, filename.toString(), this);
}

@Specialization(guards = {
"isRubyString(source)",
"isRubyBinding(binding)",
"isRubyString(filename)",
"isNil(noLineNumber)"
})
public Object evalBindingFilename(DynamicObject source, DynamicObject binding, DynamicObject filename, DynamicObject noLineNumber) {
return evalBindingFilename(source, binding, filename, NotProvided.INSTANCE);
}

@TruffleBoundary
@Specialization(guards = {
"isRubyString(source)",
1 change: 1 addition & 0 deletions truffle/src/main/ruby/core.rb
Original file line number Diff line number Diff line change
@@ -250,6 +250,7 @@ def self.omit(reason)
# Load JRuby+Truffle classes

require_relative 'core/array'
require_relative 'core/binding'
require_relative 'core/fixnum'
require_relative 'core/float'
require_relative 'core/kernel'
13 changes: 13 additions & 0 deletions truffle/src/main/ruby/core/binding.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

class Binding
def eval(code, file = nil, line = nil)
Kernel.eval(code, self, file, line)
end
end

1 comment on commit 8e00e3e

@nirvdrum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Sorry, something went wrong.

Please sign in to comment.