Make Object::IsFoo const.

Removed a few useless const_casts on the way.

R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/351573002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21961 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3563b709
...@@ -6214,7 +6214,7 @@ Local<String> String::Empty(Isolate* isolate) { ...@@ -6214,7 +6214,7 @@ Local<String> String::Empty(Isolate* isolate) {
String::ExternalStringResource* String::GetExternalStringResource() const { String::ExternalStringResource* String::GetExternalStringResource() const {
typedef internal::Object O; typedef internal::Object O;
typedef internal::Internals I; typedef internal::Internals I;
O* obj = *reinterpret_cast<O**>(const_cast<String*>(this)); O* obj = *reinterpret_cast<O* const*>(this);
String::ExternalStringResource* result; String::ExternalStringResource* result;
if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) { if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
...@@ -6233,7 +6233,7 @@ String::ExternalStringResourceBase* String::GetExternalStringResourceBase( ...@@ -6233,7 +6233,7 @@ String::ExternalStringResourceBase* String::GetExternalStringResourceBase(
String::Encoding* encoding_out) const { String::Encoding* encoding_out) const {
typedef internal::Object O; typedef internal::Object O;
typedef internal::Internals I; typedef internal::Internals I;
O* obj = *reinterpret_cast<O**>(const_cast<String*>(this)); O* obj = *reinterpret_cast<O* const*>(this);
int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask; int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
*encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask); *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
ExternalStringResourceBase* resource = NULL; ExternalStringResourceBase* resource = NULL;
...@@ -6260,7 +6260,7 @@ bool Value::IsUndefined() const { ...@@ -6260,7 +6260,7 @@ bool Value::IsUndefined() const {
bool Value::QuickIsUndefined() const { bool Value::QuickIsUndefined() const {
typedef internal::Object O; typedef internal::Object O;
typedef internal::Internals I; typedef internal::Internals I;
O* obj = *reinterpret_cast<O**>(const_cast<Value*>(this)); O* obj = *reinterpret_cast<O* const*>(this);
if (!I::HasHeapObjectTag(obj)) return false; if (!I::HasHeapObjectTag(obj)) return false;
if (I::GetInstanceType(obj) != I::kOddballType) return false; if (I::GetInstanceType(obj) != I::kOddballType) return false;
return (I::GetOddballKind(obj) == I::kUndefinedOddballKind); return (I::GetOddballKind(obj) == I::kUndefinedOddballKind);
...@@ -6278,7 +6278,7 @@ bool Value::IsNull() const { ...@@ -6278,7 +6278,7 @@ bool Value::IsNull() const {
bool Value::QuickIsNull() const { bool Value::QuickIsNull() const {
typedef internal::Object O; typedef internal::Object O;
typedef internal::Internals I; typedef internal::Internals I;
O* obj = *reinterpret_cast<O**>(const_cast<Value*>(this)); O* obj = *reinterpret_cast<O* const*>(this);
if (!I::HasHeapObjectTag(obj)) return false; if (!I::HasHeapObjectTag(obj)) return false;
if (I::GetInstanceType(obj) != I::kOddballType) return false; if (I::GetInstanceType(obj) != I::kOddballType) return false;
return (I::GetOddballKind(obj) == I::kNullOddballKind); return (I::GetOddballKind(obj) == I::kNullOddballKind);
...@@ -6296,7 +6296,7 @@ bool Value::IsString() const { ...@@ -6296,7 +6296,7 @@ bool Value::IsString() const {
bool Value::QuickIsString() const { bool Value::QuickIsString() const {
typedef internal::Object O; typedef internal::Object O;
typedef internal::Internals I; typedef internal::Internals I;
O* obj = *reinterpret_cast<O**>(const_cast<Value*>(this)); O* obj = *reinterpret_cast<O* const*>(this);
if (!I::HasHeapObjectTag(obj)) return false; if (!I::HasHeapObjectTag(obj)) return false;
return (I::GetInstanceType(obj) < I::kFirstNonstringType); return (I::GetInstanceType(obj) < I::kFirstNonstringType);
} }
......
...@@ -370,8 +370,7 @@ MAKE_TO_LOCAL(ToLocal, DeclaredAccessorDescriptor, DeclaredAccessorDescriptor) ...@@ -370,8 +370,7 @@ MAKE_TO_LOCAL(ToLocal, DeclaredAccessorDescriptor, DeclaredAccessorDescriptor)
const v8::From* that, bool allow_empty_handle) { \ const v8::From* that, bool allow_empty_handle) { \
EXTRA_CHECK(allow_empty_handle || that != NULL); \ EXTRA_CHECK(allow_empty_handle || that != NULL); \
EXTRA_CHECK(that == NULL || \ EXTRA_CHECK(that == NULL || \
(*reinterpret_cast<v8::internal::Object**>( \ (*reinterpret_cast<v8::internal::Object* const*>(that))->Is##To()); \
const_cast<v8::From*>(that)))->Is##To()); \
return v8::internal::Handle<v8::internal::To>( \ return v8::internal::Handle<v8::internal::To>( \
reinterpret_cast<v8::internal::To**>(const_cast<v8::From*>(that))); \ reinterpret_cast<v8::internal::To**>(const_cast<v8::From*>(that))); \
} }
......
This diff is collapsed.
...@@ -92,8 +92,8 @@ bool Object::BooleanValue() { ...@@ -92,8 +92,8 @@ bool Object::BooleanValue() {
} }
bool Object::IsCallable() { bool Object::IsCallable() const {
Object* fun = this; const Object* fun = this;
while (fun->IsJSFunctionProxy()) { while (fun->IsJSFunctionProxy()) {
fun = JSFunctionProxy::cast(fun)->call_trap(); fun = JSFunctionProxy::cast(fun)->call_trap();
} }
......
...@@ -1350,48 +1350,49 @@ const char* GetBailoutReason(BailoutReason reason); ...@@ -1350,48 +1350,49 @@ const char* GetBailoutReason(BailoutReason reason);
class Object { class Object {
public: public:
// Type testing. // Type testing.
bool IsObject() { return true; } bool IsObject() const { return true; }
#define IS_TYPE_FUNCTION_DECL(type_) inline bool Is##type_(); #define IS_TYPE_FUNCTION_DECL(type_) INLINE(bool Is##type_() const);
OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
#undef IS_TYPE_FUNCTION_DECL #undef IS_TYPE_FUNCTION_DECL
inline bool IsFixedArrayBase(); INLINE(bool IsFixedArrayBase() const);
inline bool IsExternal(); INLINE(bool IsExternal() const);
inline bool IsAccessorInfo(); INLINE(bool IsAccessorInfo() const);
inline bool IsStruct(); INLINE(bool IsStruct() const);
#define DECLARE_STRUCT_PREDICATE(NAME, Name, name) inline bool Is##Name(); #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \
INLINE(bool Is##Name() const);
STRUCT_LIST(DECLARE_STRUCT_PREDICATE) STRUCT_LIST(DECLARE_STRUCT_PREDICATE)
#undef DECLARE_STRUCT_PREDICATE #undef DECLARE_STRUCT_PREDICATE
INLINE(bool IsSpecObject()); INLINE(bool IsSpecObject()) const;
INLINE(bool IsSpecFunction()); INLINE(bool IsSpecFunction()) const;
INLINE(bool IsTemplateInfo()); INLINE(bool IsTemplateInfo()) const;
INLINE(bool IsNameDictionary()); INLINE(bool IsNameDictionary() const);
INLINE(bool IsSeededNumberDictionary()); INLINE(bool IsSeededNumberDictionary() const);
INLINE(bool IsUnseededNumberDictionary()); INLINE(bool IsUnseededNumberDictionary() const);
INLINE(bool IsOrderedHashSet()); INLINE(bool IsOrderedHashSet() const);
INLINE(bool IsOrderedHashMap()); INLINE(bool IsOrderedHashMap() const);
bool IsCallable(); bool IsCallable() const;
// Oddball testing. // Oddball testing.
INLINE(bool IsUndefined()); INLINE(bool IsUndefined() const);
INLINE(bool IsNull()); INLINE(bool IsNull() const);
INLINE(bool IsTheHole()); INLINE(bool IsTheHole() const);
INLINE(bool IsException()); INLINE(bool IsException() const);
INLINE(bool IsUninitialized()); INLINE(bool IsUninitialized() const);
INLINE(bool IsTrue()); INLINE(bool IsTrue() const);
INLINE(bool IsFalse()); INLINE(bool IsFalse() const);
inline bool IsArgumentsMarker(); INLINE(bool IsArgumentsMarker() const);
// Filler objects (fillers and free space objects). // Filler objects (fillers and free space objects).
inline bool IsFiller(); INLINE(bool IsFiller() const);
// Extract the number. // Extract the number.
inline double Number(); inline double Number();
inline bool IsNaN(); INLINE(bool IsNaN() const);
bool ToInt32(int32_t* value); bool ToInt32(int32_t* value);
bool ToUint32(uint32_t* value); bool ToUint32(uint32_t* value);
...@@ -1683,7 +1684,7 @@ class HeapObject: public Object { ...@@ -1683,7 +1684,7 @@ class HeapObject: public Object {
inline Heap* GetHeap() const; inline Heap* GetHeap() const;
// Convenience method to get current isolate. // Convenience method to get current isolate.
inline Isolate* GetIsolate(); inline Isolate* GetIsolate() const;
// Converts an address to a HeapObject pointer. // Converts an address to a HeapObject pointer.
static inline HeapObject* FromAddress(Address address); static inline HeapObject* FromAddress(Address address);
...@@ -1813,7 +1814,7 @@ class FlexibleBodyDescriptor { ...@@ -1813,7 +1814,7 @@ class FlexibleBodyDescriptor {
class HeapNumber: public HeapObject { class HeapNumber: public HeapObject {
public: public:
// [value]: number value. // [value]: number value.
inline double value(); inline double value() const;
inline void set_value(double value); inline void set_value(double value);
DECLARE_CAST(HeapNumber) DECLARE_CAST(HeapNumber)
...@@ -1969,7 +1970,7 @@ class JSReceiver: public HeapObject { ...@@ -1969,7 +1970,7 @@ class JSReceiver: public HeapObject {
uint32_t index); uint32_t index);
// Return the object's prototype (might be Heap::null_value()). // Return the object's prototype (might be Heap::null_value()).
inline Object* GetPrototype(); inline Object* GetPrototype() const;
// Return the constructor function (may be Heap::null_value()). // Return the constructor function (may be Heap::null_value()).
inline Object* GetConstructor(); inline Object* GetConstructor();
...@@ -4770,7 +4771,7 @@ class NormalizedMapCache: public FixedArray { ...@@ -4770,7 +4771,7 @@ class NormalizedMapCache: public FixedArray {
DECLARE_CAST(NormalizedMapCache) DECLARE_CAST(NormalizedMapCache)
static inline bool IsNormalizedMapCache(Object* obj); static inline bool IsNormalizedMapCache(const Object* obj);
DECLARE_VERIFIER(NormalizedMapCache) DECLARE_VERIFIER(NormalizedMapCache)
private: private:
...@@ -7808,7 +7809,7 @@ class JSGlobalProxy : public JSObject { ...@@ -7808,7 +7809,7 @@ class JSGlobalProxy : public JSObject {
DECLARE_CAST(JSGlobalProxy) DECLARE_CAST(JSGlobalProxy)
inline bool IsDetachedFrom(GlobalObject* global); inline bool IsDetachedFrom(GlobalObject* global) const;
// Dispatched behavior. // Dispatched behavior.
DECLARE_PRINTER(JSGlobalProxy) DECLARE_PRINTER(JSGlobalProxy)
...@@ -8804,7 +8805,7 @@ class StringHasher { ...@@ -8804,7 +8805,7 @@ class StringHasher {
// concrete performance benefit at that particular point in the code. // concrete performance benefit at that particular point in the code.
class StringShape BASE_EMBEDDED { class StringShape BASE_EMBEDDED {
public: public:
inline explicit StringShape(String* s); inline explicit StringShape(const String* s);
inline explicit StringShape(Map* s); inline explicit StringShape(Map* s);
inline explicit StringShape(InstanceType t); inline explicit StringShape(InstanceType t);
inline bool IsSequential(); inline bool IsSequential();
...@@ -9063,8 +9064,8 @@ class String: public Name { ...@@ -9063,8 +9064,8 @@ class String: public Name {
// be ASCII encoded. This might be the case even if the string is // be ASCII encoded. This might be the case even if the string is
// two-byte. Such strings may appear when the embedder prefers // two-byte. Such strings may appear when the embedder prefers
// two-byte external representations even for ASCII data. // two-byte external representations even for ASCII data.
inline bool IsOneByteRepresentation(); inline bool IsOneByteRepresentation() const;
inline bool IsTwoByteRepresentation(); inline bool IsTwoByteRepresentation() const;
// Cons and slices have an encoding flag that may not represent the actual // Cons and slices have an encoding flag that may not represent the actual
// encoding of the underlying string. This is taken into account here. // encoding of the underlying string. This is taken into account here.
...@@ -9732,7 +9733,7 @@ class Oddball: public HeapObject { ...@@ -9732,7 +9733,7 @@ class Oddball: public HeapObject {
// [to_number]: Cached to_number computed at startup. // [to_number]: Cached to_number computed at startup.
DECL_ACCESSORS(to_number, Object) DECL_ACCESSORS(to_number, Object)
inline byte kind(); inline byte kind() const;
inline void set_kind(byte kind); inline void set_kind(byte kind);
DECLARE_CAST(Oddball) DECLARE_CAST(Oddball)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment