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

Side by Side Diff: src/ast.cc

Issue 18842: Experimental: periodic merge of the bleeding_edge branch to the... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: Created 11 years, 10 months 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 | Annotate | Revision Log
« no previous file with comments | « src/ast.h ('k') | src/bootstrapper.h » ('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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 Interval self(StartRegister(index()), EndRegister(index())); 237 Interval self(StartRegister(index()), EndRegister(index()));
238 return self.Union(body()->CaptureRegisters()); 238 return self.Union(body()->CaptureRegisters());
239 } 239 }
240 240
241 241
242 Interval RegExpQuantifier::CaptureRegisters() { 242 Interval RegExpQuantifier::CaptureRegisters() {
243 return body()->CaptureRegisters(); 243 return body()->CaptureRegisters();
244 } 244 }
245 245
246 246
247 bool RegExpAssertion::IsAnchored() {
248 return type() == RegExpAssertion::START_OF_INPUT;
249 }
250
251
252 bool RegExpAlternative::IsAnchored() {
253 return this->nodes()->at(0)->IsAnchored();
254 }
255
256
257 bool RegExpDisjunction::IsAnchored() {
258 ZoneList<RegExpTree*>* alternatives = this->alternatives();
259 for (int i = 0; i < alternatives->length(); i++) {
260 if (!alternatives->at(i)->IsAnchored())
261 return false;
262 }
263 return true;
264 }
265
266
267 bool RegExpLookahead::IsAnchored() {
268 return is_positive() && body()->IsAnchored();
269 }
270
271
272 bool RegExpCapture::IsAnchored() {
273 return body()->IsAnchored();
274 }
275
276
247 // Convert regular expression trees to a simple sexp representation. 277 // Convert regular expression trees to a simple sexp representation.
248 // This representation should be different from the input grammar 278 // This representation should be different from the input grammar
249 // in as many cases as possible, to make it more difficult for incorrect 279 // in as many cases as possible, to make it more difficult for incorrect
250 // parses to look as correct ones which is likely if the input and 280 // parses to look as correct ones which is likely if the input and
251 // output formats are alike. 281 // output formats are alike.
252 class RegExpUnparser: public RegExpVisitor { 282 class RegExpUnparser: public RegExpVisitor {
253 public: 283 public:
254 RegExpUnparser(); 284 RegExpUnparser();
255 void VisitCharacterRange(CharacterRange that); 285 void VisitCharacterRange(CharacterRange that);
256 SmartPointer<const char> ToString() { return stream_.ToCString(); } 286 SmartPointer<const char> ToString() { return stream_.ToCString(); }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 440
411 SmartPointer<const char> RegExpTree::ToString() { 441 SmartPointer<const char> RegExpTree::ToString() {
412 RegExpUnparser unparser; 442 RegExpUnparser unparser;
413 Accept(&unparser, NULL); 443 Accept(&unparser, NULL);
414 return unparser.ToString(); 444 return unparser.ToString();
415 } 445 }
416 446
417 447
418 RegExpDisjunction::RegExpDisjunction(ZoneList<RegExpTree*>* alternatives) 448 RegExpDisjunction::RegExpDisjunction(ZoneList<RegExpTree*>* alternatives)
419 : alternatives_(alternatives) { 449 : alternatives_(alternatives) {
450 ASSERT(alternatives->length() > 1);
420 RegExpTree* first_alternative = alternatives->at(0); 451 RegExpTree* first_alternative = alternatives->at(0);
421 min_match_ = first_alternative->min_match(); 452 min_match_ = first_alternative->min_match();
422 max_match_ = first_alternative->max_match(); 453 max_match_ = first_alternative->max_match();
423 for (int i = 1; i < alternatives->length(); i++) { 454 for (int i = 1; i < alternatives->length(); i++) {
424 RegExpTree* alternative = alternatives->at(i); 455 RegExpTree* alternative = alternatives->at(i);
425 min_match_ = Min(min_match_, alternative->min_match()); 456 min_match_ = Min(min_match_, alternative->min_match());
426 max_match_ = Max(max_match_, alternative->max_match()); 457 max_match_ = Max(max_match_, alternative->max_match());
427 } 458 }
428 } 459 }
429 460
430 461
431 RegExpAlternative::RegExpAlternative(ZoneList<RegExpTree*>* nodes) 462 RegExpAlternative::RegExpAlternative(ZoneList<RegExpTree*>* nodes)
432 : nodes_(nodes) { 463 : nodes_(nodes) {
464 ASSERT(nodes->length() > 1);
433 min_match_ = 0; 465 min_match_ = 0;
434 max_match_ = 0; 466 max_match_ = 0;
435 for (int i = 0; i < nodes->length(); i++) { 467 for (int i = 0; i < nodes->length(); i++) {
436 RegExpTree* node = nodes->at(i); 468 RegExpTree* node = nodes->at(i);
437 min_match_ += node->min_match(); 469 min_match_ += node->min_match();
438 int node_max_match = node->max_match(); 470 int node_max_match = node->max_match();
439 if (kInfinity - max_match_ < node_max_match) { 471 if (kInfinity - max_match_ < node_max_match) {
440 max_match_ = kInfinity; 472 max_match_ = kInfinity;
441 } else { 473 } else {
442 max_match_ += node->max_match(); 474 max_match_ += node->max_match();
443 } 475 }
444 } 476 }
445 } 477 }
446 478
447 479
448 } } // namespace v8::internal 480 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/bootstrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698