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

Unified Diff: runtime/vm/object.cc

Issue 9166016: Introduce the Error object class in the vm. It represents all of the (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 11 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/object_store.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 3167)
+++ runtime/vm/object.cc (working copy)
@@ -76,6 +76,10 @@
RawClass* Object::context_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
RawClass* Object::context_scope_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
RawClass* Object::api_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
+RawClass* Object::language_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
+RawClass* Object::unhandled_exception_class_ =
+ reinterpret_cast<RawClass*>(RAW_NULL);
+RawClass* Object::unwind_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
#undef RAW_NULL
int Object::GetSingletonClassIndex(const RawClass* raw_class) {
@@ -130,6 +134,12 @@
return kContextScopeClass;
} else if (raw_class == api_error_class()) {
return kApiErrorClass;
+ } else if (raw_class == language_error_class()) {
+ return kLanguageErrorClass;
+ } else if (raw_class == unhandled_exception_class()) {
+ return kUnhandledExceptionClass;
+ } else if (raw_class == unwind_error_class()) {
+ return kUnwindErrorClass;
}
return kInvalidIndex;
}
@@ -163,6 +173,9 @@
case kContextClass: return context_class();
case kContextScopeClass: return context_scope_class();
case kApiErrorClass: return api_error_class();
+ case kLanguageErrorClass: return language_error_class();
+ case kUnhandledExceptionClass: return unhandled_exception_class();
+ case kUnwindErrorClass: return unwind_error_class();
default: break;
}
UNREACHABLE();
@@ -197,6 +210,9 @@
case kContextClass: return "Context";
case kContextScopeClass: return "ContextScope";
case kApiErrorClass: return "ApiError";
+ case kLanguageErrorClass: return "LanguageError";
+ case kUnhandledExceptionClass: return "UnhandledException";
+ case kUnwindErrorClass: return "UnwindError";
default: break;
}
UNREACHABLE();
@@ -343,6 +359,15 @@
cls = Class::New<ApiError>();
api_error_class_ = cls.raw();
+ cls = Class::New<LanguageError>();
+ language_error_class_ = cls.raw();
+
+ cls = Class::New<UnhandledException>();
+ unhandled_exception_class_ = cls.raw();
+
+ cls = Class::New<UnwindError>();
+ unwind_error_class_ = cls.raw();
+
ASSERT(class_class() != null_);
}
@@ -493,11 +518,6 @@
RegisterClass(cls, "ExternalFourByteString", impl_script, core_impl_lib);
pending_classes.Add(&Class::ZoneHandle(cls.raw()));
- cls = Class::New<UnhandledException>();
- object_store->set_unhandled_exception_class(cls);
- RegisterClass(cls, "UnhandledException", impl_script, core_impl_lib);
- pending_classes.Add(&Class::ZoneHandle(cls.raw()));
-
cls = Class::New<Stacktrace>();
object_store->set_stacktrace_class(cls);
RegisterClass(cls, "Stacktrace", impl_script, core_impl_lib);
@@ -680,9 +700,6 @@
cls = Class::New<Bool>();
object_store->set_bool_class(cls);
- cls = Class::New<UnhandledException>();
- object_store->set_unhandled_exception_class(cls);
-
cls = Class::New<Stacktrace>();
object_store->set_stacktrace_class(cls);
@@ -1164,9 +1181,6 @@
RawClass* Class::GetClass(ObjectKind kind) {
ObjectStore* object_store = Isolate::Current()->object_store();
switch (kind) {
- case kUnhandledException:
- ASSERT(object_store->unhandled_exception_class() != Class::null());
- return object_store->unhandled_exception_class();
case kSmi:
ASSERT(object_store->smi_class() != Class::null());
return object_store->smi_class();
@@ -5022,12 +5036,67 @@
}
+const char* Error::ToCString() const {
+ // Error is an abstract class. We should never reach here.
+ UNREACHABLE();
+ return "Error";
+}
+
+
+RawApiError* ApiError::New(const String& message, Heap::Space space) {
+ const Class& cls = Class::Handle(Object::api_error_class());
+ ApiError& result = ApiError::Handle();
+ {
+ RawObject* raw = Object::Allocate(cls,
+ ApiError::InstanceSize(),
+ space);
+ NoGCScope no_gc;
+ result ^= raw;
+ }
+ result.set_message(message);
+ return result.raw();
+}
+
+
+void ApiError::set_message(const String& message) const {
+ StorePointer(&raw_ptr()->message_, message.raw());
+}
+
+
+const char* ApiError::ToCString() const {
+ return "ApiError";
+}
+
+
+RawLanguageError* LanguageError::New(const String& message, Heap::Space space) {
+ const Class& cls = Class::Handle(Object::language_error_class());
+ LanguageError& result = LanguageError::Handle();
+ {
+ RawObject* raw = Object::Allocate(cls,
+ LanguageError::InstanceSize(),
+ space);
+ NoGCScope no_gc;
+ result ^= raw;
+ }
+ result.set_message(message);
+ return result.raw();
+}
+
+
+void LanguageError::set_message(const String& message) const {
+ StorePointer(&raw_ptr()->message_, message.raw());
+}
+
+
+const char* LanguageError::ToCString() const {
+ return "LanguageError";
+}
+
+
RawUnhandledException* UnhandledException::New(const Instance& exception,
const Instance& stacktrace,
Heap::Space space) {
- Isolate* isolate = Isolate::Current();
- const Class& cls = Class::Handle(
- isolate->object_store()->unhandled_exception_class());
+ const Class& cls = Class::Handle(Object::unhandled_exception_class());
UnhandledException& result = UnhandledException::Handle();
{
RawObject* raw = Object::Allocate(cls,
@@ -5057,47 +5126,31 @@
}
-RawApiError* ApiError::New(const String& message, Heap::Space space) {
- const Class& cls = Class::Handle(Object::api_error_class());
- ApiError& result = ApiError::Handle();
+RawUnwindError* UnwindError::New(const String& message, Heap::Space space) {
+ const Class& cls = Class::Handle(Object::unwind_error_class());
+ UnwindError& result = UnwindError::Handle();
{
RawObject* raw = Object::Allocate(cls,
- ApiError::InstanceSize(),
+ UnwindError::InstanceSize(),
space);
NoGCScope no_gc;
result ^= raw;
}
- result.set_data(message);
+ result.set_message(message);
return result.raw();
}
-RawApiError* ApiError::New(const UnhandledException& exception,
- Heap::Space space) {
- const Class& cls = Class::Handle(Object::api_error_class());
- ApiError& result = ApiError::Handle();
- {
- RawObject* raw = Object::Allocate(cls,
- ApiError::InstanceSize(),
- space);
- NoGCScope no_gc;
- result ^= raw;
- }
- result.set_data(exception);
- return result.raw();
+void UnwindError::set_message(const String& message) const {
+ StorePointer(&raw_ptr()->message_, message.raw());
}
-void ApiError::set_data(const Object& data) const {
- StorePointer(&raw_ptr()->data_, data.raw());
+const char* UnwindError::ToCString() const {
+ return "UnwindError";
}
-const char* ApiError::ToCString() const {
- return "ApiError";
-}
-
-
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/object_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698