Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: src/vector.h

Issue 641283003: Support lazy parsing of inner functions (Closed) Base URL: https://chromium.googlesource.com/external/v8.git@bleeding_edge
Patch Set: Actually track variable declarations in the preparser Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/preparser.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_VECTOR_H_ 5 #ifndef V8_VECTOR_H_
6 #define V8_VECTOR_H_ 6 #define V8_VECTOR_H_
7 7
8 #include <string.h> 8 #include <string.h>
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 14 matching lines...) Expand all
25 } 25 }
26 26
27 static Vector<T> New(int length) { 27 static Vector<T> New(int length) {
28 return Vector<T>(NewArray<T>(length), length); 28 return Vector<T>(NewArray<T>(length), length);
29 } 29 }
30 30
31 // Returns a vector using the same backing storage as this one, 31 // Returns a vector using the same backing storage as this one,
32 // spanning from and including 'from', to but not including 'to'. 32 // spanning from and including 'from', to but not including 'to'.
33 Vector<T> SubVector(int from, int to) { 33 Vector<T> SubVector(int from, int to) {
34 SLOW_DCHECK(to <= length_); 34 SLOW_DCHECK(to <= length_);
35 SLOW_DCHECK(from < to); 35 SLOW_DCHECK(from <= to);
36 DCHECK(0 <= from); 36 DCHECK(0 <= from);
37 return Vector<T>(start() + from, to - from); 37 return Vector<T>(start() + from, to - from);
38 } 38 }
39 39
40 // Returns the length of the vector. 40 // Returns the length of the vector.
41 int length() const { return length_; } 41 int length() const { return length_; }
42 42
43 // Returns whether or not the vector is empty. 43 // Returns whether or not the vector is empty.
44 bool is_empty() const { return length_ == 0; } 44 bool is_empty() const { return length_ == 0; }
45 45
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 // Releases the array underlying this vector. Once disposed the 85 // Releases the array underlying this vector. Once disposed the
86 // vector is empty. 86 // vector is empty.
87 void Dispose() { 87 void Dispose() {
88 DeleteArray(start_); 88 DeleteArray(start_);
89 start_ = NULL; 89 start_ = NULL;
90 length_ = 0; 90 length_ = 0;
91 } 91 }
92 92
93 inline Vector<T> operator+(int offset) { 93 inline Vector<T> operator+(int offset) {
94 DCHECK(offset < length_); 94 DCHECK(offset <= length_);
95 return Vector<T>(start_ + offset, length_ - offset); 95 return Vector<T>(start_ + offset, length_ - offset);
96 } 96 }
97 97
98 inline Vector<T>& operator+=(int offset) {
99 DCHECK(offset <= length_);
100 start_ += offset;
101 length_ -= offset;
102 return *this;
103 }
104
98 // Factory method for creating empty vectors. 105 // Factory method for creating empty vectors.
99 static Vector<T> empty() { return Vector<T>(NULL, 0); } 106 static Vector<T> empty() { return Vector<T>(NULL, 0); }
100 107
101 template<typename S> 108 template<typename S>
102 static Vector<T> cast(Vector<S> input) { 109 static Vector<T> cast(Vector<S> input) {
103 return Vector<T>(reinterpret_cast<T*>(input.start()), 110 return Vector<T>(reinterpret_cast<T*>(input.start()),
104 input.length() * sizeof(S) / sizeof(T)); 111 input.length() * sizeof(S) / sizeof(T));
105 } 112 }
106 113
107 bool operator==(const Vector<T>& other) const { 114 bool operator==(const Vector<T>& other) const {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 184
178 inline Vector<char> MutableCStrVector(char* data, int max) { 185 inline Vector<char> MutableCStrVector(char* data, int max) {
179 int length = StrLength(data); 186 int length = StrLength(data);
180 return Vector<char>(data, (length < max) ? length : max); 187 return Vector<char>(data, (length < max) ? length : max);
181 } 188 }
182 189
183 190
184 } } // namespace v8::internal 191 } } // namespace v8::internal
185 192
186 #endif // V8_VECTOR_H_ 193 #endif // V8_VECTOR_H_
OLDNEW
« no previous file with comments | « src/preparser.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698