OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 19317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19328 set_hour(nan, SKIP_WRITE_BARRIER); | 19328 set_hour(nan, SKIP_WRITE_BARRIER); |
19329 set_min(nan, SKIP_WRITE_BARRIER); | 19329 set_min(nan, SKIP_WRITE_BARRIER); |
19330 set_sec(nan, SKIP_WRITE_BARRIER); | 19330 set_sec(nan, SKIP_WRITE_BARRIER); |
19331 set_weekday(nan, SKIP_WRITE_BARRIER); | 19331 set_weekday(nan, SKIP_WRITE_BARRIER); |
19332 } else { | 19332 } else { |
19333 set_cache_stamp(Smi::FromInt(DateCache::kInvalidStamp), SKIP_WRITE_BARRIER); | 19333 set_cache_stamp(Smi::FromInt(DateCache::kInvalidStamp), SKIP_WRITE_BARRIER); |
19334 } | 19334 } |
19335 } | 19335 } |
19336 | 19336 |
19337 | 19337 |
19338 // static | |
19339 MaybeHandle<Object> JSDate::ToPrimitive(Handle<JSReceiver> receiver, | |
19340 Handle<Object> hint) { | |
19341 Isolate* const isolate = receiver->GetIsolate(); | |
19342 if (hint->IsString()) { | |
19343 Handle<String> hint_string = Handle<String>::cast(hint); | |
19344 if (hint_string->Equals(isolate->heap()->number_string())) { | |
19345 return JSReceiver::OrdinaryToPrimitive(receiver, | |
19346 OrdinaryToPrimitiveHint::kNumber); | |
19347 } | |
19348 if (hint_string->Equals(isolate->heap()->default_string()) || | |
19349 hint_string->Equals(isolate->heap()->string_string())) { | |
19350 return JSReceiver::OrdinaryToPrimitive(receiver, | |
19351 OrdinaryToPrimitiveHint::kString); | |
19352 } | |
19353 } | |
19354 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kInvalidHint, hint), | |
19355 Object); | |
19356 } | |
19357 | |
19358 | |
19359 void JSDate::SetCachedFields(int64_t local_time_ms, DateCache* date_cache) { | 19338 void JSDate::SetCachedFields(int64_t local_time_ms, DateCache* date_cache) { |
19360 int days = DateCache::DaysFromTime(local_time_ms); | 19339 int days = DateCache::DaysFromTime(local_time_ms); |
19361 int time_in_day_ms = DateCache::TimeInDay(local_time_ms, days); | 19340 int time_in_day_ms = DateCache::TimeInDay(local_time_ms, days); |
19362 int year, month, day; | 19341 int year, month, day; |
19363 date_cache->YearMonthDayFromDays(days, &year, &month, &day); | 19342 date_cache->YearMonthDayFromDays(days, &year, &month, &day); |
19364 int weekday = date_cache->Weekday(days); | 19343 int weekday = date_cache->Weekday(days); |
19365 int hour = time_in_day_ms / (60 * 60 * 1000); | 19344 int hour = time_in_day_ms / (60 * 60 * 1000); |
19366 int min = (time_in_day_ms / (60 * 1000)) % 60; | 19345 int min = (time_in_day_ms / (60 * 1000)) % 60; |
19367 int sec = (time_in_day_ms / 1000) % 60; | 19346 int sec = (time_in_day_ms / 1000) % 60; |
19368 set_cache_stamp(date_cache->stamp()); | 19347 set_cache_stamp(date_cache->stamp()); |
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20362 // depend on this. | 20341 // depend on this. |
20363 return DICTIONARY_ELEMENTS; | 20342 return DICTIONARY_ELEMENTS; |
20364 } | 20343 } |
20365 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20344 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
20366 return kind; | 20345 return kind; |
20367 } | 20346 } |
20368 } | 20347 } |
20369 | 20348 |
20370 } // namespace internal | 20349 } // namespace internal |
20371 } // namespace v8 | 20350 } // namespace v8 |
OLD | NEW |