10
10
package org .jruby .truffle .nodes .rubinius ;
11
11
12
12
import com .oracle .truffle .api .CompilerDirectives ;
13
+ import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
13
14
import com .oracle .truffle .api .dsl .Specialization ;
14
15
import com .oracle .truffle .api .frame .VirtualFrame ;
15
16
import com .oracle .truffle .api .source .SourceSection ;
@@ -46,7 +47,7 @@ public RubyTime timeSNow(VirtualFrame frame, RubyClass timeClass) {
46
47
return new RubyTime (timeClass , now (readTimeZoneNode .executeRubyString (frame )), nil ());
47
48
}
48
49
49
- @ CompilerDirectives . TruffleBoundary
50
+ @ TruffleBoundary
50
51
private DateTime now (RubyString timeZone ) {
51
52
return DateTime .now (org .jruby .RubyTime .getTimeZoneFromTZString (getContext ().getRuntime (), timeZone .toString ()));
52
53
}
@@ -68,7 +69,7 @@ public RubyTime timeSDup(RubyTime other) {
68
69
69
70
}
70
71
71
- @ RubiniusPrimitive (name = "time_s_specific" , needsSelf = false )
72
+ @ RubiniusPrimitive (name = "time_s_specific" , needsSelf = false , lowerFixnumParameters = { 0 , 1 } )
72
73
public static abstract class TimeSSpecificPrimitiveNode extends RubiniusPrimitiveNode {
73
74
74
75
@ Child private ReadTimeZoneNode readTimeZoneNode ;
@@ -78,48 +79,27 @@ public TimeSSpecificPrimitiveNode(RubyContext context, SourceSection sourceSecti
78
79
readTimeZoneNode = new ReadTimeZoneNode (context , sourceSection );
79
80
}
80
81
81
- @ Specialization (guards = {"isTrue(isUTC)" , "isNil(offset)" })
82
- public RubyTime timeSSpecificUTC (long seconds , long nanoseconds , boolean isUTC , Object offset ) {
83
- return timeSSpecificUTC ((int ) seconds , (int ) nanoseconds , isUTC , offset );
84
- }
85
-
86
- @ Specialization (guards = {"isTrue(isUTC)" , "isNil(offset)" })
87
- public RubyTime timeSSpecificUTC (long seconds , int nanoseconds , boolean isUTC , Object offset ) {
88
- return timeSSpecificUTC ((int ) seconds , nanoseconds , isUTC , offset );
89
- }
90
-
91
- @ Specialization (guards = {"isTrue(isUTC)" , "isNil(offset)" })
82
+ @ Specialization (guards = { "isTrue(isUTC)" , "isNil(offset)" })
92
83
public RubyTime timeSSpecificUTC (int seconds , int nanoseconds , boolean isUTC , Object offset ) {
93
84
// TODO(CS): overflow checks needed?
94
85
final long milliseconds = seconds * 1_000L + (nanoseconds / 1_000_000 );
95
86
return new RubyTime (getContext ().getCoreLibrary ().getTimeClass (), time (milliseconds ), nil ());
96
87
}
97
88
98
-
99
- @ Specialization (guards = {"!isTrue(isUTC)" , "isNil(offset)" })
100
- public RubyTime timeSSpecific (VirtualFrame frame , long seconds , long nanoseconds , boolean isUTC , Object offset ) {
101
- return timeSSpecific (frame , (int ) seconds , (int ) nanoseconds , isUTC , offset );
102
- }
103
-
104
- @ Specialization (guards = {"!isTrue(isUTC)" , "isNil(offset)" })
105
- public RubyTime timeSSpecific (VirtualFrame frame , long seconds , int nanoseconds , boolean isUTC , Object offset ) {
106
- return timeSSpecific (frame , (int ) seconds , nanoseconds , isUTC , offset );
107
- }
108
-
109
- @ Specialization (guards = {"!isTrue(isUTC)" , "isNil(offset)" })
89
+ @ Specialization (guards = { "!isTrue(isUTC)" , "isNil(offset)" })
110
90
public RubyTime timeSSpecific (VirtualFrame frame , int seconds , int nanoseconds , boolean isUTC , Object offset ) {
111
91
// TODO(CS): overflow checks needed?
112
92
final long milliseconds = (long ) seconds * 1_000 + ((long ) nanoseconds / 1_000_000 );
113
- return new RubyTime (getContext ().getCoreLibrary ().getTimeClass (), time (milliseconds , readTimeZoneNode .executeRubyString (frame )), offset );
93
+ return new RubyTime (getContext ().getCoreLibrary ().getTimeClass (), localtime (milliseconds , readTimeZoneNode .executeRubyString (frame )), offset );
114
94
}
115
95
116
- @ CompilerDirectives . TruffleBoundary
117
- public DateTime time (long milliseconds ) {
96
+ @ TruffleBoundary
97
+ private DateTime time (long milliseconds ) {
118
98
return new DateTime (milliseconds , DateTimeZone .UTC );
119
99
}
120
100
121
- @ CompilerDirectives . TruffleBoundary
122
- private DateTime time (long milliseconds , RubyString timeZone ) {
101
+ @ TruffleBoundary
102
+ private DateTime localtime (long milliseconds , RubyString timeZone ) {
123
103
return new DateTime (milliseconds , org .jruby .RubyTime .getTimeZoneFromTZString (getContext ().getRuntime (), timeZone .toString ()));
124
104
}
125
105
@@ -160,7 +140,7 @@ public TimeDecomposePrimitiveNode(RubyContext context, SourceSection sourceSecti
160
140
super (context , sourceSection );
161
141
}
162
142
163
- @ CompilerDirectives . TruffleBoundary
143
+ @ TruffleBoundary
164
144
@ Specialization
165
145
public RubyArray timeDecompose (RubyTime time ) {
166
146
final DateTime dateTime = time .getDateTime ();
@@ -203,7 +183,7 @@ public TimeStrftimePrimitiveNode(RubyContext context, SourceSection sourceSectio
203
183
super (context , sourceSection );
204
184
}
205
185
206
- @ CompilerDirectives . TruffleBoundary
186
+ @ TruffleBoundary
207
187
@ Specialization
208
188
public RubyString timeStrftime (RubyTime time , RubyString format ) {
209
189
final RubyDateFormatter rdf = getContext ().getRuntime ().getCurrentContext ().getRubyDateFormatter ();
0 commit comments