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

Side by Side Diff: src/jsregexp.h

Issue 22815033: Fix crash due RegExpAtom method called on RegExpCharacterClass object. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 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.cc ('k') | src/jsregexp.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 VISIT(BackReference) \ 419 VISIT(BackReference) \
420 VISIT(Empty) \ 420 VISIT(Empty) \
421 VISIT(Text) 421 VISIT(Text)
422 422
423 423
424 #define FORWARD_DECLARE(Name) class RegExp##Name; 424 #define FORWARD_DECLARE(Name) class RegExp##Name;
425 FOR_EACH_REG_EXP_TREE_TYPE(FORWARD_DECLARE) 425 FOR_EACH_REG_EXP_TREE_TYPE(FORWARD_DECLARE)
426 #undef FORWARD_DECLARE 426 #undef FORWARD_DECLARE
427 427
428 428
429 class TextElement { 429 class TextElement V8_FINAL BASE_EMBEDDED {
430 public: 430 public:
431 enum TextType {UNINITIALIZED, ATOM, CHAR_CLASS}; 431 enum TextType {
432 TextElement() : text_type(UNINITIALIZED) { } 432 ATOM,
433 explicit TextElement(TextType t) : text_type(t), cp_offset(-1) { } 433 CHAR_CLASS
434 };
435
434 static TextElement Atom(RegExpAtom* atom); 436 static TextElement Atom(RegExpAtom* atom);
435 static TextElement CharClass(RegExpCharacterClass* char_class); 437 static TextElement CharClass(RegExpCharacterClass* char_class);
436 int length(); 438
437 TextType text_type; 439 int cp_offset() const { return cp_offset_; }
438 union { 440 void set_cp_offset(int cp_offset) { cp_offset_ = cp_offset; }
439 RegExpAtom* u_atom; 441 int length() const;
440 RegExpCharacterClass* u_char_class; 442
441 } data; 443 TextType text_type() const { return text_type_; }
442 int cp_offset; 444
445 RegExpTree* tree() const { return tree_; }
446
447 RegExpAtom* atom() const {
448 ASSERT(text_type() == ATOM);
449 return reinterpret_cast<RegExpAtom*>(tree());
450 }
451
452 RegExpCharacterClass* char_class() const {
453 ASSERT(text_type() == CHAR_CLASS);
454 return reinterpret_cast<RegExpCharacterClass*>(tree());
455 }
456
457 private:
458 TextElement(TextType text_type, RegExpTree* tree)
459 : cp_offset_(-1), text_type_(text_type), tree_(tree) {}
460
461 int cp_offset_;
462 TextType text_type_;
463 RegExpTree* tree_;
443 }; 464 };
444 465
445 466
446 class Trace; 467 class Trace;
447 468
448 469
449 struct NodeInfo { 470 struct NodeInfo {
450 NodeInfo() 471 NodeInfo()
451 : being_analyzed(false), 472 : being_analyzed(false),
452 been_analyzed(false), 473 been_analyzed(false),
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 Handle<String> sample_subject, 1636 Handle<String> sample_subject,
1616 bool is_ascii, Zone* zone); 1637 bool is_ascii, Zone* zone);
1617 1638
1618 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); 1639 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case);
1619 }; 1640 };
1620 1641
1621 1642
1622 } } // namespace v8::internal 1643 } } // namespace v8::internal
1623 1644
1624 #endif // V8_JSREGEXP_H_ 1645 #endif // V8_JSREGEXP_H_
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/jsregexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698