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

Unified Diff: lib/regexp.cc

Issue 8363034: Report NullPointerException when we try to construct a regular expression (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years, 2 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 | « no previous file | vm/ast.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/regexp.cc
===================================================================
--- lib/regexp.cc (revision 858)
+++ lib/regexp.cc (working copy)
@@ -13,9 +13,18 @@
namespace dart {
+static void CheckAndThrowExceptionIfNull(const Instance& obj) {
+ if (obj.IsNull()) {
+ GrowableArray<const Object*> args;
+ Exceptions::ThrowByType(Exceptions::kNullPointer, args);
+ }
+}
+
+
DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_factory, 4) {
ASSERT(TypeArguments::CheckedHandle(arguments->At(0)).IsNull());
const String& pattern = String::CheckedHandle(arguments->At(1));
+ CheckAndThrowExceptionIfNull(pattern);
const Instance& handle_multi_line = Instance::CheckedHandle(arguments->At(2));
const Instance& handle_ignore_case =
Instance::CheckedHandle(arguments->At(3));
@@ -29,6 +38,7 @@
DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_getPattern, 1) {
const JSRegExp& regexp = JSRegExp::CheckedHandle(arguments->At(0));
+ ASSERT(!regexp.IsNull());
const String& result = String::Handle(regexp.pattern());
arguments->SetReturn(result);
}
@@ -36,6 +46,7 @@
DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_multiLine, 1) {
const JSRegExp& regexp = JSRegExp::CheckedHandle(arguments->At(0));
+ ASSERT(!regexp.IsNull());
const Bool& result = Bool::Handle(Bool::Get(regexp.is_multi_line()));
arguments->SetReturn(result);
}
@@ -43,6 +54,7 @@
DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_ignoreCase, 1) {
const JSRegExp& regexp = JSRegExp::CheckedHandle(arguments->At(0));
+ ASSERT(!regexp.IsNull());
const Bool& result = Bool::Handle(Bool::Get(regexp.is_ignore_case()));
arguments->SetReturn(result);
}
@@ -50,6 +62,7 @@
DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_getGroupCount, 1) {
const JSRegExp& regexp = JSRegExp::CheckedHandle(arguments->At(0));
+ ASSERT(!regexp.IsNull());
if (regexp.is_initialized()) {
const Smi& result = Smi::Handle(regexp.num_bracket_expressions());
arguments->SetReturn(result);
@@ -67,7 +80,9 @@
DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_ExecuteMatch, 3) {
const JSRegExp& regexp = JSRegExp::CheckedHandle(arguments->At(0));
+ ASSERT(!regexp.IsNull());
const String& str = String::CheckedHandle(arguments->At(1));
+ CheckAndThrowExceptionIfNull(str);
const Smi& start_index = Smi::CheckedHandle(arguments->At(2));
const Array& result =
Array::Handle(Jscre::Execute(regexp, str, start_index.Value()));
« no previous file with comments | « no previous file | vm/ast.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698