Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/api.h" | 5 #include "src/api.h" |
| 6 | 6 |
| 7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
| 8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
| 9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
| 10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
| (...skipping 2657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2668 bool Value::IsBoolean() const { | 2668 bool Value::IsBoolean() const { |
| 2669 return Utils::OpenHandle(this)->IsBoolean(); | 2669 return Utils::OpenHandle(this)->IsBoolean(); |
| 2670 } | 2670 } |
| 2671 | 2671 |
| 2672 | 2672 |
| 2673 bool Value::IsExternal() const { | 2673 bool Value::IsExternal() const { |
| 2674 return Utils::OpenHandle(this)->IsExternal(); | 2674 return Utils::OpenHandle(this)->IsExternal(); |
| 2675 } | 2675 } |
| 2676 | 2676 |
| 2677 | 2677 |
| 2678 bool Value::IsInt32() const { | 2678 bool Value::IsInt32() const { return Utils::OpenHandle(this)->IsInt32(); } |
|
dcarney
2015/03/12 10:45:58
i don't think v8 cares internally about this disti
bashi
2015/03/12 12:19:19
Right. Reverted.
| |
| 2679 i::Handle<i::Object> obj = Utils::OpenHandle(this); | |
| 2680 if (obj->IsSmi()) return true; | |
| 2681 if (obj->IsNumber()) { | |
| 2682 return i::IsInt32Double(obj->Number()); | |
| 2683 } | |
| 2684 return false; | |
| 2685 } | |
| 2686 | 2679 |
| 2687 | 2680 |
| 2688 bool Value::IsUint32() const { | 2681 bool Value::IsUint32() const { return Utils::OpenHandle(this)->IsUint32(); } |
|
dcarney
2015/03/12 10:45:58
same
| |
| 2689 i::Handle<i::Object> obj = Utils::OpenHandle(this); | |
| 2690 if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0; | |
| 2691 if (obj->IsNumber()) { | |
| 2692 double value = obj->Number(); | |
| 2693 return !i::IsMinusZero(value) && | |
| 2694 value >= 0 && | |
| 2695 value <= i::kMaxUInt32 && | |
| 2696 value == i::FastUI2D(i::FastD2UI(value)); | |
| 2697 } | |
| 2698 return false; | |
| 2699 } | |
| 2700 | 2682 |
| 2701 | 2683 |
| 2702 static bool CheckConstructor(i::Isolate* isolate, | 2684 static bool CheckConstructor(i::Isolate* isolate, |
| 2703 i::Handle<i::JSObject> obj, | 2685 i::Handle<i::JSObject> obj, |
| 2704 const char* class_name) { | 2686 const char* class_name) { |
| 2705 i::Handle<i::Object> constr(obj->map()->GetConstructor(), isolate); | 2687 i::Handle<i::Object> constr(obj->map()->GetConstructor(), isolate); |
| 2706 if (!constr->IsJSFunction()) return false; | 2688 if (!constr->IsJSFunction()) return false; |
| 2707 i::Handle<i::JSFunction> func = i::Handle<i::JSFunction>::cast(constr); | 2689 i::Handle<i::JSFunction> func = i::Handle<i::JSFunction>::cast(constr); |
| 2708 return func->shared()->native() && constr.is_identical_to( | 2690 return func->shared()->native() && constr.is_identical_to( |
| 2709 i::Object::GetProperty(isolate, | 2691 i::Object::GetProperty(isolate, |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2966 | 2948 |
| 2967 | 2949 |
| 2968 void v8::Integer::CheckCast(v8::Value* that) { | 2950 void v8::Integer::CheckCast(v8::Value* that) { |
| 2969 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2951 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 2970 Utils::ApiCheck(obj->IsNumber(), | 2952 Utils::ApiCheck(obj->IsNumber(), |
| 2971 "v8::Integer::Cast()", | 2953 "v8::Integer::Cast()", |
| 2972 "Could not convert to number"); | 2954 "Could not convert to number"); |
| 2973 } | 2955 } |
| 2974 | 2956 |
| 2975 | 2957 |
| 2958 void v8::Int32::CheckCast(v8::Value* that) { | |
| 2959 i::Handle<i::Object> obj = Utils::OpenHandle(that); | |
| 2960 Utils::ApiCheck(obj->IsInt32(), "v8::Int32::Cast()", | |
|
dcarney
2015/03/12 10:45:58
just use that->IsInt32()
bashi
2015/03/12 12:19:19
Done.
| |
| 2961 "Could not convert to 32-bit signed integer"); | |
| 2962 } | |
| 2963 | |
| 2964 | |
| 2965 void v8::Uint32::CheckCast(v8::Value* that) { | |
| 2966 i::Handle<i::Object> obj = Utils::OpenHandle(that); | |
|
dcarney
2015/03/12 10:45:58
same
| |
| 2967 Utils::ApiCheck(obj->IsUint32(), "v8::Uint32::Cast()", | |
| 2968 "Could not convert to 32-bit unsigned integer"); | |
| 2969 } | |
| 2970 | |
| 2971 | |
| 2976 void v8::Array::CheckCast(Value* that) { | 2972 void v8::Array::CheckCast(Value* that) { |
| 2977 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2973 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 2978 Utils::ApiCheck(obj->IsJSArray(), | 2974 Utils::ApiCheck(obj->IsJSArray(), |
| 2979 "v8::Array::Cast()", | 2975 "v8::Array::Cast()", |
| 2980 "Could not convert to array"); | 2976 "Could not convert to array"); |
| 2981 } | 2977 } |
| 2982 | 2978 |
| 2983 | 2979 |
| 2984 void v8::Promise::CheckCast(Value* that) { | 2980 void v8::Promise::CheckCast(Value* that) { |
| 2985 Utils::ApiCheck(that->IsPromise(), | 2981 Utils::ApiCheck(that->IsPromise(), |
| (...skipping 4990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7976 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7972 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7977 Address callback_address = | 7973 Address callback_address = |
| 7978 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7974 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7979 VMState<EXTERNAL> state(isolate); | 7975 VMState<EXTERNAL> state(isolate); |
| 7980 ExternalCallbackScope call_scope(isolate, callback_address); | 7976 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7981 callback(info); | 7977 callback(info); |
| 7982 } | 7978 } |
| 7983 | 7979 |
| 7984 | 7980 |
| 7985 } } // namespace v8::internal | 7981 } } // namespace v8::internal |
| OLD | NEW |