Skip to content
Permalink
Browse files
[Truffle] Coerce File.exist? argument to String.
  • Loading branch information
nirvdrum committed Feb 19, 2015
1 parent 0331353 commit 6f5ce08da83b0fedcbd825fadc0de2a269536822
Showing 1 changed file with 10 additions and 1 deletion.
@@ -10,12 +10,16 @@
package org.jruby.truffle.nodes.core;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.CreateCast;
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 jnr.posix.FileStat;

import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.coerce.ToStrNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.core.*;
@@ -251,7 +255,8 @@ public boolean executable(RubyString path) {
}

@CoreMethod(names = {"exist?", "exists?"}, onSingleton = true, required = 1)
public abstract static class ExistsNode extends CoreMethodNode {
@NodeChild(value = "path")
public abstract static class ExistsNode extends RubyNode {

public ExistsNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -261,6 +266,10 @@ public ExistsNode(ExistsNode prev) {
super(prev);
}

@CreateCast("path") public RubyNode coercePathToString(RubyNode path) {
return ToStrNodeFactory.create(getContext(), getSourceSection(), path);
}

@Specialization
public boolean exists(RubyString path) {
notDesignedForCompilation();

0 comments on commit 6f5ce08

Please sign in to comment.