OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/date.h" | 8 #include "src/date.h" |
9 #include "src/dateparser-inl.h" | 9 #include "src/dateparser-inl.h" |
10 #include "src/messages.h" | |
11 #include "src/runtime/runtime-utils.h" | 10 #include "src/runtime/runtime-utils.h" |
12 | 11 |
13 namespace v8 { | 12 namespace v8 { |
14 namespace internal { | 13 namespace internal { |
15 | 14 |
16 RUNTIME_FUNCTION(Runtime_DateMakeDay) { | 15 RUNTIME_FUNCTION(Runtime_DateMakeDay) { |
17 SealHandleScope shs(isolate); | 16 SealHandleScope shs(isolate); |
18 DCHECK(args.length() == 2); | 17 DCHECK(args.length() == 2); |
19 | 18 |
20 CONVERT_SMI_ARG_CHECKED(year, 0); | 19 CONVERT_SMI_ARG_CHECKED(year, 0); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } | 55 } |
57 } | 56 } |
58 date->SetValue(*value, is_value_nan); | 57 date->SetValue(*value, is_value_nan); |
59 return *value; | 58 return *value; |
60 } | 59 } |
61 | 60 |
62 | 61 |
63 RUNTIME_FUNCTION(Runtime_ThrowNotDateError) { | 62 RUNTIME_FUNCTION(Runtime_ThrowNotDateError) { |
64 HandleScope scope(isolate); | 63 HandleScope scope(isolate); |
65 DCHECK(args.length() == 0); | 64 DCHECK(args.length() == 0); |
66 THROW_NEW_ERROR_RETURN_FAILURE(isolate, | 65 THROW_NEW_ERROR_RETURN_FAILURE( |
67 NewTypeError(MessageTemplate::kNotDateObject)); | 66 isolate, NewTypeError("not_date_object", HandleVector<Object>(NULL, 0))); |
68 } | 67 } |
69 | 68 |
70 | 69 |
71 RUNTIME_FUNCTION(Runtime_DateCurrentTime) { | 70 RUNTIME_FUNCTION(Runtime_DateCurrentTime) { |
72 HandleScope scope(isolate); | 71 HandleScope scope(isolate); |
73 DCHECK(args.length() == 0); | 72 DCHECK(args.length() == 0); |
74 if (FLAG_log_timer_events || FLAG_prof_cpp) LOG(isolate, CurrentTimeEvent()); | 73 if (FLAG_log_timer_events || FLAG_prof_cpp) LOG(isolate, CurrentTimeEvent()); |
75 | 74 |
76 // According to ECMA-262, section 15.9.1, page 117, the precision of | 75 // According to ECMA-262, section 15.9.1, page 117, the precision of |
77 // the number in a Date object representing a particular instant in | 76 // the number in a Date object representing a particular instant in |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 172 |
174 | 173 |
175 RUNTIME_FUNCTION(Runtime_DateField) { | 174 RUNTIME_FUNCTION(Runtime_DateField) { |
176 SealHandleScope shs(isolate); | 175 SealHandleScope shs(isolate); |
177 DCHECK(args.length() == 2); | 176 DCHECK(args.length() == 2); |
178 CONVERT_ARG_CHECKED(Object, obj, 0); | 177 CONVERT_ARG_CHECKED(Object, obj, 0); |
179 CONVERT_SMI_ARG_CHECKED(index, 1); | 178 CONVERT_SMI_ARG_CHECKED(index, 1); |
180 if (!obj->IsJSDate()) { | 179 if (!obj->IsJSDate()) { |
181 HandleScope scope(isolate); | 180 HandleScope scope(isolate); |
182 THROW_NEW_ERROR_RETURN_FAILURE( | 181 THROW_NEW_ERROR_RETURN_FAILURE( |
183 isolate, NewTypeError(MessageTemplate::kNotDateObject)); | 182 isolate, |
| 183 NewTypeError("not_date_object", HandleVector<Object>(NULL, 0))); |
184 } | 184 } |
185 JSDate* date = JSDate::cast(obj); | 185 JSDate* date = JSDate::cast(obj); |
186 if (index == 0) return date->value(); | 186 if (index == 0) return date->value(); |
187 return JSDate::GetField(date, Smi::FromInt(index)); | 187 return JSDate::GetField(date, Smi::FromInt(index)); |
188 } | 188 } |
189 } | 189 } |
190 } // namespace v8::internal | 190 } // namespace v8::internal |
OLD | NEW |