OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/jsregexp-inl.h" | 8 #include "src/jsregexp-inl.h" |
9 #include "src/jsregexp.h" | 9 #include "src/jsregexp.h" |
| 10 #include "src/messages.h" |
10 #include "src/runtime/runtime-utils.h" | 11 #include "src/runtime/runtime-utils.h" |
11 #include "src/string-builder.h" | 12 #include "src/string-builder.h" |
12 #include "src/string-search.h" | 13 #include "src/string-search.h" |
13 | 14 |
14 namespace v8 { | 15 namespace v8 { |
15 namespace internal { | 16 namespace internal { |
16 | 17 |
17 class CompiledReplacement { | 18 class CompiledReplacement { |
18 public: | 19 public: |
19 explicit CompiledReplacement(Zone* zone) | 20 explicit CompiledReplacement(Zone* zone) |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 906 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
906 CONVERT_ARG_HANDLE_CHECKED(String, flags_string, 2); | 907 CONVERT_ARG_HANDLE_CHECKED(String, flags_string, 2); |
907 Factory* factory = isolate->factory(); | 908 Factory* factory = isolate->factory(); |
908 // If source is the empty string we set it to "(?:)" instead as | 909 // If source is the empty string we set it to "(?:)" instead as |
909 // suggested by ECMA-262, 5th, section 15.10.4.1. | 910 // suggested by ECMA-262, 5th, section 15.10.4.1. |
910 if (source->length() == 0) source = factory->query_colon_string(); | 911 if (source->length() == 0) source = factory->query_colon_string(); |
911 | 912 |
912 bool success = false; | 913 bool success = false; |
913 JSRegExp::Flags flags = RegExpFlagsFromString(flags_string, &success); | 914 JSRegExp::Flags flags = RegExpFlagsFromString(flags_string, &success); |
914 if (!success) { | 915 if (!success) { |
915 Handle<FixedArray> element = factory->NewFixedArray(1); | |
916 element->set(0, *flags_string); | |
917 Handle<JSArray> args = factory->NewJSArrayWithElements(element); | |
918 THROW_NEW_ERROR_RETURN_FAILURE( | 916 THROW_NEW_ERROR_RETURN_FAILURE( |
919 isolate, NewSyntaxError("invalid_regexp_flags", args)); | 917 isolate, |
| 918 NewSyntaxError(MessageTemplate::kInvalidRegExpFlags, flags_string)); |
920 } | 919 } |
921 | 920 |
922 Handle<String> escaped_source; | 921 Handle<String> escaped_source; |
923 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, escaped_source, | 922 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, escaped_source, |
924 EscapeRegExpSource(isolate, source)); | 923 EscapeRegExpSource(isolate, source)); |
925 | 924 |
926 Handle<Object> global = factory->ToBoolean(flags.is_global()); | 925 Handle<Object> global = factory->ToBoolean(flags.is_global()); |
927 Handle<Object> ignore_case = factory->ToBoolean(flags.is_ignore_case()); | 926 Handle<Object> ignore_case = factory->ToBoolean(flags.is_ignore_case()); |
928 Handle<Object> multiline = factory->ToBoolean(flags.is_multiline()); | 927 Handle<Object> multiline = factory->ToBoolean(flags.is_multiline()); |
929 Handle<Object> sticky = factory->ToBoolean(flags.is_sticky()); | 928 Handle<Object> sticky = factory->ToBoolean(flags.is_sticky()); |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 | 1180 |
1182 | 1181 |
1183 RUNTIME_FUNCTION(Runtime_IsRegExp) { | 1182 RUNTIME_FUNCTION(Runtime_IsRegExp) { |
1184 SealHandleScope shs(isolate); | 1183 SealHandleScope shs(isolate); |
1185 DCHECK(args.length() == 1); | 1184 DCHECK(args.length() == 1); |
1186 CONVERT_ARG_CHECKED(Object, obj, 0); | 1185 CONVERT_ARG_CHECKED(Object, obj, 0); |
1187 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); | 1186 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); |
1188 } | 1187 } |
1189 } | 1188 } |
1190 } // namespace v8::internal | 1189 } // namespace v8::internal |
OLD | NEW |