| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 ZoneStringList* labels_; | 314 ZoneStringList* labels_; |
| 315 Type type_; | 315 Type type_; |
| 316 Label break_target_; | 316 Label break_target_; |
| 317 int entry_id_; | 317 int entry_id_; |
| 318 int exit_id_; | 318 int exit_id_; |
| 319 }; | 319 }; |
| 320 | 320 |
| 321 | 321 |
| 322 class Block: public BreakableStatement { | 322 class Block: public BreakableStatement { |
| 323 public: | 323 public: |
| 324 inline Block(ZoneStringList* labels, int capacity, bool is_initializer_block); | 324 inline Block(Zone* zone, |
| 325 ZoneStringList* labels, |
| 326 int capacity, |
| 327 bool is_initializer_block); |
| 325 | 328 |
| 326 DECLARE_NODE_TYPE(Block) | 329 DECLARE_NODE_TYPE(Block) |
| 327 | 330 |
| 328 virtual Assignment* StatementAsSimpleAssignment() { | 331 virtual Assignment* StatementAsSimpleAssignment() { |
| 329 if (statements_.length() != 1) return NULL; | 332 if (statements_.length() != 1) return NULL; |
| 330 return statements_[0]->StatementAsSimpleAssignment(); | 333 return statements_[0]->StatementAsSimpleAssignment(); |
| 331 } | 334 } |
| 332 | 335 |
| 333 virtual CountOperation* StatementAsCountOperation() { | 336 virtual CountOperation* StatementAsCountOperation() { |
| 334 if (statements_.length() != 1) return NULL; | 337 if (statements_.length() != 1) return NULL; |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 int if_id_; | 733 int if_id_; |
| 731 int then_id_; | 734 int then_id_; |
| 732 int else_id_; | 735 int else_id_; |
| 733 }; | 736 }; |
| 734 | 737 |
| 735 | 738 |
| 736 // NOTE: TargetCollectors are represented as nodes to fit in the target | 739 // NOTE: TargetCollectors are represented as nodes to fit in the target |
| 737 // stack in the compiler; this should probably be reworked. | 740 // stack in the compiler; this should probably be reworked. |
| 738 class TargetCollector: public AstNode { | 741 class TargetCollector: public AstNode { |
| 739 public: | 742 public: |
| 740 TargetCollector(): targets_(0) { } | 743 explicit TargetCollector(Zone* zone): targets_(zone, 0) { } |
| 741 | 744 |
| 742 // Adds a jump target to the collector. The collector stores a pointer not | 745 // Adds a jump target to the collector. The collector stores a pointer not |
| 743 // a copy of the target to make binding work, so make sure not to pass in | 746 // a copy of the target to make binding work, so make sure not to pass in |
| 744 // references to something on the stack. | 747 // references to something on the stack. |
| 745 void AddTarget(Label* target); | 748 void AddTarget(Label* target); |
| 746 | 749 |
| 747 // Virtual behaviour. TargetCollectors are never part of the AST. | 750 // Virtual behaviour. TargetCollectors are never part of the AST. |
| 748 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } | 751 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } |
| 749 virtual TargetCollector* AsTargetCollector() { return this; } | 752 virtual TargetCollector* AsTargetCollector() { return this; } |
| 750 | 753 |
| (...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1860 | 1863 |
| 1861 | 1864 |
| 1862 class CharacterSet BASE_EMBEDDED { | 1865 class CharacterSet BASE_EMBEDDED { |
| 1863 public: | 1866 public: |
| 1864 explicit CharacterSet(uc16 standard_set_type) | 1867 explicit CharacterSet(uc16 standard_set_type) |
| 1865 : ranges_(NULL), | 1868 : ranges_(NULL), |
| 1866 standard_set_type_(standard_set_type) {} | 1869 standard_set_type_(standard_set_type) {} |
| 1867 explicit CharacterSet(ZoneList<CharacterRange>* ranges) | 1870 explicit CharacterSet(ZoneList<CharacterRange>* ranges) |
| 1868 : ranges_(ranges), | 1871 : ranges_(ranges), |
| 1869 standard_set_type_(0) {} | 1872 standard_set_type_(0) {} |
| 1870 ZoneList<CharacterRange>* ranges(); | 1873 ZoneList<CharacterRange>* ranges(Zone* zone); |
| 1871 uc16 standard_set_type() { return standard_set_type_; } | 1874 uc16 standard_set_type() { return standard_set_type_; } |
| 1872 void set_standard_set_type(uc16 special_set_type) { | 1875 void set_standard_set_type(uc16 special_set_type) { |
| 1873 standard_set_type_ = special_set_type; | 1876 standard_set_type_ = special_set_type; |
| 1874 } | 1877 } |
| 1875 bool is_standard() { return standard_set_type_ != 0; } | 1878 bool is_standard() { return standard_set_type_ != 0; } |
| 1876 void Canonicalize(); | 1879 void Canonicalize(); |
| 1877 private: | 1880 private: |
| 1878 ZoneList<CharacterRange>* ranges_; | 1881 ZoneList<CharacterRange>* ranges_; |
| 1879 // If non-zero, the value represents a standard set (e.g., all whitespace | 1882 // If non-zero, the value represents a standard set (e.g., all whitespace |
| 1880 // characters) without having to expand the ranges. | 1883 // characters) without having to expand the ranges. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1895 RegExpNode* on_success); | 1898 RegExpNode* on_success); |
| 1896 virtual RegExpCharacterClass* AsCharacterClass(); | 1899 virtual RegExpCharacterClass* AsCharacterClass(); |
| 1897 virtual bool IsCharacterClass(); | 1900 virtual bool IsCharacterClass(); |
| 1898 virtual bool IsTextElement() { return true; } | 1901 virtual bool IsTextElement() { return true; } |
| 1899 virtual int min_match() { return 1; } | 1902 virtual int min_match() { return 1; } |
| 1900 virtual int max_match() { return 1; } | 1903 virtual int max_match() { return 1; } |
| 1901 virtual void AppendToText(RegExpText* text); | 1904 virtual void AppendToText(RegExpText* text); |
| 1902 CharacterSet character_set() { return set_; } | 1905 CharacterSet character_set() { return set_; } |
| 1903 // TODO(lrn): Remove need for complex version if is_standard that | 1906 // TODO(lrn): Remove need for complex version if is_standard that |
| 1904 // recognizes a mangled standard set and just do { return set_.is_special(); } | 1907 // recognizes a mangled standard set and just do { return set_.is_special(); } |
| 1905 bool is_standard(); | 1908 bool is_standard(Zone* zone); |
| 1906 // Returns a value representing the standard character set if is_standard() | 1909 // Returns a value representing the standard character set if is_standard() |
| 1907 // returns true. | 1910 // returns true. |
| 1908 // Currently used values are: | 1911 // Currently used values are: |
| 1909 // s : unicode whitespace | 1912 // s : unicode whitespace |
| 1910 // S : unicode non-whitespace | 1913 // S : unicode non-whitespace |
| 1911 // w : ASCII word character (digit, letter, underscore) | 1914 // w : ASCII word character (digit, letter, underscore) |
| 1912 // W : non-ASCII word character | 1915 // W : non-ASCII word character |
| 1913 // d : ASCII digit | 1916 // d : ASCII digit |
| 1914 // D : non-ASCII digit | 1917 // D : non-ASCII digit |
| 1915 // . : non-unicode non-newline | 1918 // . : non-unicode non-newline |
| 1916 // * : All characters | 1919 // * : All characters |
| 1917 uc16 standard_type() { return set_.standard_set_type(); } | 1920 uc16 standard_type() { return set_.standard_set_type(); } |
| 1918 ZoneList<CharacterRange>* ranges() { return set_.ranges(); } | 1921 ZoneList<CharacterRange>* ranges(Zone* zone) { return set_.ranges(zone); } |
| 1919 bool is_negated() { return is_negated_; } | 1922 bool is_negated() { return is_negated_; } |
| 1920 | 1923 |
| 1921 private: | 1924 private: |
| 1922 CharacterSet set_; | 1925 CharacterSet set_; |
| 1923 bool is_negated_; | 1926 bool is_negated_; |
| 1924 }; | 1927 }; |
| 1925 | 1928 |
| 1926 | 1929 |
| 1927 class RegExpAtom: public RegExpTree { | 1930 class RegExpAtom: public RegExpTree { |
| 1928 public: | 1931 public: |
| 1929 explicit RegExpAtom(Vector<const uc16> data) : data_(data) { } | 1932 explicit RegExpAtom(Vector<const uc16> data) : data_(data) { } |
| 1930 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1933 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1931 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1934 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1932 RegExpNode* on_success); | 1935 RegExpNode* on_success); |
| 1933 virtual RegExpAtom* AsAtom(); | 1936 virtual RegExpAtom* AsAtom(); |
| 1934 virtual bool IsAtom(); | 1937 virtual bool IsAtom(); |
| 1935 virtual bool IsTextElement() { return true; } | 1938 virtual bool IsTextElement() { return true; } |
| 1936 virtual int min_match() { return data_.length(); } | 1939 virtual int min_match() { return data_.length(); } |
| 1937 virtual int max_match() { return data_.length(); } | 1940 virtual int max_match() { return data_.length(); } |
| 1938 virtual void AppendToText(RegExpText* text); | 1941 virtual void AppendToText(RegExpText* text); |
| 1939 Vector<const uc16> data() { return data_; } | 1942 Vector<const uc16> data() { return data_; } |
| 1940 int length() { return data_.length(); } | 1943 int length() { return data_.length(); } |
| 1941 private: | 1944 private: |
| 1942 Vector<const uc16> data_; | 1945 Vector<const uc16> data_; |
| 1943 }; | 1946 }; |
| 1944 | 1947 |
| 1945 | 1948 |
| 1946 class RegExpText: public RegExpTree { | 1949 class RegExpText: public RegExpTree { |
| 1947 public: | 1950 public: |
| 1948 RegExpText() : elements_(2), length_(0) {} | 1951 explicit RegExpText(Zone* zone) : elements_(zone, 2), length_(0) {} |
| 1949 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1952 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1950 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1953 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1951 RegExpNode* on_success); | 1954 RegExpNode* on_success); |
| 1952 virtual RegExpText* AsText(); | 1955 virtual RegExpText* AsText(); |
| 1953 virtual bool IsText(); | 1956 virtual bool IsText(); |
| 1954 virtual bool IsTextElement() { return true; } | 1957 virtual bool IsTextElement() { return true; } |
| 1955 virtual int min_match() { return length_; } | 1958 virtual int min_match() { return length_; } |
| 1956 virtual int max_match() { return length_; } | 1959 virtual int max_match() { return length_; } |
| 1957 virtual void AppendToText(RegExpText* text); | 1960 virtual void AppendToText(RegExpText* text); |
| 1958 void AddElement(TextElement elm) { | 1961 void AddElement(TextElement elm) { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2150 | 2153 |
| 2151 private: | 2154 private: |
| 2152 Isolate* isolate_; | 2155 Isolate* isolate_; |
| 2153 bool stack_overflow_; | 2156 bool stack_overflow_; |
| 2154 }; | 2157 }; |
| 2155 | 2158 |
| 2156 | 2159 |
| 2157 } } // namespace v8::internal | 2160 } } // namespace v8::internal |
| 2158 | 2161 |
| 2159 #endif // V8_AST_H_ | 2162 #endif // V8_AST_H_ |
| OLD | NEW |