Skip to content

Commit

Permalink
[Truffle More of @offset in Time.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Mar 4, 2015
1 parent 30ac04b commit 88ae22c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/TimeNodes.java
Expand Up @@ -66,8 +66,14 @@ public InternalOffsetNode(InternalOffsetNode prev) {
}

@Specialization
public RubyNilClass internalOffset(RubyTime time) {
return getContext().getCoreLibrary().getNilObject();
public Object internalOffset(RubyTime time) {
final Object offset = time.getOffset();

if (offset == null) {
return getContext().getCoreLibrary().getNilObject();

This comment has been minimized.

Copy link
@nirvdrum

nirvdrum Mar 4, 2015

Contributor

I've asked this before and don't recall the answer, but can't we just enforce that the offset is always nil when null, either by never passing null into the constructor or by moving this conditional to the constructor itself?

This comment has been minimized.

Copy link
@chrisseaton

chrisseaton Mar 4, 2015

Author Contributor

I just tried that again. Things broke and I couldn't figure it out. The core of the problem is I can't figure out what @offset is. Is it always seconds? Can it be something else? Is nil ok? Is float? Not really sure anymore.

} else {
return offset;
}
}
}

Expand All @@ -83,8 +89,9 @@ public InternalSetOffsetNode(InternalSetOffsetNode prev) {
}

@Specialization
public boolean internalSetGMT(RubyTime time, Object setOffset) {
throw new UnsupportedOperationException("_set_offset " + setOffset.getClass());
public Object internalSetOffset(RubyTime time, Object offset) {
time.setOffset(offset);
return offset;
}
}

Expand Down

0 comments on commit 88ae22c

Please sign in to comment.