Skip to content

Commit

Permalink
[Truffle] Add more File.{atime,ctime,mtime}.
Browse files Browse the repository at this point in the history
  • Loading branch information
bjfish committed May 2, 2015
1 parent a24fcc5 commit 333fb28
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 15 deletions.
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/file/atime_tags.txt

This file was deleted.

3 changes: 0 additions & 3 deletions spec/truffle/tags/core/file/ctime_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/file/mtime_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/file/stat/atime_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/file/stat/ctime_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/file/stat/mtime_tags.txt

This file was deleted.

4 changes: 0 additions & 4 deletions spec/truffle/tags/core/file/stat_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package org.jruby.truffle.nodes.rubinius;

import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.HiddenKey;
import com.oracle.truffle.api.source.SourceSection;
import jnr.posix.FileStat;
Expand All @@ -24,6 +25,64 @@ public abstract class StatPrimitiveNodes {

public static final HiddenKey STAT_IDENTIFIER = new HiddenKey("stat");

@RubiniusPrimitive(name = "stat_atime")
public static abstract class StatAtimePrimitiveNode extends StatReadPrimitiveNode {

public StatAtimePrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object atime(VirtualFrame frame, RubyBasicObject rubyStat) {
final long time = getStat(rubyStat).atime();
return ruby(frame, "Time.at(time)", "time", time);
}

}

@RubiniusPrimitive(name = "stat_ctime")
public static abstract class StatCtimePrimitiveNode extends StatReadPrimitiveNode {

public StatCtimePrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object ctime(VirtualFrame frame, RubyBasicObject rubyStat) {
final long time = getStat(rubyStat).ctime();
return ruby(frame, "Time.at(time)", "time", time);
}

}

@RubiniusPrimitive(name = "stat_mtime")
public static abstract class StatMtimePrimitiveNode extends StatReadPrimitiveNode {

public StatMtimePrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object mtime(VirtualFrame frame, RubyBasicObject rubyStat) {
final long time = getStat(rubyStat).mtime();
return ruby(frame, "Time.at(time)", "time", time);
}

}

@RubiniusPrimitive(name = "stat_blksize")
public static abstract class StatBlksizePrimitiveNode extends StatReadPrimitiveNode {

public StatBlksizePrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public long blksize(RubyBasicObject rubyStat) {
return getStat(rubyStat).blockSize();
}

}

@RubiniusPrimitive(name = "stat_dev")
public static abstract class StatDevPrimitiveNode extends StatReadPrimitiveNode {
Expand Down

0 comments on commit 333fb28

Please sign in to comment.