| 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 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 virtual bool Emit(RegExpCompiler* compiler, Trace* trace); | 973 virtual bool Emit(RegExpCompiler* compiler, Trace* trace); |
| 974 virtual int EatsAtLeast(int recursion_depth); | 974 virtual int EatsAtLeast(int recursion_depth); |
| 975 int EatsAtLeastHelper(int recursion_depth, RegExpNode* ignore_this_node); | 975 int EatsAtLeastHelper(int recursion_depth, RegExpNode* ignore_this_node); |
| 976 virtual void GetQuickCheckDetails(QuickCheckDetails* details, | 976 virtual void GetQuickCheckDetails(QuickCheckDetails* details, |
| 977 RegExpCompiler* compiler, | 977 RegExpCompiler* compiler, |
| 978 int characters_filled_in); | 978 int characters_filled_in); |
| 979 virtual ChoiceNode* Clone() { return new ChoiceNode(*this); } | 979 virtual ChoiceNode* Clone() { return new ChoiceNode(*this); } |
| 980 | 980 |
| 981 bool being_calculated() { return being_calculated_; } | 981 bool being_calculated() { return being_calculated_; } |
| 982 void set_being_calculated(bool b) { being_calculated_ = b; } | 982 void set_being_calculated(bool b) { being_calculated_ = b; } |
| 983 virtual bool try_to_emit_quick_check_for_alternative(int i) { return true; } |
| 983 | 984 |
| 984 protected: | 985 protected: |
| 985 int GreedyLoopTextLength(GuardedAlternative *alternative); | 986 int GreedyLoopTextLength(GuardedAlternative *alternative); |
| 986 ZoneList<GuardedAlternative>* alternatives_; | 987 ZoneList<GuardedAlternative>* alternatives_; |
| 987 | 988 |
| 988 private: | 989 private: |
| 989 friend class DispatchTableConstructor; | 990 friend class DispatchTableConstructor; |
| 990 friend class Analysis; | 991 friend class Analysis; |
| 991 void GenerateGuard(RegExpMacroAssembler* macro_assembler, | 992 void GenerateGuard(RegExpMacroAssembler* macro_assembler, |
| 992 Guard *guard, | 993 Guard *guard, |
| 993 Trace* trace); | 994 Trace* trace); |
| 994 int CalculatePreloadCharacters(RegExpCompiler* compiler); | 995 int CalculatePreloadCharacters(RegExpCompiler* compiler); |
| 995 bool EmitOutOfLineContinuation(RegExpCompiler* compiler, | 996 bool EmitOutOfLineContinuation(RegExpCompiler* compiler, |
| 996 Trace* trace, | 997 Trace* trace, |
| 997 GuardedAlternative alternative, | 998 GuardedAlternative alternative, |
| 998 AlternativeGeneration* alt_gen, | 999 AlternativeGeneration* alt_gen, |
| 999 int preload_characters, | 1000 int preload_characters, |
| 1000 bool next_expects_preload); | 1001 bool next_expects_preload); |
| 1001 DispatchTable* table_; | 1002 DispatchTable* table_; |
| 1002 bool being_calculated_; | 1003 bool being_calculated_; |
| 1003 }; | 1004 }; |
| 1004 | 1005 |
| 1005 | 1006 |
| 1007 class NegativeLookaheadChoiceNode: public ChoiceNode { |
| 1008 public: |
| 1009 explicit NegativeLookaheadChoiceNode(GuardedAlternative this_must_fail, |
| 1010 GuardedAlternative then_do_this) |
| 1011 : ChoiceNode(2) { |
| 1012 AddAlternative(this_must_fail); |
| 1013 AddAlternative(then_do_this); |
| 1014 } |
| 1015 virtual int EatsAtLeast(int recursion_depth); |
| 1016 virtual void GetQuickCheckDetails(QuickCheckDetails* details, |
| 1017 RegExpCompiler* compiler, |
| 1018 int characters_filled_in); |
| 1019 // For a negative lookahead we don't emit the quick check for the |
| 1020 // alternative that is expected to fail. This is because quick check code |
| 1021 // starts by loading enough characters for the alternative that takes fewest |
| 1022 // characters, but on a negative lookahead the negative branch did not take |
| 1023 // part in that calculation (EatsAtLeast) so the assumptions don't hold. |
| 1024 virtual bool try_to_emit_quick_check_for_alternative(int i) { return i != 0; } |
| 1025 }; |
| 1026 |
| 1027 |
| 1006 class LoopChoiceNode: public ChoiceNode { | 1028 class LoopChoiceNode: public ChoiceNode { |
| 1007 public: | 1029 public: |
| 1008 explicit LoopChoiceNode(bool body_can_be_zero_length) | 1030 explicit LoopChoiceNode(bool body_can_be_zero_length) |
| 1009 : ChoiceNode(2), | 1031 : ChoiceNode(2), |
| 1010 loop_node_(NULL), | 1032 loop_node_(NULL), |
| 1011 continue_node_(NULL), | 1033 continue_node_(NULL), |
| 1012 body_can_be_zero_length_(body_can_be_zero_length) { } | 1034 body_can_be_zero_length_(body_can_be_zero_length) { } |
| 1013 void AddLoopAlternative(GuardedAlternative alt); | 1035 void AddLoopAlternative(GuardedAlternative alt); |
| 1014 void AddContinueAlternative(GuardedAlternative alt); | 1036 void AddContinueAlternative(GuardedAlternative alt); |
| 1015 virtual bool Emit(RegExpCompiler* compiler, Trace* trace); | 1037 virtual bool Emit(RegExpCompiler* compiler, Trace* trace); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 Handle<String> pattern, | 1303 Handle<String> pattern, |
| 1282 bool is_ascii); | 1304 bool is_ascii); |
| 1283 | 1305 |
| 1284 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); | 1306 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); |
| 1285 }; | 1307 }; |
| 1286 | 1308 |
| 1287 | 1309 |
| 1288 } } // namespace v8::internal | 1310 } } // namespace v8::internal |
| 1289 | 1311 |
| 1290 #endif // V8_JSREGEXP_H_ | 1312 #endif // V8_JSREGEXP_H_ |
| OLD | NEW |