| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 | 58 |
| 59 protected: | 59 protected: |
| 60 // This is null until the string is internalized. | 60 // This is null until the string is internalized. |
| 61 Handle<String> string_; | 61 Handle<String> string_; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 | 64 |
| 65 class AstRawString : public AstString { | 65 class AstRawString : public AstString { |
| 66 public: | 66 public: |
| 67 virtual int length() const OVERRIDE { | 67 int length() const OVERRIDE { |
| 68 if (is_one_byte_) | 68 if (is_one_byte_) |
| 69 return literal_bytes_.length(); | 69 return literal_bytes_.length(); |
| 70 return literal_bytes_.length() / 2; | 70 return literal_bytes_.length() / 2; |
| 71 } | 71 } |
| 72 | 72 |
| 73 virtual void Internalize(Isolate* isolate) OVERRIDE; | 73 void Internalize(Isolate* isolate) OVERRIDE; |
| 74 | 74 |
| 75 bool AsArrayIndex(uint32_t* index) const; | 75 bool AsArrayIndex(uint32_t* index) const; |
| 76 | 76 |
| 77 // The string is not null-terminated, use length() to find out the length. | 77 // The string is not null-terminated, use length() to find out the length. |
| 78 const unsigned char* raw_data() const { | 78 const unsigned char* raw_data() const { |
| 79 return literal_bytes_.start(); | 79 return literal_bytes_.start(); |
| 80 } | 80 } |
| 81 bool is_one_byte() const { return is_one_byte_; } | 81 bool is_one_byte() const { return is_one_byte_; } |
| 82 bool IsOneByteEqualTo(const char* data) const; | 82 bool IsOneByteEqualTo(const char* data) const; |
| 83 uint16_t FirstCharacter() const { | 83 uint16_t FirstCharacter() const { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 uint32_t hash_; | 117 uint32_t hash_; |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 | 120 |
| 121 class AstConsString : public AstString { | 121 class AstConsString : public AstString { |
| 122 public: | 122 public: |
| 123 AstConsString(const AstString* left, const AstString* right) | 123 AstConsString(const AstString* left, const AstString* right) |
| 124 : left_(left), | 124 : left_(left), |
| 125 right_(right) {} | 125 right_(right) {} |
| 126 | 126 |
| 127 virtual int length() const OVERRIDE { | 127 int length() const OVERRIDE { return left_->length() + right_->length(); } |
| 128 return left_->length() + right_->length(); | |
| 129 } | |
| 130 | 128 |
| 131 virtual void Internalize(Isolate* isolate) OVERRIDE; | 129 void Internalize(Isolate* isolate) OVERRIDE; |
| 132 | 130 |
| 133 private: | 131 private: |
| 134 friend class AstValueFactory; | 132 friend class AstValueFactory; |
| 135 | 133 |
| 136 const AstString* left_; | 134 const AstString* left_; |
| 137 const AstString* right_; | 135 const AstString* right_; |
| 138 }; | 136 }; |
| 139 | 137 |
| 140 | 138 |
| 141 // AstValue is either a string, a number, a string array, a boolean, or a | 139 // AstValue is either a string, a number, a string array, a boolean, or a |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 359 |
| 362 bool AstRawString::IsArguments(AstValueFactory* ast_value_factory) const { | 360 bool AstRawString::IsArguments(AstValueFactory* ast_value_factory) const { |
| 363 return ast_value_factory->arguments_string() == this; | 361 return ast_value_factory->arguments_string() == this; |
| 364 } | 362 } |
| 365 } } // namespace v8::internal | 363 } } // namespace v8::internal |
| 366 | 364 |
| 367 #undef STRING_CONSTANTS | 365 #undef STRING_CONSTANTS |
| 368 #undef OTHER_CONSTANTS | 366 #undef OTHER_CONSTANTS |
| 369 | 367 |
| 370 #endif // V8_AST_VALUE_FACTORY_H_ | 368 #endif // V8_AST_VALUE_FACTORY_H_ |
| OLD | NEW |