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

Unified Diff: runtime/lib/error.cc

Issue 10916039: Throw AbstractClassInstantiationError if an abstract class is instantiated (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 | « lib/core/errors.dart ('k') | runtime/lib/error.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/error.cc
===================================================================
--- runtime/lib/error.cc (revision 11699)
+++ runtime/lib/error.cc (working copy)
@@ -105,6 +105,38 @@
}
+// Allocate and throw a new AbstractClassInstantiationError.
+// Arg0: Token position of allocation statement.
+// Arg1: class name of the abstract class that cannot be instantiated.
+// Return value: none, throws an exception.
+DEFINE_NATIVE_ENTRY(AbstractClassInstantiationError_throwNew, 2) {
+ GET_NATIVE_ARGUMENT(Smi, smi_pos, arguments->At(0));
+ GET_NATIVE_ARGUMENT(String, class_name, arguments->At(1));
+ intptr_t error_pos = smi_pos.Value();
+
+ // Allocate a new instance of type AbstractClassInstantiationError.
+ const Instance& error = Instance::Handle(Exceptions::NewInstance(
+ "AbstractClassInstantiationErrorImplementation"));
+ ASSERT(!error.IsNull());
+
+ // Initialize 'url', 'line' and 'className' fields.
+ DartFrameIterator iterator;
+ iterator.NextFrame(); // Skip native call.
+ const Script& script = Script::Handle(Exceptions::GetCallerScript(&iterator));
+ const Class& cls = Class::Handle(error.clazz());
+ Exceptions::SetField(error, cls, "url", String::Handle(script.url()));
+ intptr_t line, column;
+ script.GetTokenLocation(error_pos, &line, &column);
+ Exceptions::SetField(error, cls, "line", Smi::Handle(Smi::New(line)));
+ Exceptions::SetField(error, cls, "className", class_name);
+
+ // Throw AbstractClassInstantiationError instance.
+ Exceptions::Throw(error);
+ UNREACHABLE();
+ return Object::null();
+}
+
+
// Allocate and throw StaticResolutionException.
// Arg0: index of the static call that was not resolved at compile time.
// Return value: none, throws an exception.
« no previous file with comments | « lib/core/errors.dart ('k') | runtime/lib/error.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698