| 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" |
| 10 #include "src/runtime/runtime-utils.h" | 11 #include "src/runtime/runtime-utils.h" |
| 11 | 12 |
| 12 namespace v8 { | 13 namespace v8 { |
| 13 namespace internal { | 14 namespace internal { |
| 14 | 15 |
| 15 RUNTIME_FUNCTION(Runtime_DateMakeDay) { | 16 RUNTIME_FUNCTION(Runtime_DateMakeDay) { |
| 16 SealHandleScope shs(isolate); | 17 SealHandleScope shs(isolate); |
| 17 DCHECK(args.length() == 2); | 18 DCHECK(args.length() == 2); |
| 18 | 19 |
| 19 CONVERT_SMI_ARG_CHECKED(year, 0); | 20 CONVERT_SMI_ARG_CHECKED(year, 0); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 } | 56 } |
| 56 } | 57 } |
| 57 date->SetValue(*value, is_value_nan); | 58 date->SetValue(*value, is_value_nan); |
| 58 return *value; | 59 return *value; |
| 59 } | 60 } |
| 60 | 61 |
| 61 | 62 |
| 62 RUNTIME_FUNCTION(Runtime_ThrowNotDateError) { | 63 RUNTIME_FUNCTION(Runtime_ThrowNotDateError) { |
| 63 HandleScope scope(isolate); | 64 HandleScope scope(isolate); |
| 64 DCHECK(args.length() == 0); | 65 DCHECK(args.length() == 0); |
| 65 THROW_NEW_ERROR_RETURN_FAILURE( | 66 THROW_NEW_ERROR_RETURN_FAILURE(isolate, |
| 66 isolate, NewTypeError("not_date_object", HandleVector<Object>(NULL, 0))); | 67 NewTypeError(MessageTemplate::kNotDateObject)); |
| 67 } | 68 } |
| 68 | 69 |
| 69 | 70 |
| 70 RUNTIME_FUNCTION(Runtime_DateCurrentTime) { | 71 RUNTIME_FUNCTION(Runtime_DateCurrentTime) { |
| 71 HandleScope scope(isolate); | 72 HandleScope scope(isolate); |
| 72 DCHECK(args.length() == 0); | 73 DCHECK(args.length() == 0); |
| 73 if (FLAG_log_timer_events || FLAG_prof_cpp) LOG(isolate, CurrentTimeEvent()); | 74 if (FLAG_log_timer_events || FLAG_prof_cpp) LOG(isolate, CurrentTimeEvent()); |
| 74 | 75 |
| 75 // According to ECMA-262, section 15.9.1, page 117, the precision of | 76 // According to ECMA-262, section 15.9.1, page 117, the precision of |
| 76 // the number in a Date object representing a particular instant in | 77 // the number in a Date object representing a particular instant in |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 173 |
| 173 | 174 |
| 174 RUNTIME_FUNCTION(Runtime_DateField) { | 175 RUNTIME_FUNCTION(Runtime_DateField) { |
| 175 SealHandleScope shs(isolate); | 176 SealHandleScope shs(isolate); |
| 176 DCHECK(args.length() == 2); | 177 DCHECK(args.length() == 2); |
| 177 CONVERT_ARG_CHECKED(Object, obj, 0); | 178 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 178 CONVERT_SMI_ARG_CHECKED(index, 1); | 179 CONVERT_SMI_ARG_CHECKED(index, 1); |
| 179 if (!obj->IsJSDate()) { | 180 if (!obj->IsJSDate()) { |
| 180 HandleScope scope(isolate); | 181 HandleScope scope(isolate); |
| 181 THROW_NEW_ERROR_RETURN_FAILURE( | 182 THROW_NEW_ERROR_RETURN_FAILURE( |
| 182 isolate, | 183 isolate, NewTypeError(MessageTemplate::kNotDateObject)); |
| 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 |