Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1973)

Unified Diff: runtime/vm/object.h

Issue 10693071: Use VM type cast and save handles. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/native_entry.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.h
===================================================================
--- runtime/vm/object.h (revision 9315)
+++ runtime/vm/object.h (working copy)
@@ -92,6 +92,9 @@
static object& CheckedZoneHandle(RawObject* raw_ptr) { \
return CheckedZoneHandle(Isolate::Current(), raw_ptr); \
} \
+ /* T::Cast cannot be applied to a null Object, because the object vtable */ \
+ /* is not setup for type T, although some methods are supposed to work */ \
+ /* with null, for example Instance::Equals(). */ \
static const object& Cast(const Object& obj) { \
ASSERT(obj.Is##object()); \
return reinterpret_cast<const object&>(obj); \
@@ -5074,12 +5077,9 @@
Token::Kind TokenStream::KindAt(intptr_t index) const {
const Object& obj = Object::Handle(TokenAt(index));
if (obj.IsSmi()) {
- return static_cast<Token::Kind>(
- Smi::Value(reinterpret_cast<RawSmi*>(obj.raw())));
+ return static_cast<Token::Kind>(Smi::Cast(obj).Value());
} else if (obj.IsLiteralToken()) {
- LiteralToken& token = LiteralToken::Handle();
- token ^= obj.raw();
- return token.kind();
+ return LiteralToken::Cast(obj).kind();
}
ASSERT(obj.IsString()); // Must be an identifier.
return Token::kIDENT;
« no previous file with comments | « runtime/vm/native_entry.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698