| OLD | NEW |
| 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 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1538 void set_table(DispatchTable* value) { table_ = value; } | 1538 void set_table(DispatchTable* value) { table_ = value; } |
| 1539 void set_choice_index(int value) { choice_index_ = value; } | 1539 void set_choice_index(int value) { choice_index_ = value; } |
| 1540 }; | 1540 }; |
| 1541 | 1541 |
| 1542 | 1542 |
| 1543 void Analysis::VisitEnd(EndNode* that) { | 1543 void Analysis::VisitEnd(EndNode* that) { |
| 1544 // nothing to do | 1544 // nothing to do |
| 1545 } | 1545 } |
| 1546 | 1546 |
| 1547 | 1547 |
| 1548 class AddDispatchRange { |
| 1549 public: |
| 1550 AddDispatchRange(Analysis* analysis) : analysis_(analysis) { } |
| 1551 void Call(uc32 from, DispatchTable::Entry entry); |
| 1552 private: |
| 1553 Analysis* analysis_; |
| 1554 }; |
| 1555 |
| 1556 |
| 1557 void AddDispatchRange::Call(uc32 from, DispatchTable::Entry entry) { |
| 1558 CharacterRange range(from, entry.to()); |
| 1559 analysis_->table()->AddRange(range, analysis_->choice_index()); |
| 1560 } |
| 1561 |
| 1562 |
| 1548 void Analysis::VisitChoice(ChoiceNode* node) { | 1563 void Analysis::VisitChoice(ChoiceNode* node) { |
| 1549 if (node->visited()) return; | 1564 if (node->visited()) return; |
| 1550 node->set_visited(true); | 1565 node->set_visited(true); |
| 1551 ZoneList<GuardedAlternative>* choices = node->choices(); | 1566 ZoneList<GuardedAlternative>* choices = node->choices(); |
| 1552 AnalysisBuilder data(this); | 1567 AnalysisBuilder data(this); |
| 1553 data.set_table(node->table()); | 1568 data.set_table(node->table()); |
| 1554 for (int i = 0; i < choices->length(); i++) { | 1569 for (int i = 0; i < choices->length(); i++) { |
| 1555 data.set_choice_index(i); | 1570 data.set_choice_index(i); |
| 1556 data.Analyze(choices->at(i).node()); | 1571 data.Analyze(choices->at(i).node()); |
| 1557 } | 1572 } |
| 1558 node->set_visited(false); | 1573 node->set_visited(false); |
| 1574 if (table() != NULL) { |
| 1575 data.table()->ForEach(AddDispatchRange(this)); |
| 1576 } |
| 1559 } | 1577 } |
| 1560 | 1578 |
| 1561 | 1579 |
| 1562 void Analysis::VisitBackreference(BackreferenceNode* that) { | 1580 void Analysis::VisitBackreference(BackreferenceNode* that) { |
| 1563 UNIMPLEMENTED(); | 1581 UNIMPLEMENTED(); |
| 1564 } | 1582 } |
| 1565 | 1583 |
| 1566 | 1584 |
| 1567 void Analysis::VisitCharacterClass(CharacterClassNode* that) { | 1585 void Analysis::VisitCharacterClass(CharacterClassNode* that) { |
| 1568 if (table() != NULL) { | 1586 if (table() != NULL) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1608 RegExpNode* RegExpEngine::Compile(RegExpParseResult* input) { | 1626 RegExpNode* RegExpEngine::Compile(RegExpParseResult* input) { |
| 1609 RegExpCompiler compiler(input->capture_count); | 1627 RegExpCompiler compiler(input->capture_count); |
| 1610 RegExpNode* node = compiler.Compile(input->tree, | 1628 RegExpNode* node = compiler.Compile(input->tree, |
| 1611 EndNode::GetAccept(), | 1629 EndNode::GetAccept(), |
| 1612 EndNode::GetBacktrack()); | 1630 EndNode::GetBacktrack()); |
| 1613 return node; | 1631 return node; |
| 1614 } | 1632 } |
| 1615 | 1633 |
| 1616 | 1634 |
| 1617 }} // namespace v8::internal | 1635 }} // namespace v8::internal |
| OLD | NEW |