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

Unified Diff: runtime/vm/exceptions.cc

Issue 10659005: Implement type cast in the VM. (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
Index: runtime/vm/exceptions.cc
===================================================================
--- runtime/vm/exceptions.cc (revision 9048)
+++ runtime/vm/exceptions.cc (working copy)
@@ -182,13 +182,21 @@
const String& dst_type_name,
const String& dst_name,
const String& malformed_error) {
- // Allocate a new instance of TypeError.
- const Instance& type_error = Instance::Handle(NewInstance("TypeError"));
+ // Allocate a new instance of TypeError or CastException.
+ Instance& type_error = Instance::Handle();
+ Class& cls = Class::Handle();
+ if (dst_name.Equals("type cast")) {
+ type_error = NewInstance("CastException");
+ cls = type_error.clazz();
+ cls = cls.SuperClass();
+ } else {
+ type_error = NewInstance("TypeError");
+ cls = type_error.clazz();
+ }
// Initialize 'url', 'line', and 'column' fields.
DartFrameIterator iterator;
const Script& script = Script::Handle(GetCallerScript(&iterator));
- const Class& cls = Class::Handle(type_error.clazz());
// Location fields are defined in AssertionError, the superclass of TypeError.
const Class& assertion_error_class = Class::Handle(cls.SuperClass());
SetLocationFields(type_error, assertion_error_class, script, location);

Powered by Google App Engine
This is Rietveld 408576698