| OLD | NEW |
| 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 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 uint16_t c = stream.GetNext(); | 1061 uint16_t c = stream.GetNext(); |
| 1062 | 1062 |
| 1063 if (c < 32 || c >= 127) { | 1063 if (c < 32 || c >= 127) { |
| 1064 ascii = false; | 1064 ascii = false; |
| 1065 } | 1065 } |
| 1066 } | 1066 } |
| 1067 stream.Reset(this); | 1067 stream.Reset(this); |
| 1068 if (ascii) { | 1068 if (ascii) { |
| 1069 accumulator->Add("<String[%u]: ", length()); | 1069 accumulator->Add("<String[%u]: ", length()); |
| 1070 for (int i = 0; i < len; i++) { | 1070 for (int i = 0; i < len; i++) { |
| 1071 accumulator->Put(stream.GetNext()); | 1071 accumulator->Put(static_cast<char>(stream.GetNext())); |
| 1072 } | 1072 } |
| 1073 accumulator->Put('>'); | 1073 accumulator->Put('>'); |
| 1074 } else { | 1074 } else { |
| 1075 // Backslash indicates that the string contains control | 1075 // Backslash indicates that the string contains control |
| 1076 // characters and that backslashes are therefore escaped. | 1076 // characters and that backslashes are therefore escaped. |
| 1077 accumulator->Add("<String[%u]\\: ", length()); | 1077 accumulator->Add("<String[%u]\\: ", length()); |
| 1078 for (int i = 0; i < len; i++) { | 1078 for (int i = 0; i < len; i++) { |
| 1079 uint16_t c = stream.GetNext(); | 1079 uint16_t c = stream.GetNext(); |
| 1080 if (c == '\n') { | 1080 if (c == '\n') { |
| 1081 accumulator->Add("\\n"); | 1081 accumulator->Add("\\n"); |
| 1082 } else if (c == '\r') { | 1082 } else if (c == '\r') { |
| 1083 accumulator->Add("\\r"); | 1083 accumulator->Add("\\r"); |
| 1084 } else if (c == '\\') { | 1084 } else if (c == '\\') { |
| 1085 accumulator->Add("\\\\"); | 1085 accumulator->Add("\\\\"); |
| 1086 } else if (c < 32 || c > 126) { | 1086 } else if (c < 32 || c > 126) { |
| 1087 accumulator->Add("\\x%02x", c); | 1087 accumulator->Add("\\x%02x", c); |
| 1088 } else { | 1088 } else { |
| 1089 accumulator->Put(c); | 1089 accumulator->Put(static_cast<char>(c)); |
| 1090 } | 1090 } |
| 1091 } | 1091 } |
| 1092 if (truncated) { | 1092 if (truncated) { |
| 1093 accumulator->Put('.'); | 1093 accumulator->Put('.'); |
| 1094 accumulator->Put('.'); | 1094 accumulator->Put('.'); |
| 1095 accumulator->Put('.'); | 1095 accumulator->Put('.'); |
| 1096 } | 1096 } |
| 1097 accumulator->Put('>'); | 1097 accumulator->Put('>'); |
| 1098 } | 1098 } |
| 1099 return; | 1099 return; |
| (...skipping 6426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7526 static inline bool compare(const uint8_t* a, const uint8_t* b, int len) { | 7526 static inline bool compare(const uint8_t* a, const uint8_t* b, int len) { |
| 7527 return CompareRawStringContents(a, b, len); | 7527 return CompareRawStringContents(a, b, len); |
| 7528 } | 7528 } |
| 7529 }; | 7529 }; |
| 7530 | 7530 |
| 7531 | 7531 |
| 7532 class StringComparator { | 7532 class StringComparator { |
| 7533 class State { | 7533 class State { |
| 7534 public: | 7534 public: |
| 7535 explicit inline State(ConsStringIteratorOp* op) | 7535 explicit inline State(ConsStringIteratorOp* op) |
| 7536 : op_(op) {} | 7536 : op_(op), is_one_byte_(true), length_(0), buffer8_(NULL) {} |
| 7537 | 7537 |
| 7538 inline void Init(String* string, unsigned len) { | 7538 inline void Init(String* string, unsigned len) { |
| 7539 op_->Reset(); | 7539 op_->Reset(); |
| 7540 int32_t type = string->map()->instance_type(); | 7540 int32_t type = string->map()->instance_type(); |
| 7541 String::Visit(string, 0, *this, *op_, type, len); | 7541 String::Visit(string, 0, *this, *op_, type, len); |
| 7542 } | 7542 } |
| 7543 | 7543 |
| 7544 inline void VisitOneByteString(const uint8_t* chars, unsigned length) { | 7544 inline void VisitOneByteString(const uint8_t* chars, unsigned length) { |
| 7545 is_one_byte_ = true; | 7545 is_one_byte_ = true; |
| 7546 buffer8_ = chars; | 7546 buffer8_ = chars; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 7560 if (is_one_byte_) { | 7560 if (is_one_byte_) { |
| 7561 buffer8_ += consumed; | 7561 buffer8_ += consumed; |
| 7562 } else { | 7562 } else { |
| 7563 buffer16_ += consumed; | 7563 buffer16_ += consumed; |
| 7564 } | 7564 } |
| 7565 length_ -= consumed; | 7565 length_ -= consumed; |
| 7566 return; | 7566 return; |
| 7567 } | 7567 } |
| 7568 // Advance state. | 7568 // Advance state. |
| 7569 ASSERT(op_->HasMore()); | 7569 ASSERT(op_->HasMore()); |
| 7570 int32_t type; | 7570 int32_t type = 0; |
| 7571 unsigned length; | 7571 unsigned length = 0; |
| 7572 String* next = op_->ContinueOperation(&type, &length); | 7572 String* next = op_->ContinueOperation(&type, &length); |
| 7573 ASSERT(next != NULL); | 7573 ASSERT(next != NULL); |
| 7574 ConsStringNullOp null_op; | 7574 ConsStringNullOp null_op; |
| 7575 String::Visit(next, 0, *this, null_op, type, length); | 7575 String::Visit(next, 0, *this, null_op, type, length); |
| 7576 } | 7576 } |
| 7577 | 7577 |
| 7578 ConsStringIteratorOp* const op_; | 7578 ConsStringIteratorOp* const op_; |
| 7579 bool is_one_byte_; | 7579 bool is_one_byte_; |
| 7580 unsigned offset_; | |
| 7581 unsigned length_; | 7580 unsigned length_; |
| 7582 union { | 7581 union { |
| 7583 const uint8_t* buffer8_; | 7582 const uint8_t* buffer8_; |
| 7584 const uint16_t* buffer16_; | 7583 const uint16_t* buffer16_; |
| 7585 }; | 7584 }; |
| 7586 DISALLOW_IMPLICIT_CONSTRUCTORS(State); | 7585 DISALLOW_IMPLICIT_CONSTRUCTORS(State); |
| 7587 }; | 7586 }; |
| 7588 | 7587 |
| 7589 public: | 7588 public: |
| 7590 inline StringComparator(ConsStringIteratorOp* op_1, | 7589 inline StringComparator(ConsStringIteratorOp* op_1, |
| (...skipping 6552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14143 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 14142 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
| 14144 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 14143 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
| 14145 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 14144 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
| 14146 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 14145 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
| 14147 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 14146 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
| 14148 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 14147 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
| 14149 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 14148 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
| 14150 } | 14149 } |
| 14151 | 14150 |
| 14152 } } // namespace v8::internal | 14151 } } // namespace v8::internal |
| OLD | NEW |