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

Unified Diff: runtime/vm/object.cc

Issue 8334009: Use the distinguished class, ApiFailure, to signal when a Dart_Result is (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 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/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 537)
+++ runtime/vm/object.cc (working copy)
@@ -74,6 +74,7 @@
reinterpret_cast<RawClass*>(RAW_NULL);
RawClass* Object::context_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
RawClass* Object::context_scope_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
+RawClass* Object::api_failure_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
#undef RAW_NULL
int Object::GetSingletonClassIndex(const RawClass* raw_class) {
@@ -124,6 +125,8 @@
return kContextClass;
} else if (raw_class == context_scope_class()) {
return kContextScopeClass;
+ } else if (raw_class == api_failure_class()) {
+ return kApiFailureClass;
}
return kInvalidIndex;
}
@@ -155,6 +158,7 @@
case kExceptionHandlersClass: return exception_handlers_class();
case kContextClass: return context_class();
case kContextScopeClass: return context_scope_class();
+ case kApiFailureClass: return api_failure_class();
default: break;
}
UNREACHABLE();
@@ -187,6 +191,7 @@
case kExceptionHandlersClass: return "ExceptionHandlers";
case kContextClass: return "Context";
case kContextScopeClass: return "ContextScope";
+ case kApiFailureClass: return "ApiFailure";
default: break;
}
UNREACHABLE();
@@ -317,6 +322,9 @@
cls = Class::New<ContextScope>();
context_scope_class_ = cls.raw();
+ cls = Class::New<ApiFailure>();
+ api_failure_class_ = cls.raw();
+
ASSERT(class_class() != null_);
}
@@ -4414,6 +4422,31 @@
}
+RawApiFailure* ApiFailure::New(const String& message, Heap::Space space) {
+ const Class& cls = Class::Handle(Object::api_failure_class());
+ ApiFailure& result = ApiFailure::Handle();
+ {
+ RawObject* raw = Object::Allocate(cls,
+ ApiFailure::InstanceSize(),
+ space);
+ NoGCScope no_gc;
+ result ^= raw;
+ }
+ result.set_message(message);
+ return result.raw();
+}
+
+
+void ApiFailure::set_message(const String& message) const {
+ StorePointer(&raw_ptr()->message_, message.raw());
+}
+
+
+const char* ApiFailure::ToCString() const {
+ return "ApiFailure";
+}
+
+
bool Instance::Equals(const Instance& other) const {
if (this->raw() == other.raw()) {
return true; // "===".
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698