Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 23b320ec4de9
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a83d6a50e5f9
Choose a head ref
  • 5 commits
  • 11 files changed
  • 1 contributor

Commits on May 17, 2015

  1. Copy the full SHA
    cd829e9 View commit details
  2. [Truffle] Fix warnings.

    eregon committed May 17, 2015
    Copy the full SHA
    836e3b4 View commit details
  3. Copy the full SHA
    26adc0d View commit details
  4. Copy the full SHA
    61abd6d View commit details
  5. Copy the full SHA
    a83d6a5 View commit details
5 changes: 0 additions & 5 deletions spec/truffle/tags/core/module/class_eval_tags.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
fails:Module#class_eval uses the optional filename and lineno parameters for error messages
fails:Module#class_eval converts a non-string filename to a string using to_str
fails:Module#class_eval raises a TypeError when the given filename can't be converted to string using to_str
fails:Module#class_eval converts non string eval-string to string using to_str
fails:Module#class_eval raises a TypeError when the given eval-string can't be converted to string using to_str
fails:Module#class_eval raises an ArgumentError when a block and normal arguments are given
fails:Module#class_eval adds methods respecting the lexical constant scope
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/module/class_exec_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/module/initialize_tags.txt

This file was deleted.

5 changes: 0 additions & 5 deletions spec/truffle/tags/core/module/module_eval_tags.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
fails:Module#module_eval uses the optional filename and lineno parameters for error messages
fails:Module#module_eval converts a non-string filename to a string using to_str
fails:Module#module_eval raises a TypeError when the given filename can't be converted to string using to_str
fails:Module#module_eval converts non string eval-string to string using to_str
fails:Module#module_eval raises a TypeError when the given eval-string can't be converted to string using to_str
fails:Module#module_eval raises an ArgumentError when a block and normal arguments are given
fails:Module#module_eval adds methods respecting the lexical constant scope
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/module/module_exec_tags.txt

This file was deleted.

59 changes: 41 additions & 18 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@

import com.oracle.truffle.api.CallTarget;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.CreateCast;
import com.oracle.truffle.api.dsl.NodeChild;
@@ -36,6 +37,7 @@
import org.jruby.truffle.nodes.cast.BooleanCastNodeGen;
import org.jruby.truffle.nodes.coerce.SymbolOrToStrNode;
import org.jruby.truffle.nodes.coerce.SymbolOrToStrNodeGen;
import org.jruby.truffle.nodes.coerce.ToStrNode;
import org.jruby.truffle.nodes.coerce.ToStrNodeGen;
import org.jruby.truffle.nodes.control.SequenceNode;
import org.jruby.truffle.nodes.core.KernelNodes.BindingNode;
@@ -572,6 +574,7 @@ public abstract static class ClassEvalNode extends CoreMethodArrayArgumentsNode

@Child private YieldDispatchHeadNode yield;
@Child private BindingNode bindingNode;
@Child private ToStrNode toStrNode;

public ClassEvalNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -586,32 +589,45 @@ protected RubyBinding getCallerBinding(VirtualFrame frame) {
return bindingNode.executeRubyBinding(frame);
}

protected RubyString toStr(VirtualFrame frame, Object object) {
if (toStrNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
toStrNode = insert(ToStrNodeGen.create(getContext(), getSourceSection(), null));
}
return toStrNode.executeRubyString(frame, object);
}

@Specialization
public Object classEval(VirtualFrame frame, RubyModule module, RubyString code, UndefinedPlaceholder file, UndefinedPlaceholder line, UndefinedPlaceholder block) {
CompilerDirectives.transferToInterpreter();

final Source source = Source.fromText(code.toString(), "(eval)");
return classEvalSource(frame, module, source, code.getByteList().getEncoding());
return classEvalSource(frame, module, code, "(eval)");
}

@Specialization
public Object classEval(VirtualFrame frame, RubyModule module, RubyString code, RubyString file, UndefinedPlaceholder line, UndefinedPlaceholder block) {
CompilerDirectives.transferToInterpreter();

final Source source = Source.asPseudoFile(code.toString(), file.toString());
return classEvalSource(frame, module, source, code.getByteList().getEncoding());
return classEvalSource(frame, module, code, file.toString());
}

@Specialization
public Object classEval(VirtualFrame frame, RubyModule module, RubyString code, RubyString file, int line, UndefinedPlaceholder block) {
CompilerDirectives.transferToInterpreter();
return classEvalSource(frame, module, code, file.toString());
}

@Specialization(guards = "!isUndefinedPlaceholder(code)")
public Object classEval(VirtualFrame frame, RubyModule module, Object code, UndefinedPlaceholder file, UndefinedPlaceholder line, UndefinedPlaceholder block) {
return classEvalSource(frame, module, toStr(frame, code), file.toString());
}

final Source source = Source.asPseudoFile(code.toString(), file.toString());
return classEvalSource(frame, module, source, code.getByteList().getEncoding());
@Specialization(guards = "!isUndefinedPlaceholder(file)")
public Object classEval(VirtualFrame frame, RubyModule module, RubyString code, Object file, UndefinedPlaceholder line, UndefinedPlaceholder block) {
return classEvalSource(frame, module, code, toStr(frame, file).toString());
}

private Object classEvalSource(VirtualFrame frame, RubyModule module, Source source, Encoding encoding) {
private Object classEvalSource(VirtualFrame frame, RubyModule module, RubyString code, String file) {
RubyBinding binding = getCallerBinding(frame);
Encoding encoding = code.getByteList().getEncoding();

CompilerDirectives.transferToInterpreter();
Source source = Source.fromText(code.toString(), file);

return getContext().execute(source, encoding, TranslatorDriver.ParserContext.MODULE, module, binding.getFrame(), this, new NodeWrapper() {
@Override
@@ -629,13 +645,18 @@ public Object classEval(VirtualFrame frame, RubyModule self, UndefinedPlaceholde
@Specialization
public Object classEval(RubyModule self, UndefinedPlaceholder code, UndefinedPlaceholder file, UndefinedPlaceholder line, UndefinedPlaceholder block) {
CompilerDirectives.transferToInterpreter();

throw new RaiseException(getContext().getCoreLibrary().argumentError(0, 1, 2, this));
}

@Specialization(guards = "!isUndefinedPlaceholder(code)")
public Object classEval(RubyModule self, Object code, UndefinedPlaceholder file, UndefinedPlaceholder line, RubyProc block) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().argumentError(1, 0, this));
}

}

@CoreMethod(names = {"class_exec","module_exec"}, argumentsAsArray = true, needsBlock = true)
@CoreMethod(names = { "class_exec", "module_exec" }, argumentsAsArray = true, needsBlock = true)
public abstract static class ClassExecNode extends CoreMethodArrayArgumentsNode {

@Child private YieldDispatchHeadNode yield;
@@ -649,11 +670,13 @@ public ClassExecNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public Object classExec(VirtualFrame frame, RubyModule self, Object[] args, RubyProc block) {
CompilerDirectives.transferToInterpreter();

// TODO: deal with args
return yield.dispatchWithModifiedSelf(frame, block, self, args);
}

return yield.dispatchWithModifiedSelf(frame, block, self);
@Specialization
public Object classExec(VirtualFrame frame, RubyModule self, Object[] args, UndefinedPlaceholder block) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().noBlockGiven(this));
}

}
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ public Object execute(VirtualFrame frame) {
RubyModule definingModule;

if (constant == null) {
definingModule = new RubyModule(getContext(), lexicalParent, name, this);
definingModule = new RubyModule(getContext(), getContext().getCoreLibrary().getModuleClass(), lexicalParent, name, this);
} else {
Object module = constant.getValue();
if (!(module instanceof RubyModule) || !((RubyModule) module).isOnlyAModule()) {
Original file line number Diff line number Diff line change
@@ -813,6 +813,11 @@ public RubyException localJumpError(String message, Node currentNode) {
return new RubyException(localJumpErrorClass, context.makeString(message), RubyCallStack.getBacktrace(currentNode));
}

public RubyException noBlockGiven(Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
return localJumpError("no block given", currentNode);
}

public RubyException unexpectedReturn(Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
return localJumpError("unexpected return", currentNode);
Original file line number Diff line number Diff line change
@@ -102,11 +102,7 @@ public static void debugModuleChain(RubyModule module) {
*/
private final Set<RubyModule> lexicalDependents = Collections.newSetFromMap(new WeakHashMap<RubyModule, Boolean>());

public RubyModule(RubyContext context, RubyModule lexicalParent, String name, Node currentNode) {
this(context, context.getCoreLibrary().getModuleClass(), lexicalParent, name, currentNode);
}

protected RubyModule(RubyContext context, RubyClass selfClass, RubyModule lexicalParent, String name, Node currentNode) {
public RubyModule(RubyContext context, RubyClass selfClass, RubyModule lexicalParent, String name, Node currentNode) {
super(context, selfClass);
this.context = context;

@@ -611,7 +607,7 @@ public static class ModuleAllocator implements Allocator {

@Override
public RubyBasicObject allocate(RubyContext context, RubyClass rubyClass, Node currentNode) {
return new RubyModule(context, null, null, currentNode);
return new RubyModule(context, rubyClass, null, null, currentNode);
}

}
2 changes: 0 additions & 2 deletions truffle/src/main/ruby/core/kernel.rb
Original file line number Diff line number Diff line change
@@ -31,8 +31,6 @@ def caller(start = 1, limit = nil)
def at_exit(&block)
Truffle::Primitive.at_exit false, &block
end
private :at_exit
module_function :at_exit


end
4 changes: 2 additions & 2 deletions truffle/src/main/ruby/core/rubinius/common/argf.rb
Original file line number Diff line number Diff line change
@@ -453,7 +453,7 @@ def seek(*args)
def set_encoding(*args)
@encoding_args = args
if @stream and !@stream.closed?
@stream.set_encoding *args
@stream.set_encoding(*args)
end
end

@@ -474,7 +474,7 @@ def stream(file)
stream = file == "-" ? STDIN : File.open(file, "r", :external_encoding => encoding)

if @encoding_args
stream.set_encoding *@encoding_args
stream.set_encoding(*@encoding_args)
elsif encoding
stream.set_encoding encoding
end