| OLD | NEW |
| 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 #include "vm/regexp_parser.h" | 10 #include "vm/regexp_parser.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 const String& errmsg = String::Handle( | 71 const String& errmsg = String::Handle( |
| 72 String::New("Regular expression is not initialized yet. ")); | 72 String::New("Regular expression is not initialized yet. ")); |
| 73 const String& message = String::Handle(String::Concat(errmsg, pattern)); | 73 const String& message = String::Handle(String::Concat(errmsg, pattern)); |
| 74 const Array& args = Array::Handle(Array::New(1)); | 74 const Array& args = Array::Handle(Array::New(1)); |
| 75 args.SetAt(0, message); | 75 args.SetAt(0, message); |
| 76 Exceptions::ThrowByType(Exceptions::kFormat, args); | 76 Exceptions::ThrowByType(Exceptions::kFormat, args); |
| 77 return Object::null(); | 77 return Object::null(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 | 80 |
| 81 static RawObject* ExecuteMatch(Zone* zone, |
| 82 NativeArguments* arguments, |
| 83 bool sticky) { |
| 84 const RegExp& regexp = RegExp::CheckedHandle(arguments->NativeArgAt(0)); |
| 85 ASSERT(!regexp.IsNull()); |
| 86 GET_NON_NULL_NATIVE_ARGUMENT(String, subject, arguments->NativeArgAt(1)); |
| 87 GET_NON_NULL_NATIVE_ARGUMENT(Smi, start_index, arguments->NativeArgAt(2)); |
| 88 |
| 89 if (FLAG_interpret_irregexp) { |
| 90 return BytecodeRegExpMacroAssembler::Interpret(regexp, subject, start_index, |
| 91 /*sticky=*/sticky, zone); |
| 92 } |
| 93 |
| 94 return IRRegExpMacroAssembler::Execute(regexp, subject, start_index, |
| 95 /*sticky=*/sticky, zone); |
| 96 } |
| 97 |
| 98 |
| 81 DEFINE_NATIVE_ENTRY(RegExp_ExecuteMatch, 3) { | 99 DEFINE_NATIVE_ENTRY(RegExp_ExecuteMatch, 3) { |
| 82 // This function is intrinsified. See Intrinsifier::RegExp_ExecuteMatch. | 100 // This function is intrinsified. See Intrinsifier::RegExp_ExecuteMatch. |
| 83 const RegExp& regexp = RegExp::CheckedHandle(arguments->NativeArgAt(0)); | 101 return ExecuteMatch(zone, arguments, /*sticky=*/false); |
| 84 ASSERT(!regexp.IsNull()); | |
| 85 GET_NON_NULL_NATIVE_ARGUMENT(String, subject, arguments->NativeArgAt(1)); | |
| 86 GET_NON_NULL_NATIVE_ARGUMENT(Smi, start_index, arguments->NativeArgAt(2)); | |
| 87 | |
| 88 if (FLAG_interpret_irregexp || FLAG_precompiled_runtime) { | |
| 89 return BytecodeRegExpMacroAssembler::Interpret(regexp, subject, start_index, | |
| 90 zone); | |
| 91 } | |
| 92 | |
| 93 return IRRegExpMacroAssembler::Execute(regexp, subject, start_index, zone); | |
| 94 } | 102 } |
| 95 | 103 |
| 104 |
| 105 DEFINE_NATIVE_ENTRY(RegExp_ExecuteMatchSticky, 3) { |
| 106 // This function is intrinsified. See Intrinsifier::RegExp_ExecuteMatchSticky. |
| 107 return ExecuteMatch(zone, arguments, /*sticky=*/true); |
| 108 } |
| 109 |
| 110 |
| 96 } // namespace dart | 111 } // namespace dart |
| OLD | NEW |