OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2603 | 2603 |
2604 bool Value::IsExternal() const { | 2604 bool Value::IsExternal() const { |
2605 return Utils::OpenHandle(this)->IsExternal(); | 2605 return Utils::OpenHandle(this)->IsExternal(); |
2606 } | 2606 } |
2607 | 2607 |
2608 | 2608 |
2609 bool Value::IsInt32() const { | 2609 bool Value::IsInt32() const { |
2610 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2610 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2611 if (obj->IsSmi()) return true; | 2611 if (obj->IsSmi()) return true; |
2612 if (obj->IsNumber()) { | 2612 if (obj->IsNumber()) { |
2613 double value = obj->Number(); | 2613 return i::IsInt32Double(obj->Number()); |
2614 static const i::DoubleRepresentation minus_zero(-0.0); | |
2615 i::DoubleRepresentation rep(value); | |
2616 if (rep.bits == minus_zero.bits) { | |
2617 return false; | |
2618 } | |
2619 return i::FastI2D(i::FastD2I(value)) == value; | |
2620 } | 2614 } |
2621 return false; | 2615 return false; |
2622 } | 2616 } |
2623 | 2617 |
2624 | 2618 |
2625 bool Value::IsUint32() const { | 2619 bool Value::IsUint32() const { |
2626 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2620 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2627 if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0; | 2621 if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0; |
2628 if (obj->IsNumber()) { | 2622 if (obj->IsNumber()) { |
2629 double value = obj->Number(); | 2623 double value = obj->Number(); |
2630 static const i::DoubleRepresentation minus_zero(-0.0); | 2624 return !i::IsMinusZero(value) && |
2631 i::DoubleRepresentation rep(value); | 2625 value >= 0 && |
2632 if (rep.bits == minus_zero.bits) { | 2626 value <= i::kMaxUInt32 && |
2633 return false; | 2627 value == i::FastUI2D(i::FastD2UI(value)); |
2634 } | |
2635 return i::FastUI2D(i::FastD2UI(value)) == value; | |
2636 } | 2628 } |
2637 return false; | 2629 return false; |
2638 } | 2630 } |
2639 | 2631 |
2640 | 2632 |
2641 bool Value::IsDate() const { | 2633 bool Value::IsDate() const { |
2642 i::Isolate* isolate = i::Isolate::Current(); | 2634 i::Isolate* isolate = i::Isolate::Current(); |
2643 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2635 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2644 return obj->HasSpecificClassOf(isolate->heap()->Date_string()); | 2636 return obj->HasSpecificClassOf(isolate->heap()->Date_string()); |
2645 } | 2637 } |
(...skipping 5125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7771 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7763 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7772 Address callback_address = | 7764 Address callback_address = |
7773 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7765 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7774 VMState<EXTERNAL> state(isolate); | 7766 VMState<EXTERNAL> state(isolate); |
7775 ExternalCallbackScope call_scope(isolate, callback_address); | 7767 ExternalCallbackScope call_scope(isolate, callback_address); |
7776 callback(info); | 7768 callback(info); |
7777 } | 7769 } |
7778 | 7770 |
7779 | 7771 |
7780 } } // namespace v8::internal | 7772 } } // namespace v8::internal |
OLD | NEW |