Skip to content

Commit

Permalink
Showing 4 changed files with 62 additions and 19 deletions.
18 changes: 17 additions & 1 deletion maven/jruby-dist/pom.rb
Original file line number Diff line number Diff line change
@@ -47,6 +47,8 @@
end

execute :pack200 do |ctx|
require 'open3'

jruby_home = Dir[ File.join( ctx.project.build.directory.to_pathname,
'META-INF/jruby.home/**/*.jar' ) ]
gem_home = Dir[ File.join( ctx.project.build.directory.to_pathname,
@@ -58,7 +60,21 @@
file = f.sub /.jar$/, ''
unless File.exists?( file + '.pack.gz' )
puts "pack200 #{f.sub(/.*jruby.home./, '').sub(/.*rubygems-provided./, '')}"
`pack200 #{file}.pack.gz #{file}.jar`

Open3.popen3('pack200', "#{file}.pack.gz", "#{file}.jar") do |stdin, stdout, stderr, wait_thread|
stdio_threads = []

stdio_threads << Thread.new(stdout) do |stdout|
stdout.each { |line| $stdout.puts line }
end

stdio_threads << Thread.new(stderr) do |stderr|
stderr.each { |line| $stderr.puts line }
end

stdio_threads.each(&:join)
wait_thread.value
end
end
end
end
32 changes: 32 additions & 0 deletions spec/ruby/core/binding/local_variable_get_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)

ruby_version_is "2.1" do
describe "Binding#local_variable_get" do
it "reads local variables captured in the binding" do
a = 42
bind = binding
bind.local_variable_get(:a).should == 42
end

it "raises a NameError for missing variables" do
bind = BindingSpecs::Demo.new(1).get_empty_binding

lambda {
bind.local_variable_get(:no_such_variable)
}.should raise_error(NameError)
end

it "reads variables added later to the binding" do
bind = BindingSpecs::Demo.new(1).get_empty_binding

lambda {
bind.local_variable_get(:a)
}.should raise_error(NameError)

bind.local_variable_set(:a, 42)

bind.local_variable_get(:a).should == 42
end
end
end
14 changes: 4 additions & 10 deletions test/truffle/pe/core/frozen_pe.rb
Original file line number Diff line number Diff line change
@@ -6,10 +6,8 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1


example "true.frozen?", true

example "false.frozen?", true
example "nil.frozen?", true

# int
example "3.frozen?", true
@@ -20,16 +18,12 @@
# Bignum
example "(10 ** 100).frozen?", true

# float
example "3.5.frozen?", true

# double
example "(2**62).to_f.frozen?", true
example "3.5.frozen?", true

# Symbols are always frozen
example ":symbol.frozen?", true

example "nil.frozen?", true

# Object
example "'abc'.frozen?", false

example "'abc'.freeze.frozen?", true
Original file line number Diff line number Diff line change
@@ -70,6 +70,10 @@ public FrameSlotAndDepth(FrameSlot slot, int depth) {
this.slot = slot;
this.depth = depth;
}

public FrameSlot getSlot() {
return slot;
}
}

public static FrameSlotAndDepth findFrameSlotOrNull(DynamicObject binding, DynamicObject symbol) {
@@ -137,19 +141,16 @@ public LocalVariableGetNode(RubyContext context, SourceSection sourceSection) {
"symbol == cachedSymbol",
"!isLastLine(cachedSymbol)",
"compatibleFrames(binding, cachedBinding)",
}, limit = "getCacheLimit()")
"cachedFrameSlot != null"
},
limit = "getCacheLimit()")
public Object localVariableGetCached(DynamicObject binding, DynamicObject symbol,
@Cached("symbol") DynamicObject cachedSymbol,
@Cached("binding") DynamicObject cachedBinding,
@Cached("findFrameSlotOrNull(binding, symbol)") FrameSlotAndDepth cachedFrameSlot,
@Cached("createReadNode(cachedFrameSlot)") ReadFrameSlotNode readLocalVariableNode) {
if (cachedFrameSlot == null) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().nameErrorLocalVariableNotDefined(Layouts.SYMBOL.getString(symbol), binding, this));
} else {
final MaterializedFrame frame = RubyArguments.getDeclarationFrame(Layouts.BINDING.getFrame(binding), cachedFrameSlot.depth);
return readLocalVariableNode.executeRead(frame);
}
final MaterializedFrame frame = RubyArguments.getDeclarationFrame(Layouts.BINDING.getFrame(binding), cachedFrameSlot.depth);
return readLocalVariableNode.executeRead(frame);
}

@TruffleBoundary

0 comments on commit fef441c

Please sign in to comment.