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

Side by Side Diff: runtime/vm/object.h

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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/debugger_api_impl.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "vm/assert.h" 8 #include "vm/assert.h"
9 #include "vm/dart.h" 9 #include "vm/dart.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 kLibraryClass, 150 kLibraryClass,
151 kLibraryPrefixClass, 151 kLibraryPrefixClass,
152 kCodeClass, 152 kCodeClass,
153 kInstructionsClass, 153 kInstructionsClass,
154 kPcDescriptorsClass, 154 kPcDescriptorsClass,
155 kLocalVarDescriptorsClass, 155 kLocalVarDescriptorsClass,
156 kExceptionHandlersClass, 156 kExceptionHandlersClass,
157 kContextClass, 157 kContextClass,
158 kContextScopeClass, 158 kContextScopeClass,
159 kApiErrorClass, 159 kApiErrorClass,
160 kLanguageErrorClass,
161 kUnhandledExceptionClass,
162 kUnwindErrorClass,
160 kMaxId, 163 kMaxId,
161 kInvalidIndex = -1, 164 kInvalidIndex = -1,
162 }; 165 };
163 166
164 virtual ~Object() { } 167 virtual ~Object() { }
165 168
166 RawObject* raw() const { return raw_; } 169 RawObject* raw() const { return raw_; }
167 void operator=(RawObject* value) { SetRaw(value); } 170 void operator=(RawObject* value) { SetRaw(value); }
168 171
169 void set_tags(intptr_t value) { 172 void set_tags(intptr_t value) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 static RawClass* code_class() { return code_class_; } 286 static RawClass* code_class() { return code_class_; }
284 static RawClass* instructions_class() { return instructions_class_; } 287 static RawClass* instructions_class() { return instructions_class_; }
285 static RawClass* pc_descriptors_class() { return pc_descriptors_class_; } 288 static RawClass* pc_descriptors_class() { return pc_descriptors_class_; }
286 static RawClass* var_descriptors_class() { return var_descriptors_class_; } 289 static RawClass* var_descriptors_class() { return var_descriptors_class_; }
287 static RawClass* exception_handlers_class() { 290 static RawClass* exception_handlers_class() {
288 return exception_handlers_class_; 291 return exception_handlers_class_;
289 } 292 }
290 static RawClass* context_class() { return context_class_; } 293 static RawClass* context_class() { return context_class_; }
291 static RawClass* context_scope_class() { return context_scope_class_; } 294 static RawClass* context_scope_class() { return context_scope_class_; }
292 static RawClass* api_error_class() { return api_error_class_; } 295 static RawClass* api_error_class() { return api_error_class_; }
296 static RawClass* language_error_class() { return language_error_class_; }
297 static RawClass* unhandled_exception_class() {
298 return unhandled_exception_class_;
299 }
300 static RawClass* unwind_error_class() { return unwind_error_class_; }
293 301
294 static int GetSingletonClassIndex(const RawClass* raw_class); 302 static int GetSingletonClassIndex(const RawClass* raw_class);
295 static RawClass* GetSingletonClass(int index); 303 static RawClass* GetSingletonClass(int index);
296 static const char* GetSingletonClassName(int index); 304 static const char* GetSingletonClassName(int index);
297 305
298 static RawClass* CreateAndRegisterInterface(const char* cname, 306 static RawClass* CreateAndRegisterInterface(const char* cname,
299 const Script& script, 307 const Script& script,
300 const Library& lib); 308 const Library& lib);
301 static void RegisterClass(const Class& cls, 309 static void RegisterClass(const Class& cls,
302 const char* cname, 310 const char* cname,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 static RawClass* library_class_; // Class of the Library vm object. 395 static RawClass* library_class_; // Class of the Library vm object.
388 static RawClass* library_prefix_class_; // Class of Library prefix vm object. 396 static RawClass* library_prefix_class_; // Class of Library prefix vm object.
389 static RawClass* code_class_; // Class of the Code vm object. 397 static RawClass* code_class_; // Class of the Code vm object.
390 static RawClass* instructions_class_; // Class of the Instructions vm object. 398 static RawClass* instructions_class_; // Class of the Instructions vm object.
391 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object. 399 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object.
392 static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors. 400 static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors.
393 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers. 401 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers.
394 static RawClass* context_class_; // Class of the Context vm object. 402 static RawClass* context_class_; // Class of the Context vm object.
395 static RawClass* context_scope_class_; // Class of ContextScope vm object. 403 static RawClass* context_scope_class_; // Class of ContextScope vm object.
396 static RawClass* api_error_class_; // Class of ApiError. 404 static RawClass* api_error_class_; // Class of ApiError.
405 static RawClass* language_error_class_; // Class of LanguageError.
406 static RawClass* unhandled_exception_class_; // Class of UnhandledException.
407 static RawClass* unwind_error_class_; // Class of UnwindError.
397 408
398 friend void RawObject::Validate() const; 409 friend void RawObject::Validate() const;
399 410
400 // Disallow allocation. 411 // Disallow allocation.
401 void* operator new(size_t size); 412 void* operator new(size_t size);
402 // Disallow copy constructor. 413 // Disallow copy constructor.
403 DISALLOW_COPY_AND_ASSIGN(Object); 414 DISALLOW_COPY_AND_ASSIGN(Object);
404 }; 415 };
405 416
406 417
(...skipping 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after
2170 raw_addr += sizeof(RawContextScope) + 2181 raw_addr += sizeof(RawContextScope) +
2171 (index * sizeof(RawContextScope::VariableDesc)); 2182 (index * sizeof(RawContextScope::VariableDesc));
2172 return reinterpret_cast<RawContextScope::VariableDesc*>(raw_addr); 2183 return reinterpret_cast<RawContextScope::VariableDesc*>(raw_addr);
2173 } 2184 }
2174 2185
2175 HEAP_OBJECT_IMPLEMENTATION(ContextScope, Object); 2186 HEAP_OBJECT_IMPLEMENTATION(ContextScope, Object);
2176 friend class Class; 2187 friend class Class;
2177 }; 2188 };
2178 2189
2179 2190
2180 class UnhandledException : public Object { 2191 class Error : public Object {
2192 private:
2193 HEAP_OBJECT_IMPLEMENTATION(Error, Object);
2194 };
2195
2196
2197 class ApiError : public Error {
2198 public:
2199 RawString* message() const { return raw_ptr()->message_; }
2200 static intptr_t message_offset() {
2201 return OFFSET_OF(RawApiError, message_);
2202 }
2203
2204 static intptr_t InstanceSize() {
2205 return RoundedAllocationSize(sizeof(RawApiError));
2206 }
2207
2208 static RawApiError* New(const String& message,
2209 Heap::Space space = Heap::kNew);
2210
2211 private:
2212 void set_message(const String& message) const;
2213
2214 HEAP_OBJECT_IMPLEMENTATION(ApiError, Error);
2215 friend class Class;
2216 };
2217
2218
2219 class LanguageError : public Error {
2220 public:
2221 RawString* message() const { return raw_ptr()->message_; }
2222 static intptr_t message_offset() {
2223 return OFFSET_OF(RawLanguageError, message_);
2224 }
2225
2226 static intptr_t InstanceSize() {
2227 return RoundedAllocationSize(sizeof(RawLanguageError));
2228 }
2229
2230 static RawLanguageError* New(const String& message,
2231 Heap::Space space = Heap::kNew);
2232
2233 private:
2234 void set_message(const String& message) const;
2235
2236 HEAP_OBJECT_IMPLEMENTATION(LanguageError, Error);
2237 friend class Class;
2238 };
2239
2240
2241 class UnhandledException : public Error {
2181 public: 2242 public:
2182 RawInstance* exception() const { return raw_ptr()->exception_; } 2243 RawInstance* exception() const { return raw_ptr()->exception_; }
2183 static intptr_t exception_offset() { 2244 static intptr_t exception_offset() {
2184 return OFFSET_OF(RawUnhandledException, exception_); 2245 return OFFSET_OF(RawUnhandledException, exception_);
2185 } 2246 }
2186 2247
2187 RawInstance* stacktrace() const { return raw_ptr()->stacktrace_; } 2248 RawInstance* stacktrace() const { return raw_ptr()->stacktrace_; }
2188 static intptr_t stacktrace_offset() { 2249 static intptr_t stacktrace_offset() {
2189 return OFFSET_OF(RawUnhandledException, stacktrace_); 2250 return OFFSET_OF(RawUnhandledException, stacktrace_);
2190 } 2251 }
2191 2252
2192 static intptr_t InstanceSize() { 2253 static intptr_t InstanceSize() {
2193 return RoundedAllocationSize(sizeof(RawUnhandledException)); 2254 return RoundedAllocationSize(sizeof(RawUnhandledException));
2194 } 2255 }
2195 2256
2196 static RawUnhandledException* New(const Instance& exception, 2257 static RawUnhandledException* New(const Instance& exception,
2197 const Instance& stacktrace, 2258 const Instance& stacktrace,
2198 Heap::Space space = Heap::kNew); 2259 Heap::Space space = Heap::kNew);
2199 2260
2200 private: 2261 private:
2201 void set_exception(const Instance& exception) const; 2262 void set_exception(const Instance& exception) const;
2202 void set_stacktrace(const Instance& stacktrace) const; 2263 void set_stacktrace(const Instance& stacktrace) const;
2203 2264
2204 HEAP_OBJECT_IMPLEMENTATION(UnhandledException, Object); 2265 HEAP_OBJECT_IMPLEMENTATION(UnhandledException, Error);
2205 friend class Class; 2266 friend class Class;
2206 }; 2267 };
2207 2268
2208 2269
2209 class ApiError : public Object { 2270 class UnwindError : public Error {
2210 public: 2271 public:
2211 RawObject* data() const { return raw_ptr()->data_; } 2272 RawString* message() const { return raw_ptr()->message_; }
2212 static intptr_t data_offset() { 2273 static intptr_t message_offset() {
2213 return OFFSET_OF(RawApiError, data_); 2274 return OFFSET_OF(RawUnwindError, message_);
2214 } 2275 }
2215 2276
2216 static intptr_t InstanceSize() { 2277 static intptr_t InstanceSize() {
2217 return RoundedAllocationSize(sizeof(RawApiError)); 2278 return RoundedAllocationSize(sizeof(RawUnwindError));
2218 } 2279 }
2219 2280
2220 static RawApiError* New(const String& message, 2281 static RawUnwindError* New(const String& message,
2221 Heap::Space space = Heap::kNew); 2282 Heap::Space space = Heap::kNew);
2222
2223 static RawApiError* New(const UnhandledException& exception,
2224 Heap::Space space = Heap::kNew);
2225 2283
2226 private: 2284 private:
2227 void set_data(const Object& data) const; 2285 void set_message(const String& message) const;
2228 2286
2229 HEAP_OBJECT_IMPLEMENTATION(ApiError, Object); 2287 HEAP_OBJECT_IMPLEMENTATION(UnwindError, Error);
2230 friend class Class; 2288 friend class Class;
2231 }; 2289 };
2232 2290
2233 2291
2234 // Instance is the base class for all instance objects (aka the Object class 2292 // Instance is the base class for all instance objects (aka the Object class
2235 // in Dart source code. 2293 // in Dart source code.
2236 class Instance : public Object { 2294 class Instance : public Object {
2237 public: 2295 public:
2238 virtual bool Equals(const Instance& other) const; 2296 virtual bool Equals(const Instance& other) const;
2239 virtual RawInstance* Canonicalize() const; 2297 virtual RawInstance* Canonicalize() const;
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after
3376 } 3434 }
3377 3435
3378 3436
3379 void Context::SetAt(intptr_t index, const Instance& value) const { 3437 void Context::SetAt(intptr_t index, const Instance& value) const {
3380 StorePointer(InstanceAddr(index), value.raw()); 3438 StorePointer(InstanceAddr(index), value.raw());
3381 } 3439 }
3382 3440
3383 } // namespace dart 3441 } // namespace dart
3384 3442
3385 #endif // VM_OBJECT_H_ 3443 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/debugger_api_impl.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698