OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/builtins/builtins-utils.h" | 5 #include "src/builtins/builtins-utils.h" |
6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
7 | 7 |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/regexp/jsregexp.h" | 9 #include "src/regexp/jsregexp.h" |
10 #include "src/regexp/regexp-utils.h" | 10 #include "src/regexp/regexp-utils.h" |
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 Handle<Object> string_obj = args.atOrUndefined(isolate, 1); | 1151 Handle<Object> string_obj = args.atOrUndefined(isolate, 1); |
1152 | 1152 |
1153 Handle<String> string; | 1153 Handle<String> string; |
1154 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, string, | 1154 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, string, |
1155 Object::ToString(isolate, string_obj)); | 1155 Object::ToString(isolate, string_obj)); |
1156 | 1156 |
1157 Handle<Object> previous_last_index_obj; | 1157 Handle<Object> previous_last_index_obj; |
1158 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, previous_last_index_obj, | 1158 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, previous_last_index_obj, |
1159 RegExpUtils::GetLastIndex(isolate, recv)); | 1159 RegExpUtils::GetLastIndex(isolate, recv)); |
1160 | 1160 |
1161 if (!previous_last_index_obj->IsSmi() || | 1161 if (!previous_last_index_obj->SameValue(Smi::kZero)) { |
1162 Smi::cast(*previous_last_index_obj)->value() != 0) { | |
1163 RETURN_FAILURE_ON_EXCEPTION(isolate, | 1162 RETURN_FAILURE_ON_EXCEPTION(isolate, |
1164 RegExpUtils::SetLastIndex(isolate, recv, 0)); | 1163 RegExpUtils::SetLastIndex(isolate, recv, 0)); |
1165 } | 1164 } |
1166 | 1165 |
1167 Handle<Object> result; | 1166 Handle<Object> result; |
1168 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1167 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1169 isolate, result, | 1168 isolate, result, |
1170 RegExpUtils::RegExpExec(isolate, recv, string, | 1169 RegExpUtils::RegExpExec(isolate, recv, string, |
1171 isolate->factory()->undefined_value())); | 1170 isolate->factory()->undefined_value())); |
1172 | 1171 |
1173 Handle<Object> current_last_index_obj; | 1172 Handle<Object> current_last_index_obj; |
1174 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, current_last_index_obj, | 1173 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, current_last_index_obj, |
1175 RegExpUtils::GetLastIndex(isolate, recv)); | 1174 RegExpUtils::GetLastIndex(isolate, recv)); |
1176 | 1175 |
1177 Maybe<bool> is_last_index_unchanged = | 1176 const bool is_last_index_unchanged = |
1178 Object::Equals(current_last_index_obj, previous_last_index_obj); | 1177 current_last_index_obj->SameValue(*previous_last_index_obj); |
1179 if (is_last_index_unchanged.IsNothing()) return isolate->pending_exception(); | 1178 if (!is_last_index_unchanged) { |
1180 if (!is_last_index_unchanged.FromJust()) { | |
1181 if (previous_last_index_obj->IsSmi()) { | 1179 if (previous_last_index_obj->IsSmi()) { |
1182 RETURN_FAILURE_ON_EXCEPTION( | 1180 RETURN_FAILURE_ON_EXCEPTION( |
1183 isolate, | 1181 isolate, |
1184 RegExpUtils::SetLastIndex( | 1182 RegExpUtils::SetLastIndex( |
1185 isolate, recv, Smi::cast(*previous_last_index_obj)->value())); | 1183 isolate, recv, Smi::cast(*previous_last_index_obj)->value())); |
1186 } else { | 1184 } else { |
1187 RETURN_FAILURE_ON_EXCEPTION( | 1185 RETURN_FAILURE_ON_EXCEPTION( |
1188 isolate, | 1186 isolate, |
1189 Object::SetProperty(recv, isolate->factory()->lastIndex_string(), | 1187 Object::SetProperty(recv, isolate->factory()->lastIndex_string(), |
1190 previous_last_index_obj, STRICT)); | 1188 previous_last_index_obj, STRICT)); |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2010 a->Bind(&if_matched); | 2008 a->Bind(&if_matched); |
2011 { | 2009 { |
2012 Node* result = ConstructNewResultFromMatchInfo(isolate, a, context, | 2010 Node* result = ConstructNewResultFromMatchInfo(isolate, a, context, |
2013 match_indices, string); | 2011 match_indices, string); |
2014 a->Return(result); | 2012 a->Return(result); |
2015 } | 2013 } |
2016 } | 2014 } |
2017 | 2015 |
2018 } // namespace internal | 2016 } // namespace internal |
2019 } // namespace v8 | 2017 } // namespace v8 |
OLD | NEW |