| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 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 "experimental-scanner.h" | 28 #include "experimental-scanner.h" |
| 29 | 29 |
| 30 #include "v8.h" |
| 31 |
| 32 #include "objects.h" |
| 33 #include "objects-inl.h" |
| 34 #include "spaces-inl.h" |
| 35 #include "isolate.h" |
| 30 #include "lexer.h" | 36 #include "lexer.h" |
| 31 | 37 |
| 32 namespace v8 { | 38 namespace v8 { |
| 33 namespace internal { | 39 namespace internal { |
| 34 | 40 |
| 35 namespace { | 41 namespace { |
| 36 | 42 |
| 37 // Will go away. | 43 // Will go away. |
| 38 const byte* ReadFile(const char* name, Isolate* isolate, int* size) { | 44 const byte* ReadFile(const char* name, Isolate* isolate, int* size) { |
| 39 FILE* file = fopen(name, "rb"); | 45 FILE* file = fopen(name, "rb"); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 50 int read = static_cast<int>(fread(&chars[i], 1, *size - i, file)); | 56 int read = static_cast<int>(fread(&chars[i], 1, *size - i, file)); |
| 51 i += read; | 57 i += read; |
| 52 } | 58 } |
| 53 fclose(file); | 59 fclose(file); |
| 54 return chars; | 60 return chars; |
| 55 } | 61 } |
| 56 | 62 |
| 57 } | 63 } |
| 58 | 64 |
| 59 ExperimentalScanner::ExperimentalScanner(const char* fname, | 65 ExperimentalScanner::ExperimentalScanner(const char* fname, |
| 60 bool read_all_at_once) | 66 bool read_all_at_once, |
| 67 Isolate* isolate) |
| 61 : current_(0), | 68 : current_(0), |
| 62 fetched_(0), | 69 fetched_(0), |
| 63 read_all_at_once_(read_all_at_once), | 70 read_all_at_once_(read_all_at_once), |
| 64 source_(0), | 71 source_(0), |
| 65 length_(0) { | 72 length_(0) { |
| 66 file_ = fopen(fname, "rb"); | 73 file_ = fopen(fname, "rb"); |
| 67 scanner_ = new PushScanner(this); | 74 scanner_ = new PushScanner(this, isolate->unicode_cache()); |
| 68 if (read_all_at_once_) { | 75 if (read_all_at_once_) { |
| 69 source_ = ReadFile(fname, NULL, &length_); | 76 source_ = ReadFile(fname, isolate, &length_); |
| 70 token_.resize(1500); | 77 token_.resize(1500); |
| 71 beg_.resize(1500); | 78 beg_.resize(1500); |
| 72 end_.resize(1500); | 79 end_.resize(1500); |
| 73 } else { | 80 } else { |
| 74 token_.resize(BUFFER_SIZE); | 81 token_.resize(BUFFER_SIZE); |
| 75 beg_.resize(BUFFER_SIZE); | 82 beg_.resize(BUFFER_SIZE); |
| 76 end_.resize(BUFFER_SIZE); | 83 end_.resize(BUFFER_SIZE); |
| 77 } | 84 } |
| 78 } | 85 } |
| 79 | 86 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 beg_.resize(beg_.size() * 2); | 129 beg_.resize(beg_.size() * 2); |
| 123 end_.resize(end_.size() * 2); | 130 end_.resize(end_.size() * 2); |
| 124 } | 131 } |
| 125 token_[fetched_] = token; | 132 token_[fetched_] = token; |
| 126 beg_[fetched_] = beg; | 133 beg_[fetched_] = beg; |
| 127 end_[fetched_] = end; | 134 end_[fetched_] = end; |
| 128 fetched_++; | 135 fetched_++; |
| 129 } | 136 } |
| 130 | 137 |
| 131 } } // namespace v8::internal | 138 } } // namespace v8::internal |
| OLD | NEW |