Skip to content

Commit

Permalink
Showing 27 changed files with 123 additions and 92 deletions.
21 changes: 0 additions & 21 deletions .externalToolBuilders/Create Jar File.launch

This file was deleted.

10 changes: 0 additions & 10 deletions .project
Original file line number Diff line number Diff line change
@@ -10,16 +10,6 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/Create Jar File.launch</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
5 changes: 5 additions & 0 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@

import org.jruby.compiler.Constantizable;
import org.jruby.compiler.NotCompilableException;
import org.jruby.ir.IRScriptBody;
import org.objectweb.asm.util.TraceClassVisitor;
import jnr.constants.Constant;
import jnr.constants.ConstantSet;
@@ -1214,6 +1215,10 @@ private void init() {

// Create an IR manager and a top-level IR scope and bind it to the top-level static-scope object
irManager = new IRManager();
// FIXME: This registers itself into static scope as a side-effect. Let's make this
// relationship handled either more directly or through a descriptice method
// FIXME: We need a failing test case for this since removing it did not regress tests
new IRScriptBody(irManager, "", tc.getCurrentScope().getStaticScope());

// Initialize the "dummy" class used as a marker
dummyClass = new RubyClass(this, classClass);
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/RubyStruct.java
Original file line number Diff line number Diff line change
@@ -252,6 +252,8 @@ public DynamicMethod dup() {
}

if (block.isGiven()) {
// Since this defines a new class, run the block as a module-eval.
block.setEvalType(EvalType.MODULE_EVAL);
// Struct bodies should be public by default, so set block visibility to public. JRUBY-1185.
block.getBinding().setVisibility(Visibility.PUBLIC);
block.yieldNonArray(runtime.getCurrentContext(), null, newStruct);
10 changes: 6 additions & 4 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -1657,16 +1657,18 @@ private IRMethod defineMethodInner(MethodDefNode defNode, IRMethod method, IRSco

addInstr(method, new ReceiveSelfInstr(method.getSelf()));


// These instructions need to be toward the top of the method because they may both be needed for
// processing optional arguments as in def foo(a = Object).
// Set %current_scope = <current-scope>
// Set %current_module = isInstanceMethod ? %self.metaclass : %self
int nearestScopeDepth = parent.getNearestModuleReferencingScopeDepth();
addInstr(method, new CopyInstr(method.getCurrentScopeVariable(), new CurrentScope(nearestScopeDepth == -1 ? 1 : nearestScopeDepth)));
addInstr(method, new CopyInstr(method.getCurrentModuleVariable(), new ScopeModule(nearestScopeDepth == -1 ? 1 : nearestScopeDepth)));

// Build IR for arguments (including the block arg)
receiveMethodArgs(defNode.getArgsNode(), method);

addInstr(method, new CopyInstr(method.getCurrentScopeVariable(), new CurrentScope(nearestScopeDepth == -1 ? 1 : nearestScopeDepth)));
addInstr(method, new CopyInstr(method.getCurrentModuleVariable(), new ScopeModule(nearestScopeDepth == -1 ? 1 : nearestScopeDepth)));

// Thread poll on entry to method
addInstr(method, new ThreadPollInstr());

@@ -3139,7 +3141,7 @@ private void buildRescueBodyInternal(IRScope s, RescueBodyNode rescueBodyNode, V
// of StandardError. I am ignoring this for now and treating this as undefined behavior.
//
// SSS FIXME: Create a 'StandardError' operand type to eliminate this.
Variable v = addResultInstr(s, new InheritanceSearchConstInstr(s.createTemporaryVariable(), s.getCurrentModuleVariable(), "StandardError", false));
Variable v = addResultInstr(s, new InheritanceSearchConstInstr(s.createTemporaryVariable(), s.getCurrentModuleVariable(), "StandardError", false));
outputExceptionCheck(s, v, exc, caughtLabel);
}

2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ir/IREvalScript.java
Original file line number Diff line number Diff line change
@@ -106,7 +106,7 @@ public List<IRClosure> getEndBlocks() {
return endBlocks;
}

public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, DynamicScope evalScope, Block block, String backtraceName) {
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, Block block, String backtraceName) {
if (IRRuntimeHelpers.isDebug()) {
LOG.info("Graph:\n" + cfg().toStringGraph());
LOG.info("CFG:\n" + cfg().toStringInstrs());
25 changes: 11 additions & 14 deletions core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
Original file line number Diff line number Diff line change
@@ -84,9 +84,6 @@ public static IRubyObject interpretCommonEval(Ruby runtime, String file, int lin
StaticScope ss = rootNode.getStaticScope();
IRScope containingIRScope = getEvalContainerScope(ss);
IREvalScript evalScript = IRBuilder.createIRBuilder(runtime, runtime.getIRManager()).buildEvalRoot(ss, containingIRScope, file, lineNumber, rootNode, evalType);
// ClosureInterpreterContext never retrieved as an operand in this context.
// So, self operand is not required here.
// Passing null to force early crasher if ever used differently.
BeginEndInterpreterContext ic = (BeginEndInterpreterContext) evalScript.prepareForInterpretation();
ThreadContext context = runtime.getCurrentContext();

@@ -106,7 +103,7 @@ public static IRubyObject interpretCommonEval(Ruby runtime, String file, int lin
s.growIfNeeded();

runBeginEndBlocks(evalScript.getBeginBlocks(), context, self, ss, null); // FIXME: No temp vars yet right?
rv = evalScript.call(context, self, evalScript.getStaticScope().getModule(), s, block, backtraceName);
rv = evalScript.call(context, self, evalScript.getStaticScope().getModule(), block, backtraceName);
} finally {
runEndBlocks(ic.getEndBlocks(), context, self, ss, null); // FIXME: No temp vars right?
s.clearEvalType();
@@ -722,11 +719,15 @@ public static IRubyObject INTERPRET_METHOD(ThreadContext context, InterpretedIRM
* @return An IRubyObject result from the evaluation
*/
public static IRubyObject evalSimple(ThreadContext context, IRubyObject self, RubyString src, String file, int lineNumber, EvalType evalType) {
Ruby runtime = context.runtime;

if (runtime.getInstanceConfig().getCompileMode() == RubyInstanceConfig.CompileMode.TRUFFLE) {
throw new UnsupportedOperationException();
}

// this is ensured by the caller
assert file != null;

Ruby runtime = context.runtime;

// no binding, just eval in "current" frame (caller's frame)
RubyString source = src.convertToString();

@@ -736,10 +737,6 @@ public static IRubyObject evalSimple(ThreadContext context, IRubyObject self, Ru
try {
Node node = runtime.parseEval(source.getByteList(), file, evalScope, lineNumber);

if (runtime.getInstanceConfig().getCompileMode() == RubyInstanceConfig.CompileMode.TRUFFLE) {
throw new UnsupportedOperationException();
}

// SSS FIXME: AST interpreter passed both a runtime (which comes from the source string)
// and the thread-context rather than fetch one from the other. Why is that?
return Interpreter.interpretSimpleEval(runtime, file, lineNumber, "(eval)", node, self, evalType);
@@ -766,6 +763,10 @@ public static IRubyObject evalSimple(ThreadContext context, IRubyObject self, Ru
*/
public static IRubyObject evalWithBinding(ThreadContext context, IRubyObject self, IRubyObject src, Binding binding) {
Ruby runtime = context.runtime;
if (runtime.getInstanceConfig().getCompileMode() == RubyInstanceConfig.CompileMode.TRUFFLE) {
throw new UnsupportedOperationException();
}

DynamicScope evalScope;

// in 1.9, eval scopes are local to the binding
@@ -782,10 +783,6 @@ public static IRubyObject evalWithBinding(ThreadContext context, IRubyObject sel
Node node = runtime.parseEval(source.getByteList(), binding.getFile(), evalScope, binding.getLine());
Block block = binding.getFrame().getBlock();

if (runtime.getInstanceConfig().getCompileMode() == RubyInstanceConfig.CompileMode.TRUFFLE) {
throw new UnsupportedOperationException();
}

// SSS FIXME: AST interpreter passed both a runtime (which comes from the source string)
// and the thread-context rather than fetch one from the other. Why is that?
return Interpreter.interpretBindingEval(runtime, binding.getFile(), binding.getLine(), binding.getMethod(), node, self, block);
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ public Object dispatchReadConstant(
return constant.getValue();
}

final RubyClass callerClass = box.box(RubyArguments.getSelf(frame.getArguments())).getMetaClass();
final RubyClass callerClass = ignoreVisibility ? null : box.box(RubyArguments.getSelf(frame.getArguments())).getMetaClass();

final RubyMethod missingMethod = lookup(callerClass, receiverObject, "const_missing", ignoreVisibility,
dispatchAction);
@@ -111,7 +111,7 @@ public Object dispatch(
// Need to be much more fine grained with TruffleBoundary here
CompilerDirectives.transferToInterpreter();

final RubyClass callerClass = box.box(RubyArguments.getSelf(frame.getArguments())).getMetaClass();
final RubyClass callerClass = ignoreVisibility ? null : box.box(RubyArguments.getSelf(frame.getArguments())).getMetaClass();

final RubyMethod method = lookup(callerClass, receiverObject, methodName.toString(),
ignoreVisibility, dispatchAction);
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ private Object doUnboxedObject(
Dispatch.DispatchAction dispatchAction,
Object methodReceiverObject) {
final RubyBasicObject boxedReceiverObject = getContext().getCoreLibrary().box(receiverObject);
final RubyClass callerClass = getContext().getCoreLibrary().box(RubyArguments.getSelf(frame.getArguments())).getMetaClass();
final RubyClass callerClass = ignoreVisibility ? null : getContext().getCoreLibrary().box(RubyArguments.getSelf(frame.getArguments())).getMetaClass();

if (dispatchAction == Dispatch.DispatchAction.CALL_METHOD || dispatchAction == Dispatch.DispatchAction.RESPOND_TO_METHOD) {
final RubyMethod method = lookup(callerClass, boxedReceiverObject, methodName.toString(), ignoreVisibility,
@@ -164,7 +164,7 @@ private Object doRubyBasicObject(
Dispatch.DispatchAction dispatchAction,
Object methodReceiverObject) {
final RubyBasicObject boxedReceiverObject = getContext().getCoreLibrary().box(receiverObject);
final RubyClass callerClass = getContext().getCoreLibrary().box(RubyArguments.getSelf(frame.getArguments())).getMetaClass();
final RubyClass callerClass = ignoreVisibility ? null : getContext().getCoreLibrary().box(RubyArguments.getSelf(frame.getArguments())).getMetaClass();

if (dispatchAction == Dispatch.DispatchAction.CALL_METHOD || dispatchAction == Dispatch.DispatchAction.RESPOND_TO_METHOD) {
final RubyMethod method = lookup(callerClass, boxedReceiverObject, methodName.toString(), ignoreVisibility,
17 changes: 10 additions & 7 deletions lib/ruby/2.1/csv.rb
Original file line number Diff line number Diff line change
@@ -1148,9 +1148,9 @@ def self.generate(*args)
io.seek(0, IO::SEEK_END)
args.unshift(io)
else
encoding = (args[-1] = args[-1].dup).delete(:encoding) if args.last.is_a?(Hash)
encoding = args[-1][:encoding] if args.last.is_a?(Hash)
str = ""
str.encode!(encoding) if encoding
str.force_encoding(encoding) if encoding
args.unshift(str)
end
csv = new(*args) # wrap
@@ -1515,7 +1515,7 @@ def initialize(data, options = Hash.new)
init_headers(options)
init_comments(options)

options.delete(:encoding)
@force_encoding = !!(encoding || options.delete(:encoding))
options.delete(:internal_encoding)
options.delete(:external_encoding)
unless options.empty?
@@ -1655,10 +1655,13 @@ def <<(row)

output = row.map(&@quote).join(@col_sep) + @row_sep # quote and separate
if @io.is_a?(StringIO) and
output.encoding != raw_encoding and
(compatible_encoding = Encoding.compatible?(@io.string, output))
@io.set_encoding(compatible_encoding)
@io.seek(0, IO::SEEK_END)
output.encoding != (encoding = raw_encoding)
if @force_encoding
output = output.encode(encoding)
elsif (compatible_encoding = Encoding.compatible?(@io.string, output))
@io.set_encoding(compatible_encoding)
@io.seek(0, IO::SEEK_END)
end
end
@io << output

2 changes: 1 addition & 1 deletion lib/ruby/2.1/erb.rb
Original file line number Diff line number Diff line change
@@ -837,7 +837,7 @@ def run(b=new_toplevel)
# the results of that code. (See ERB::new for details on how this process
# can be affected by _safe_level_.)
#
# _b_ accepts a Binding or Proc object which is used to set the context of
# _b_ accepts a Binding object which is used to set the context of
# code evaluation.
#
def result(b=new_toplevel)
14 changes: 10 additions & 4 deletions lib/ruby/2.1/fileutils.rb
Original file line number Diff line number Diff line change
@@ -277,7 +277,7 @@ def rmdir(list, options = {})
Dir.rmdir(dir)
end
end
rescue Errno::ENOTEMPTY, Errno::ENOENT
rescue Errno::ENOTEMPTY, Errno::EEXIST, Errno::ENOENT
end
end
end
@@ -864,7 +864,8 @@ def install(src, dest, options = {})
fu_check_options options, OPT_TABLE['install']
fu_output_message "install -c#{options[:preserve] && ' -p'}#{options[:mode] ? (' -m 0%o' % options[:mode]) : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
return if options[:noop]
fu_each_src_dest(src, dest) do |s, d, st|
fu_each_src_dest(src, dest) do |s, d|
st = File.stat(s)
unless File.exist?(d) and compare_file(s, d)
remove_file d, true
copy_file s, d
@@ -1262,7 +1263,12 @@ def dereference?
end

def exist?
lstat! ? true : false
begin
lstat
true
rescue Errno::ENOENT
false
end
end

def file?
@@ -1580,7 +1586,7 @@ def fu_list(arg) #:nodoc:
def fu_each_src_dest(src, dest) #:nodoc:
fu_each_src_dest0(src, dest) do |s, d|
raise ArgumentError, "same file: #{s} and #{d}" if fu_same?(s, d)
yield s, d, File.stat(s)
yield s, d
end
end
private_module_function :fu_each_src_dest
1 change: 1 addition & 0 deletions lib/ruby/2.1/find.rb
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ def find(*paths) # :yield: path
fs_encoding = Encoding.find("filesystem")

paths.collect!{|d| raise Errno::ENOENT unless File.exist?(d); d.dup}.each do |path|
path = path.to_path if path.respond_to? :to_path
enc = path.encoding == Encoding::US_ASCII ? fs_encoding : path.encoding
ps = [path]
while file = ps.shift
12 changes: 6 additions & 6 deletions lib/ruby/2.1/gserver.rb
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@
# super(port, *args)
# end
# def serve(io)
# io.puts(Time.now.to_s)
# io.puts(Time.now.to_i)
# end
# end
#
@@ -144,7 +144,7 @@ def join
attr_reader :port
# Host on which to bind, as a String
attr_reader :host
# Maximum number of connections to accept at at ime, as a Fixnum
# Maximum number of connections to accept at a time, as a Fixnum
attr_reader :maxConnections
# IO Device on which log messages should be written
attr_accessor :stdlog
@@ -156,7 +156,7 @@ def join

# Called when a client connects, if auditing is enabled.
#
# +client+:: a TCPSocket instances representing the client that connected
# +client+:: a TCPSocket instance representing the client that connected
#
# Return true to allow this client to connect, false to prevent it.
def connecting(client)
@@ -192,7 +192,7 @@ def stopping()
# Called if #debug is true whenever an unhandled exception is raised.
# This implementation simply logs the backtrace.
#
# +detail+:: The Exception that was caught
# +detail+:: the Exception that was caught
def error(detail)
log(detail.backtrace.join("\n"))
end
@@ -212,9 +212,9 @@ def log(msg)

# Create a new server
#
# +port+:: the port, as a Fixnum, on which to listen.
# +port+:: the port, as a Fixnum, on which to listen
# +host+:: the host to bind to
# +maxConnections+:: The maximum number of simultaneous connections to
# +maxConnections+:: the maximum number of simultaneous connections to
# accept
# +stdlog+:: IO device on which to log messages
# +audit+:: if true, lifecycle callbacks will be called. See #audit
6 changes: 3 additions & 3 deletions lib/ruby/2.1/matrix.rb
Original file line number Diff line number Diff line change
@@ -1764,9 +1764,9 @@ def inner_product(v)
#
def cross_product(v)
Vector.Raise ErrDimensionMismatch unless size == v.size && v.size == 3
Vector[ v[1]*@elements[2] - v[2]*@elements[1],
v[2]*@elements[0] - v[0]*@elements[2],
v[0]*@elements[1] - v[1]*@elements[0] ]
Vector[ v[2]*@elements[1] - v[1]*@elements[2],
v[0]*@elements[2] - v[2]*@elements[0],
v[1]*@elements[0] - v[0]*@elements[1] ]
end

#
11 changes: 7 additions & 4 deletions lib/ruby/2.1/net/ftp.rb
Original file line number Diff line number Diff line change
@@ -1105,13 +1105,16 @@ def read(len = nil)
end

def gets
return readuntil("\n")
rescue EOFError
return nil
line = readuntil("\n", true)
return line.empty? ? nil : line
end

def readline
return readuntil("\n")
line = gets
if line.nil?
raise EOFError, "end of file reached"
end
return line
end
end
# :startdoc:
Loading

0 comments on commit 84177f2

Please sign in to comment.