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) {
String::ExternalStringResource* String::GetExternalStringResource() const {
typedef internal::Object O;
typedef internal::Internals I;
O* obj = *reinterpret_cast<O**>(const_cast<String*>(this));
O* obj = *reinterpret_cast<O* const*>(this);
String::ExternalStringResource* result;
if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
......@@ -6233,7 +6233,7 @@ String::ExternalStringResourceBase* String::GetExternalStringResourceBase(
String::Encoding* encoding_out) const {
typedef internal::Object O;
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;
*encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
ExternalStringResourceBase* resource = NULL;
......@@ -6260,7 +6260,7 @@ bool Value::IsUndefined() const {
bool Value::QuickIsUndefined() const {
typedef internal::Object O;
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::GetInstanceType(obj) != I::kOddballType) return false;
return (I::GetOddballKind(obj) == I::kUndefinedOddballKind);
......@@ -6278,7 +6278,7 @@ bool Value::IsNull() const {
bool Value::QuickIsNull() const {
typedef internal::Object O;
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::GetInstanceType(obj) != I::kOddballType) return false;
return (I::GetOddballKind(obj) == I::kNullOddballKind);
......@@ -6296,7 +6296,7 @@ bool Value::IsString() const {
bool Value::QuickIsString() const {
typedef internal::Object O;
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;
return (I::GetInstanceType(obj) < I::kFirstNonstringType);
}
......
......@@ -370,8 +370,7 @@ MAKE_TO_LOCAL(ToLocal, DeclaredAccessorDescriptor, DeclaredAccessorDescriptor)
const v8::From* that, bool allow_empty_handle) { \
EXTRA_CHECK(allow_empty_handle || that != NULL); \
EXTRA_CHECK(that == NULL || \
(*reinterpret_cast<v8::internal::Object**>( \
const_cast<v8::From*>(that)))->Is##To()); \
(*reinterpret_cast<v8::internal::Object* const*>(that))->Is##To()); \
return v8::internal::Handle<v8::internal::To>( \
reinterpret_cast<v8::internal::To**>(const_cast<v8::From*>(that))); \
}
......
This diff is collapsed.
......@@ -92,8 +92,8 @@ bool Object::BooleanValue() {
}
bool Object::IsCallable() {
Object* fun = this;
bool Object::IsCallable() const {
const Object* fun = this;
while (fun->IsJSFunctionProxy()) {
fun = JSFunctionProxy::cast(fun)->call_trap();
}
......
......@@ -1350,48 +1350,49 @@ const char* GetBailoutReason(BailoutReason reason);
class Object {
public:
// 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)
HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
#undef IS_TYPE_FUNCTION_DECL
inline bool IsFixedArrayBase();
inline bool IsExternal();
inline bool IsAccessorInfo();
INLINE(bool IsFixedArrayBase() const);
INLINE(bool IsExternal() const);
INLINE(bool IsAccessorInfo() const);
inline bool IsStruct();
#define DECLARE_STRUCT_PREDICATE(NAME, Name, name) inline bool Is##Name();
INLINE(bool IsStruct() const);
#define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \
INLINE(bool Is##Name() const);
STRUCT_LIST(DECLARE_STRUCT_PREDICATE)
#undef DECLARE_STRUCT_PREDICATE
INLINE(bool IsSpecObject());
INLINE(bool IsSpecFunction());
INLINE(bool IsTemplateInfo());
INLINE(bool IsNameDictionary());
INLINE(bool IsSeededNumberDictionary());
INLINE(bool IsUnseededNumberDictionary());
INLINE(bool IsOrderedHashSet());
INLINE(bool IsOrderedHashMap());
bool IsCallable();
INLINE(bool IsSpecObject()) const;
INLINE(bool IsSpecFunction()) const;
INLINE(bool IsTemplateInfo()) const;
INLINE(bool IsNameDictionary() const);
INLINE(bool IsSeededNumberDictionary() const);
INLINE(bool IsUnseededNumberDictionary() const);
INLINE(bool IsOrderedHashSet() const);
INLINE(bool IsOrderedHashMap() const);
bool IsCallable() const;
// Oddball testing.
INLINE(bool IsUndefined());
INLINE(bool IsNull());
INLINE(bool IsTheHole());
INLINE(bool IsException());
INLINE(bool IsUninitialized());
INLINE(bool IsTrue());
INLINE(bool IsFalse());
inline bool IsArgumentsMarker();
INLINE(bool IsUndefined() const);
INLINE(bool IsNull() const);
INLINE(bool IsTheHole() const);
INLINE(bool IsException() const);
INLINE(bool IsUninitialized() const);
INLINE(bool IsTrue() const);
INLINE(bool IsFalse() const);
INLINE(bool IsArgumentsMarker() const);
// Filler objects (fillers and free space objects).
inline bool IsFiller();
INLINE(bool IsFiller() const);
// Extract the number.
inline double Number();
inline bool IsNaN();
INLINE(bool IsNaN() const);
bool ToInt32(int32_t* value);
bool ToUint32(uint32_t* value);
......@@ -1683,7 +1684,7 @@ class HeapObject: public Object {
inline Heap* GetHeap() const;
// Convenience method to get current isolate.
inline Isolate* GetIsolate();
inline Isolate* GetIsolate() const;
// Converts an address to a HeapObject pointer.
static inline HeapObject* FromAddress(Address address);
......@@ -1813,7 +1814,7 @@ class FlexibleBodyDescriptor {
class HeapNumber: public HeapObject {
public:
// [value]: number value.
inline double value();
inline double value() const;
inline void set_value(double value);
DECLARE_CAST(HeapNumber)
......@@ -1969,7 +1970,7 @@ class JSReceiver: public HeapObject {
uint32_t index);
// 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()).
inline Object* GetConstructor();
......@@ -4770,7 +4771,7 @@ class NormalizedMapCache: public FixedArray {
DECLARE_CAST(NormalizedMapCache)
static inline bool IsNormalizedMapCache(Object* obj);
static inline bool IsNormalizedMapCache(const Object* obj);
DECLARE_VERIFIER(NormalizedMapCache)
private:
......@@ -7808,7 +7809,7 @@ class JSGlobalProxy : public JSObject {
DECLARE_CAST(JSGlobalProxy)
inline bool IsDetachedFrom(GlobalObject* global);
inline bool IsDetachedFrom(GlobalObject* global) const;
// Dispatched behavior.
DECLARE_PRINTER(JSGlobalProxy)
......@@ -8804,7 +8805,7 @@ class StringHasher {
// concrete performance benefit at that particular point in the code.
class StringShape BASE_EMBEDDED {
public:
inline explicit StringShape(String* s);
inline explicit StringShape(const String* s);
inline explicit StringShape(Map* s);
inline explicit StringShape(InstanceType t);
inline bool IsSequential();
......@@ -9063,8 +9064,8 @@ class String: public Name {
// 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 external representations even for ASCII data.
inline bool IsOneByteRepresentation();
inline bool IsTwoByteRepresentation();
inline bool IsOneByteRepresentation() const;
inline bool IsTwoByteRepresentation() const;
// Cons and slices have an encoding flag that may not represent the actual
// encoding of the underlying string. This is taken into account here.
......@@ -9732,7 +9733,7 @@ class Oddball: public HeapObject {
// [to_number]: Cached to_number computed at startup.
DECL_ACCESSORS(to_number, Object)
inline byte kind();
inline byte kind() const;
inline void set_kind(byte kind);
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