| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
| 6 | 6 |
| 7 #include "vm/assert.h" | 7 #include "vm/assert.h" |
| 8 #include "vm/exceptions.h" | 8 #include "vm/exceptions.h" |
| 9 #include "vm/native_entry.h" | 9 #include "vm/native_entry.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| 11 | 11 |
| 12 #include "lib/regexp_jsc.h" | 12 #include "lib/regexp_jsc.h" |
| 13 | 13 |
| 14 namespace dart { | 14 namespace dart { |
| 15 | 15 |
| 16 static void CheckAndThrowExceptionIfNull(const Instance& obj) { | 16 static void CheckAndThrowExceptionIfNull(const Instance& obj) { |
| 17 if (obj.IsNull()) { | 17 if (obj.IsNull()) { |
| 18 GrowableArray<const Object*> args; | 18 GrowableArray<const Object*> args; |
| 19 Exceptions::ThrowByType(Exceptions::kNullPointer, args); | 19 Exceptions::ThrowByType(Exceptions::kNullPointer, args); |
| 20 } | 20 } |
| 21 } | 21 } |
| 22 | 22 |
| 23 | 23 |
| 24 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_factory, 4) { | 24 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_factory, 4) { |
| 25 ASSERT(TypeArguments::CheckedHandle(arguments->At(0)).IsNull()); | 25 ASSERT(AbstractTypeArguments::CheckedHandle(arguments->At(0)).IsNull()); |
| 26 const String& pattern = String::CheckedHandle(arguments->At(1)); | 26 const String& pattern = String::CheckedHandle(arguments->At(1)); |
| 27 CheckAndThrowExceptionIfNull(pattern); | 27 CheckAndThrowExceptionIfNull(pattern); |
| 28 const Instance& handle_multi_line = Instance::CheckedHandle(arguments->At(2)); | 28 const Instance& handle_multi_line = Instance::CheckedHandle(arguments->At(2)); |
| 29 const Instance& handle_ignore_case = | 29 const Instance& handle_ignore_case = |
| 30 Instance::CheckedHandle(arguments->At(3)); | 30 Instance::CheckedHandle(arguments->At(3)); |
| 31 bool ignore_case = handle_ignore_case.raw() == Bool::True(); | 31 bool ignore_case = handle_ignore_case.raw() == Bool::True(); |
| 32 bool multi_line = handle_multi_line.raw() == Bool::True(); | 32 bool multi_line = handle_multi_line.raw() == Bool::True(); |
| 33 const JSRegExp& new_regex = JSRegExp::Handle( | 33 const JSRegExp& new_regex = JSRegExp::Handle( |
| 34 Jscre::Compile(pattern, multi_line, ignore_case)); | 34 Jscre::Compile(pattern, multi_line, ignore_case)); |
| 35 arguments->SetReturn(new_regex); | 35 arguments->SetReturn(new_regex); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 ASSERT(!regexp.IsNull()); | 83 ASSERT(!regexp.IsNull()); |
| 84 const String& str = String::CheckedHandle(arguments->At(1)); | 84 const String& str = String::CheckedHandle(arguments->At(1)); |
| 85 CheckAndThrowExceptionIfNull(str); | 85 CheckAndThrowExceptionIfNull(str); |
| 86 const Smi& start_index = Smi::CheckedHandle(arguments->At(2)); | 86 const Smi& start_index = Smi::CheckedHandle(arguments->At(2)); |
| 87 const Array& result = | 87 const Array& result = |
| 88 Array::Handle(Jscre::Execute(regexp, str, start_index.Value())); | 88 Array::Handle(Jscre::Execute(regexp, str, start_index.Value())); |
| 89 arguments->SetReturn(result); | 89 arguments->SetReturn(result); |
| 90 } | 90 } |
| 91 | 91 |
| 92 } // namespace dart | 92 } // namespace dart |
| OLD | NEW |