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

Side by Side Diff: runtime/lib/regexp.cc

Issue 11417058: Revert "Remove NullPointerException." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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/lib/object.cc ('k') | runtime/lib/regexp_patch.dart » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #include "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/bootstrap_natives.h" 6 #include "vm/bootstrap_natives.h"
7 #include "vm/exceptions.h" 7 #include "vm/exceptions.h"
8 #include "vm/native_entry.h" 8 #include "vm/native_entry.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 10
11 #include "lib/regexp_jsc.h" 11 #include "lib/regexp_jsc.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 static void CheckAndThrowExceptionIfNull(const Instance& obj) {
16 if (obj.IsNull()) {
17 GrowableArray<const Object*> args;
18 Exceptions::ThrowByType(Exceptions::kNullPointer, args);
19 }
20 }
21
15 22
16 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_factory, 4) { 23 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_factory, 4) {
17 ASSERT(AbstractTypeArguments::CheckedHandle( 24 ASSERT(AbstractTypeArguments::CheckedHandle(
18 arguments->NativeArgAt(0)).IsNull()); 25 arguments->NativeArgAt(0)).IsNull());
26 const Instance& arg1 = Instance::CheckedHandle(arguments->NativeArgAt(1));
27 CheckAndThrowExceptionIfNull(arg1);
19 GET_NATIVE_ARGUMENT(String, pattern, arguments->NativeArgAt(1)); 28 GET_NATIVE_ARGUMENT(String, pattern, arguments->NativeArgAt(1));
20 GET_NATIVE_ARGUMENT(Instance, handle_multi_line, arguments->NativeArgAt(2)); 29 GET_NATIVE_ARGUMENT(Instance, handle_multi_line, arguments->NativeArgAt(2));
21 GET_NATIVE_ARGUMENT(Instance, handle_ignore_case, arguments->NativeArgAt(3)); 30 GET_NATIVE_ARGUMENT(Instance, handle_ignore_case, arguments->NativeArgAt(3));
22 bool ignore_case = handle_ignore_case.raw() == Bool::True(); 31 bool ignore_case = handle_ignore_case.raw() == Bool::True();
23 bool multi_line = handle_multi_line.raw() == Bool::True(); 32 bool multi_line = handle_multi_line.raw() == Bool::True();
24 return Jscre::Compile(pattern, multi_line, ignore_case); 33 return Jscre::Compile(pattern, multi_line, ignore_case);
25 } 34 }
26 35
27 36
28 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_getPattern, 1) { 37 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_getPattern, 1) {
(...skipping 30 matching lines...) Expand all
59 args.Add(&pattern); 68 args.Add(&pattern);
60 args.Add(&errmsg); 69 args.Add(&errmsg);
61 Exceptions::ThrowByType(Exceptions::kIllegalJSRegExp, args); 70 Exceptions::ThrowByType(Exceptions::kIllegalJSRegExp, args);
62 return Object::null(); 71 return Object::null();
63 } 72 }
64 73
65 74
66 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_ExecuteMatch, 3) { 75 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_ExecuteMatch, 3) {
67 const JSRegExp& regexp = JSRegExp::CheckedHandle(arguments->NativeArgAt(0)); 76 const JSRegExp& regexp = JSRegExp::CheckedHandle(arguments->NativeArgAt(0));
68 ASSERT(!regexp.IsNull()); 77 ASSERT(!regexp.IsNull());
78 const Instance& arg1 = Instance::CheckedHandle(arguments->NativeArgAt(1));
79 CheckAndThrowExceptionIfNull(arg1);
69 GET_NATIVE_ARGUMENT(String, str, arguments->NativeArgAt(1)); 80 GET_NATIVE_ARGUMENT(String, str, arguments->NativeArgAt(1));
70 GET_NATIVE_ARGUMENT(Smi, start_index, arguments->NativeArgAt(2)); 81 GET_NATIVE_ARGUMENT(Smi, start_index, arguments->NativeArgAt(2));
71 return Jscre::Execute(regexp, str, start_index.Value()); 82 return Jscre::Execute(regexp, str, start_index.Value());
72 } 83 }
73 84
74 } // namespace dart 85 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/object.cc ('k') | runtime/lib/regexp_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698