OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_PARSER_H_ | 5 #ifndef V8_PARSER_H_ |
6 #define V8_PARSER_H_ | 6 #define V8_PARSER_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/ast.h" | 9 #include "src/ast.h" |
10 #include "src/compiler.h" // For CachedDataMode | 10 #include "src/compiler.h" // For CachedDataMode |
(...skipping 29 matching lines...) Expand all Loading... |
40 explicit FunctionEntry(Vector<unsigned> backing) | 40 explicit FunctionEntry(Vector<unsigned> backing) |
41 : backing_(backing) { } | 41 : backing_(backing) { } |
42 | 42 |
43 FunctionEntry() : backing_() { } | 43 FunctionEntry() : backing_() { } |
44 | 44 |
45 int start_pos() { return backing_[kStartPositionIndex]; } | 45 int start_pos() { return backing_[kStartPositionIndex]; } |
46 int end_pos() { return backing_[kEndPositionIndex]; } | 46 int end_pos() { return backing_[kEndPositionIndex]; } |
47 int literal_count() { return backing_[kLiteralCountIndex]; } | 47 int literal_count() { return backing_[kLiteralCountIndex]; } |
48 int property_count() { return backing_[kPropertyCountIndex]; } | 48 int property_count() { return backing_[kPropertyCountIndex]; } |
49 StrictMode strict_mode() { | 49 StrictMode strict_mode() { |
50 ASSERT(backing_[kStrictModeIndex] == SLOPPY || | 50 DCHECK(backing_[kStrictModeIndex] == SLOPPY || |
51 backing_[kStrictModeIndex] == STRICT); | 51 backing_[kStrictModeIndex] == STRICT); |
52 return static_cast<StrictMode>(backing_[kStrictModeIndex]); | 52 return static_cast<StrictMode>(backing_[kStrictModeIndex]); |
53 } | 53 } |
54 | 54 |
55 bool is_valid() { return !backing_.is_empty(); } | 55 bool is_valid() { return !backing_.is_empty(); } |
56 | 56 |
57 private: | 57 private: |
58 Vector<unsigned> backing_; | 58 Vector<unsigned> backing_; |
59 }; | 59 }; |
60 | 60 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 if (last_ != NULL) { | 113 if (last_ != NULL) { |
114 if (list_ == NULL) { | 114 if (list_ == NULL) { |
115 list_ = new(zone) ZoneList<T*>(initial_size, zone); | 115 list_ = new(zone) ZoneList<T*>(initial_size, zone); |
116 } | 116 } |
117 list_->Add(last_, zone); | 117 list_->Add(last_, zone); |
118 } | 118 } |
119 last_ = value; | 119 last_ = value; |
120 } | 120 } |
121 | 121 |
122 T* last() { | 122 T* last() { |
123 ASSERT(last_ != NULL); | 123 DCHECK(last_ != NULL); |
124 return last_; | 124 return last_; |
125 } | 125 } |
126 | 126 |
127 T* RemoveLast() { | 127 T* RemoveLast() { |
128 ASSERT(last_ != NULL); | 128 DCHECK(last_ != NULL); |
129 T* result = last_; | 129 T* result = last_; |
130 if ((list_ != NULL) && (list_->length() > 0)) | 130 if ((list_ != NULL) && (list_->length() > 0)) |
131 last_ = list_->RemoveLast(); | 131 last_ = list_->RemoveLast(); |
132 else | 132 else |
133 last_ = NULL; | 133 last_ = NULL; |
134 return result; | 134 return result; |
135 } | 135 } |
136 | 136 |
137 T* Get(int i) { | 137 T* Get(int i) { |
138 ASSERT((0 <= i) && (i < length())); | 138 DCHECK((0 <= i) && (i < length())); |
139 if (list_ == NULL) { | 139 if (list_ == NULL) { |
140 ASSERT_EQ(0, i); | 140 DCHECK_EQ(0, i); |
141 return last_; | 141 return last_; |
142 } else { | 142 } else { |
143 if (i == list_->length()) { | 143 if (i == list_->length()) { |
144 ASSERT(last_ != NULL); | 144 DCHECK(last_ != NULL); |
145 return last_; | 145 return last_; |
146 } else { | 146 } else { |
147 return list_->at(i); | 147 return list_->at(i); |
148 } | 148 } |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
152 void Clear() { | 152 void Clear() { |
153 list_ = NULL; | 153 list_ = NULL; |
154 last_ = NULL; | 154 last_ = NULL; |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 // Helper functions for recursive descent. | 393 // Helper functions for recursive descent. |
394 bool IsEvalOrArguments(const AstRawString* identifier) const; | 394 bool IsEvalOrArguments(const AstRawString* identifier) const; |
395 V8_INLINE bool IsFutureStrictReserved(const AstRawString* identifier) const; | 395 V8_INLINE bool IsFutureStrictReserved(const AstRawString* identifier) const; |
396 | 396 |
397 // Returns true if the expression is of type "this.foo". | 397 // Returns true if the expression is of type "this.foo". |
398 static bool IsThisProperty(Expression* expression); | 398 static bool IsThisProperty(Expression* expression); |
399 | 399 |
400 static bool IsIdentifier(Expression* expression); | 400 static bool IsIdentifier(Expression* expression); |
401 | 401 |
402 static const AstRawString* AsIdentifier(Expression* expression) { | 402 static const AstRawString* AsIdentifier(Expression* expression) { |
403 ASSERT(IsIdentifier(expression)); | 403 DCHECK(IsIdentifier(expression)); |
404 return expression->AsVariableProxy()->raw_name(); | 404 return expression->AsVariableProxy()->raw_name(); |
405 } | 405 } |
406 | 406 |
407 static bool IsBoilerplateProperty(ObjectLiteral::Property* property) { | 407 static bool IsBoilerplateProperty(ObjectLiteral::Property* property) { |
408 return ObjectLiteral::IsBoilerplateProperty(property); | 408 return ObjectLiteral::IsBoilerplateProperty(property); |
409 } | 409 } |
410 | 410 |
411 static bool IsArrayIndex(const AstRawString* string, uint32_t* index) { | 411 static bool IsArrayIndex(const AstRawString* string, uint32_t* index) { |
412 return string->AsArrayIndex(index); | 412 return string->AsArrayIndex(index); |
413 } | 413 } |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 private: | 881 private: |
882 static const int kLiteralTypeSlot = 0; | 882 static const int kLiteralTypeSlot = 0; |
883 static const int kElementsSlot = 1; | 883 static const int kElementsSlot = 1; |
884 | 884 |
885 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 885 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
886 }; | 886 }; |
887 | 887 |
888 } } // namespace v8::internal | 888 } } // namespace v8::internal |
889 | 889 |
890 #endif // V8_PARSER_H_ | 890 #endif // V8_PARSER_H_ |
OLD | NEW |