| 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 10 matching lines...) Expand all Loading... |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include <stdarg.h> | 28 #include <stdarg.h> |
| 29 #include "../include/v8stdint.h" | 29 #include "../include/v8stdint.h" |
| 30 #include "checks.h" | 30 #include "checks.h" |
| 31 #include "platform.h" |
| 31 #include "utils.h" | 32 #include "utils.h" |
| 32 | 33 |
| 33 namespace v8 { | 34 namespace v8 { |
| 34 namespace internal { | 35 namespace internal { |
| 35 | 36 |
| 36 | 37 |
| 37 SimpleStringBuilder::SimpleStringBuilder(int size) { | 38 SimpleStringBuilder::SimpleStringBuilder(int size) { |
| 38 buffer_ = Vector<char>::New(size); | 39 buffer_ = Vector<char>::New(size); |
| 39 position_ = 0; | 40 position_ = 0; |
| 40 } | 41 } |
| 41 | 42 |
| 42 | 43 |
| 43 void SimpleStringBuilder::AddString(const char* s) { | 44 void SimpleStringBuilder::AddString(const char* s) { |
| 44 AddSubstring(s, StrLength(s)); | 45 AddSubstring(s, StrLength(s)); |
| 45 } | 46 } |
| 46 | 47 |
| 47 | 48 |
| 48 void SimpleStringBuilder::AddSubstring(const char* s, int n) { | 49 void SimpleStringBuilder::AddSubstring(const char* s, int n) { |
| 49 ASSERT(!is_finalized() && position_ + n < buffer_.length()); | 50 ASSERT(!is_finalized() && position_ + n < buffer_.length()); |
| 50 ASSERT(static_cast<size_t>(n) <= strlen(s)); | 51 ASSERT(static_cast<size_t>(n) <= strlen(s)); |
| 51 memcpy(&buffer_[position_], s, n * kCharSize); | 52 OS::MemCopy(&buffer_[position_], s, n * kCharSize); |
| 52 position_ += n; | 53 position_ += n; |
| 53 } | 54 } |
| 54 | 55 |
| 55 | 56 |
| 56 void SimpleStringBuilder::AddPadding(char c, int count) { | 57 void SimpleStringBuilder::AddPadding(char c, int count) { |
| 57 for (int i = 0; i < count; i++) { | 58 for (int i = 0; i < count; i++) { |
| 58 AddCharacter(c); | 59 AddCharacter(c); |
| 59 } | 60 } |
| 60 } | 61 } |
| 61 | 62 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 case 9: return DivMagicNumberFor9; | 99 case 9: return DivMagicNumberFor9; |
| 99 case 11: return DivMagicNumberFor11; | 100 case 11: return DivMagicNumberFor11; |
| 100 case 25: return DivMagicNumberFor25; | 101 case 25: return DivMagicNumberFor25; |
| 101 case 125: return DivMagicNumberFor125; | 102 case 125: return DivMagicNumberFor125; |
| 102 case 625: return DivMagicNumberFor625; | 103 case 625: return DivMagicNumberFor625; |
| 103 default: return InvalidDivMagicNumber; | 104 default: return InvalidDivMagicNumber; |
| 104 } | 105 } |
| 105 } | 106 } |
| 106 | 107 |
| 107 } } // namespace v8::internal | 108 } } // namespace v8::internal |
| OLD | NEW |