| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 Interval self(StartRegister(index()), EndRegister(index())); | 391 Interval self(StartRegister(index()), EndRegister(index())); |
| 392 return self.Union(body()->CaptureRegisters()); | 392 return self.Union(body()->CaptureRegisters()); |
| 393 } | 393 } |
| 394 | 394 |
| 395 | 395 |
| 396 Interval RegExpQuantifier::CaptureRegisters() { | 396 Interval RegExpQuantifier::CaptureRegisters() { |
| 397 return body()->CaptureRegisters(); | 397 return body()->CaptureRegisters(); |
| 398 } | 398 } |
| 399 | 399 |
| 400 | 400 |
| 401 bool RegExpAssertion::IsAnchoredAtStart() { | 401 bool RegExpAssertion::IsAnchored() { |
| 402 return type() == RegExpAssertion::START_OF_INPUT; | 402 return type() == RegExpAssertion::START_OF_INPUT; |
| 403 } | 403 } |
| 404 | 404 |
| 405 | 405 |
| 406 bool RegExpAssertion::IsAnchoredAtEnd() { | 406 bool RegExpAlternative::IsAnchored() { |
| 407 return type() == RegExpAssertion::END_OF_INPUT; | |
| 408 } | |
| 409 | |
| 410 | |
| 411 bool RegExpAlternative::IsAnchoredAtStart() { | |
| 412 ZoneList<RegExpTree*>* nodes = this->nodes(); | 407 ZoneList<RegExpTree*>* nodes = this->nodes(); |
| 413 for (int i = 0; i < nodes->length(); i++) { | 408 for (int i = 0; i < nodes->length(); i++) { |
| 414 RegExpTree* node = nodes->at(i); | 409 RegExpTree* node = nodes->at(i); |
| 415 if (node->IsAnchoredAtStart()) { return true; } | 410 if (node->IsAnchored()) { return true; } |
| 416 if (node->max_match() > 0) { return false; } | 411 if (node->max_match() > 0) { return false; } |
| 417 } | 412 } |
| 418 return false; | 413 return false; |
| 419 } | 414 } |
| 420 | 415 |
| 421 | 416 |
| 422 bool RegExpAlternative::IsAnchoredAtEnd() { | 417 bool RegExpDisjunction::IsAnchored() { |
| 423 ZoneList<RegExpTree*>* nodes = this->nodes(); | |
| 424 for (int i = nodes->length() - 1; i >= 0; i--) { | |
| 425 RegExpTree* node = nodes->at(i); | |
| 426 if (node->IsAnchoredAtEnd()) { return true; } | |
| 427 if (node->max_match() > 0) { return false; } | |
| 428 } | |
| 429 return false; | |
| 430 } | |
| 431 | |
| 432 | |
| 433 bool RegExpDisjunction::IsAnchoredAtStart() { | |
| 434 ZoneList<RegExpTree*>* alternatives = this->alternatives(); | 418 ZoneList<RegExpTree*>* alternatives = this->alternatives(); |
| 435 for (int i = 0; i < alternatives->length(); i++) { | 419 for (int i = 0; i < alternatives->length(); i++) { |
| 436 if (!alternatives->at(i)->IsAnchoredAtStart()) | 420 if (!alternatives->at(i)->IsAnchored()) |
| 437 return false; | 421 return false; |
| 438 } | 422 } |
| 439 return true; | 423 return true; |
| 440 } | 424 } |
| 441 | 425 |
| 442 | 426 |
| 443 bool RegExpDisjunction::IsAnchoredAtEnd() { | 427 bool RegExpLookahead::IsAnchored() { |
| 444 ZoneList<RegExpTree*>* alternatives = this->alternatives(); | 428 return is_positive() && body()->IsAnchored(); |
| 445 for (int i = 0; i < alternatives->length(); i++) { | |
| 446 if (!alternatives->at(i)->IsAnchoredAtEnd()) | |
| 447 return false; | |
| 448 } | |
| 449 return true; | |
| 450 } | 429 } |
| 451 | 430 |
| 452 | 431 |
| 453 bool RegExpLookahead::IsAnchoredAtStart() { | 432 bool RegExpCapture::IsAnchored() { |
| 454 return is_positive() && body()->IsAnchoredAtStart(); | 433 return body()->IsAnchored(); |
| 455 } | 434 } |
| 456 | 435 |
| 457 | 436 |
| 458 bool RegExpCapture::IsAnchoredAtStart() { | |
| 459 return body()->IsAnchoredAtStart(); | |
| 460 } | |
| 461 | |
| 462 | |
| 463 bool RegExpCapture::IsAnchoredAtEnd() { | |
| 464 return body()->IsAnchoredAtEnd(); | |
| 465 } | |
| 466 | |
| 467 | |
| 468 // Convert regular expression trees to a simple sexp representation. | 437 // Convert regular expression trees to a simple sexp representation. |
| 469 // This representation should be different from the input grammar | 438 // This representation should be different from the input grammar |
| 470 // in as many cases as possible, to make it more difficult for incorrect | 439 // in as many cases as possible, to make it more difficult for incorrect |
| 471 // parses to look as correct ones which is likely if the input and | 440 // parses to look as correct ones which is likely if the input and |
| 472 // output formats are alike. | 441 // output formats are alike. |
| 473 class RegExpUnparser: public RegExpVisitor { | 442 class RegExpUnparser: public RegExpVisitor { |
| 474 public: | 443 public: |
| 475 RegExpUnparser(); | 444 RegExpUnparser(); |
| 476 void VisitCharacterRange(CharacterRange that); | 445 void VisitCharacterRange(CharacterRange that); |
| 477 SmartPointer<const char> ToString() { return stream_.ToCString(); } | 446 SmartPointer<const char> ToString() { return stream_.ToCString(); } |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 cond_(NULL), | 642 cond_(NULL), |
| 674 may_have_function_literal_(true) { | 643 may_have_function_literal_(true) { |
| 675 } | 644 } |
| 676 | 645 |
| 677 | 646 |
| 678 CaseClause::CaseClause(Expression* label, ZoneList<Statement*>* statements) | 647 CaseClause::CaseClause(Expression* label, ZoneList<Statement*>* statements) |
| 679 : label_(label), statements_(statements) { | 648 : label_(label), statements_(statements) { |
| 680 } | 649 } |
| 681 | 650 |
| 682 } } // namespace v8::internal | 651 } } // namespace v8::internal |
| OLD | NEW |