forked from jruby/jruby
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Truffle] Call #to_path on autoload paths.
- Loading branch information
Showing
5 changed files
with
74 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
fails:Kernel.autoload calls #to_path on non-String filenames | ||
slow:Kernel#autoload when Object is frozen raises a RuntimeError before defining the constant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
fails:Module#autoload calls #to_path on non-string filenames | ||
fails:Module#autoload calls #to_path on non-String filename arguments | ||
fails:Module#autoload (concurrently) blocks a second thread while a first is doing the autoload | ||
fails:Module#autoload (concurrently) blocks others threads while doing an autoload | ||
fails:Module#autoload shares the autoload request across dup'ed copies of modules |
66 changes: 66 additions & 0 deletions
66
truffle/src/main/java/org/jruby/truffle/nodes/coerce/ToPathNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (c) 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 | ||
*/ | ||
|
||
package org.jruby.truffle.nodes.coerce; | ||
|
||
import com.oracle.truffle.api.CompilerDirectives; | ||
import com.oracle.truffle.api.dsl.NodeChild; | ||
import com.oracle.truffle.api.dsl.Specialization; | ||
import com.oracle.truffle.api.frame.VirtualFrame; | ||
import com.oracle.truffle.api.source.SourceSection; | ||
import org.jruby.truffle.nodes.RubyNode; | ||
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode; | ||
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory; | ||
import org.jruby.truffle.runtime.RubyContext; | ||
import org.jruby.truffle.runtime.control.RaiseException; | ||
import org.jruby.truffle.runtime.core.RubyBasicObject; | ||
import org.jruby.truffle.runtime.core.RubyString; | ||
|
||
@NodeChild(value = "child", type = RubyNode.class) | ||
public abstract class ToPathNode extends RubyNode { | ||
|
||
@Child private CallDispatchHeadNode toPathNode; | ||
|
||
public ToPathNode(RubyContext context, SourceSection sourceSection) { | ||
super(context, sourceSection); | ||
toPathNode = DispatchHeadNodeFactory.createMethodCall(context); | ||
} | ||
|
||
public abstract RubyString executeRubyString(VirtualFrame frame, Object object); | ||
|
||
@Specialization | ||
public RubyBasicObject coerceRubyString(RubyString path) { | ||
return path; | ||
} | ||
|
||
@Specialization(guards = "!isRubyString(object)") | ||
public RubyBasicObject coerceObject(VirtualFrame frame, Object object) { | ||
final Object coerced; | ||
|
||
try { | ||
coerced = toPathNode.call(frame, object, "to_path", null); | ||
} catch (RaiseException e) { | ||
if (e.getRubyException().getLogicalClass() == getContext().getCoreLibrary().getNoMethodErrorClass()) { | ||
CompilerDirectives.transferToInterpreter(); | ||
throw new RaiseException(getContext().getCoreLibrary().typeErrorNoImplicitConversion(object, "String", this)); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
|
||
if (coerced instanceof RubyString) { | ||
return (RubyString) coerced; | ||
} else { | ||
CompilerDirectives.transferToInterpreter(); | ||
throw new RaiseException(getContext().getCoreLibrary().typeErrorBadCoercion(object, "String", "to_path", coerced, this)); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters