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

Unified Diff: runtime/lib/errors.cc

Issue 2564623003: Add optional message argument to assert statements in the VM. (Closed)
Patch Set: Created 4 years 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 | « no previous file | runtime/lib/errors_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/errors.cc
diff --git a/runtime/lib/errors.cc b/runtime/lib/errors.cc
index 27770a92f191954251a8ccf301773ab026f63282..9eb89177708548289daeeb50b15cd4f219f908ca 100644
--- a/runtime/lib/errors.cc
+++ b/runtime/lib/errors.cc
@@ -62,8 +62,9 @@ static RawScript* FindScript(DartFrameIterator* iterator) {
// Allocate and throw a new AssertionError.
// Arg0: index of the first token of the failed assertion.
// Arg1: index of the first token after the failed assertion.
+// Arg2: Message object or null.
// Return value: none, throws an exception.
-DEFINE_NATIVE_ENTRY(AssertionError_throwNew, 2) {
+DEFINE_NATIVE_ENTRY(AssertionError_throwNew, 3) {
// No need to type check the arguments. This function can only be called
// internally from the VM.
const TokenPosition assertion_start =
@@ -71,7 +72,8 @@ DEFINE_NATIVE_ENTRY(AssertionError_throwNew, 2) {
const TokenPosition assertion_end =
TokenPosition(Smi::CheckedHandle(arguments->NativeArgAt(1)).Value());
- const Array& args = Array::Handle(Array::New(4));
+ const Instance& message = Instance::CheckedHandle(arguments->NativeArgAt(2));
+ const Array& args = Array::Handle(Array::New(5));
DartFrameIterator iterator;
iterator.NextFrame(); // Skip native call.
@@ -92,6 +94,7 @@ DEFINE_NATIVE_ENTRY(AssertionError_throwNew, 2) {
args.SetAt(1, String::Handle(script.url()));
args.SetAt(2, Smi::Handle(Smi::New(from_line)));
args.SetAt(3, Smi::Handle(Smi::New(script.HasSource() ? from_column : -1)));
+ args.SetAt(4, message);
Exceptions::ThrowByType(Exceptions::kAssertion, args);
UNREACHABLE();
« no previous file with comments | « no previous file | runtime/lib/errors_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698