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

Side by Side Diff: src/jsregexp.cc

Issue 10889: Fixed merge-related test failure (Closed)
Patch Set: Created 12 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
« no previous file with comments | « no previous file | src/runtime.cc » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 break; 177 break;
178 case 'm': 178 case 'm':
179 flags |= JSRegExp::MULTILINE; 179 flags |= JSRegExp::MULTILINE;
180 break; 180 break;
181 } 181 }
182 } 182 }
183 return JSRegExp::Flags(flags); 183 return JSRegExp::Flags(flags);
184 } 184 }
185 185
186 186
187 static inline Handle<Object> CreateRegExpException(Handle<JSRegExp> re, 187 static inline void ThrowRegExpException(Handle<JSRegExp> re,
188 Handle<String> pattern, 188 Handle<String> pattern,
189 Handle<String> error_text, 189 Handle<String> error_text,
190 const char* message) { 190 const char* message) {
191 Handle<JSArray> array = Factory::NewJSArray(2); 191 Handle<JSArray> array = Factory::NewJSArray(2);
192 SetElement(array, 0, pattern); 192 SetElement(array, 0, pattern);
193 SetElement(array, 1, error_text); 193 SetElement(array, 1, error_text);
194 Handle<Object> regexp_err = Factory::NewSyntaxError(message, array); 194 Handle<Object> regexp_err = Factory::NewSyntaxError(message, array);
195 return Handle<Object>(Top::Throw(*regexp_err)); 195 Top::Throw(*regexp_err);
196 } 196 }
197 197
198 198
199 Handle<Object> RegExpImpl::Compile(Handle<JSRegExp> re, 199 Handle<Object> RegExpImpl::Compile(Handle<JSRegExp> re,
200 Handle<String> pattern, 200 Handle<String> pattern,
201 Handle<String> flag_str) { 201 Handle<String> flag_str) {
202 JSRegExp::Flags flags = RegExpFlagsFromString(flag_str); 202 JSRegExp::Flags flags = RegExpFlagsFromString(flag_str);
203 Handle<FixedArray> cached = CompilationCache::LookupRegExp(pattern, flags); 203 Handle<FixedArray> cached = CompilationCache::LookupRegExp(pattern, flags);
204 bool in_cache = !cached.is_null(); 204 bool in_cache = !cached.is_null();
205 Handle<Object> result; 205 Handle<Object> result;
206 StringShape shape(*pattern); 206 StringShape shape(*pattern);
207 if (in_cache) { 207 if (in_cache) {
208 re->set_data(*cached); 208 re->set_data(*cached);
209 result = re; 209 result = re;
210 } else { 210 } else {
211 SafeStringInputBuffer buffer(pattern.location()); 211 SafeStringInputBuffer buffer(pattern.location());
212 RegExpParseResult parse_result; 212 RegExpParseResult parse_result;
213 if (!ParseRegExp(&buffer, &parse_result)) { 213 if (!ParseRegExp(&buffer, &parse_result)) {
214 // Throw an exception if we fail to parse the pattern. 214 // Throw an exception if we fail to parse the pattern.
215 return CreateRegExpException(re, 215 ThrowRegExpException(re,
216 pattern, 216 pattern,
217 parse_result.error, 217 parse_result.error,
218 "malformed_regexp"); 218 "malformed_regexp");
219 return Handle<Object>();
219 } 220 }
220 RegExpAtom* atom = parse_result.tree->AsAtom(); 221 RegExpAtom* atom = parse_result.tree->AsAtom();
221 if (atom != NULL && !flags.is_ignore_case()) { 222 if (atom != NULL && !flags.is_ignore_case()) {
222 if (parse_result.has_character_escapes) { 223 if (parse_result.has_character_escapes) {
223 Vector<const uc16> atom_pattern = atom->data(); 224 Vector<const uc16> atom_pattern = atom->data();
224 Handle<String> atom_string = 225 Handle<String> atom_string =
225 Factory::NewStringFromTwoByte(atom_pattern); 226 Factory::NewStringFromTwoByte(atom_pattern);
226 result = AtomCompile(re, pattern, flags, atom_string); 227 result = AtomCompile(re, pattern, flags, atom_string);
227 } else { 228 } else {
228 result = AtomCompile(re, pattern, flags, pattern); 229 result = AtomCompile(re, pattern, flags, pattern);
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1597 analysis.Analyze(node); 1598 analysis.Analyze(node);
1598 return node; 1599 return node;
1599 } 1600 }
1600 1601
1601 1602
1602 RegExpMacroAssembler::~RegExpMacroAssembler() { 1603 RegExpMacroAssembler::~RegExpMacroAssembler() {
1603 } 1604 }
1604 1605
1605 1606
1606 }} // namespace v8::internal 1607 }} // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698