Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 1 | // Copyright 2010 the V8 project authors. All rights reserved. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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. |
| 27 | |
| 28 | #ifndef V8_PARSER_H_ |
| 29 | #define V8_PARSER_H_ |
| 30 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 31 | #include "allocation.h" |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 32 | #include "ast.h" |
| 33 | #include "scanner.h" |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 34 | #include "scopes.h" |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 35 | #include "preparse-data.h" |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 36 | |
| 37 | namespace v8 { |
| 38 | namespace internal { |
| 39 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 40 | class CompilationInfo; |
| 41 | class FuncNameInferrer; |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 42 | class ParserLog; |
| 43 | class PositionStack; |
| 44 | class Target; |
| 45 | class TemporaryScope; |
| 46 | |
| 47 | template <typename T> class ZoneListWrapper; |
| 48 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 49 | |
| 50 | class ParserMessage : public Malloced { |
| 51 | public: |
| 52 | ParserMessage(Scanner::Location loc, const char* message, |
| 53 | Vector<const char*> args) |
| 54 | : loc_(loc), |
| 55 | message_(message), |
| 56 | args_(args) { } |
| 57 | ~ParserMessage(); |
| 58 | Scanner::Location location() { return loc_; } |
| 59 | const char* message() { return message_; } |
| 60 | Vector<const char*> args() { return args_; } |
| 61 | private: |
| 62 | Scanner::Location loc_; |
| 63 | const char* message_; |
| 64 | Vector<const char*> args_; |
| 65 | }; |
| 66 | |
| 67 | |
| 68 | class FunctionEntry BASE_EMBEDDED { |
| 69 | public: |
| 70 | explicit FunctionEntry(Vector<unsigned> backing) : backing_(backing) { } |
| 71 | FunctionEntry() : backing_(Vector<unsigned>::empty()) { } |
| 72 | |
| 73 | int start_pos() { return backing_[kStartPosOffset]; } |
| 74 | void set_start_pos(int value) { backing_[kStartPosOffset] = value; } |
| 75 | |
| 76 | int end_pos() { return backing_[kEndPosOffset]; } |
| 77 | void set_end_pos(int value) { backing_[kEndPosOffset] = value; } |
| 78 | |
| 79 | int literal_count() { return backing_[kLiteralCountOffset]; } |
| 80 | void set_literal_count(int value) { backing_[kLiteralCountOffset] = value; } |
| 81 | |
| 82 | int property_count() { return backing_[kPropertyCountOffset]; } |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 83 | void set_property_count(int value) { |
| 84 | backing_[kPropertyCountOffset] = value; |
| 85 | } |
| 86 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 87 | bool is_valid() { return backing_.length() > 0; } |
| 88 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 89 | static const int kSize = 4; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 90 | |
| 91 | private: |
| 92 | Vector<unsigned> backing_; |
| 93 | static const int kStartPosOffset = 0; |
| 94 | static const int kEndPosOffset = 1; |
| 95 | static const int kLiteralCountOffset = 2; |
| 96 | static const int kPropertyCountOffset = 3; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | |
| 100 | class ScriptDataImpl : public ScriptData { |
| 101 | public: |
| 102 | explicit ScriptDataImpl(Vector<unsigned> store) |
| 103 | : store_(store), |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 104 | owns_store_(true) { } |
Iain Merrick | 9ac36c9 | 2010-09-13 15:29:50 +0100 | [diff] [blame] | 105 | |
| 106 | // Create an empty ScriptDataImpl that is guaranteed to not satisfy |
| 107 | // a SanityCheck. |
| 108 | ScriptDataImpl() : store_(Vector<unsigned>()), owns_store_(false) { } |
| 109 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 110 | virtual ~ScriptDataImpl(); |
| 111 | virtual int Length(); |
Leon Clarke | f7060e2 | 2010-06-03 12:02:55 +0100 | [diff] [blame] | 112 | virtual const char* Data(); |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 113 | virtual bool HasError(); |
Iain Merrick | 9ac36c9 | 2010-09-13 15:29:50 +0100 | [diff] [blame] | 114 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 115 | void Initialize(); |
| 116 | void ReadNextSymbolPosition(); |
| 117 | |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 118 | FunctionEntry GetFunctionEntry(int start); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 119 | int GetSymbolIdentifier(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 120 | bool SanityCheck(); |
| 121 | |
| 122 | Scanner::Location MessageLocation(); |
| 123 | const char* BuildMessage(); |
| 124 | Vector<const char*> BuildArgs(); |
| 125 | |
Iain Merrick | 9ac36c9 | 2010-09-13 15:29:50 +0100 | [diff] [blame] | 126 | int symbol_count() { |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 127 | return (store_.length() > PreparseDataConstants::kHeaderSize) |
| 128 | ? store_[PreparseDataConstants::kSymbolCountOffset] |
| 129 | : 0; |
Iain Merrick | 9ac36c9 | 2010-09-13 15:29:50 +0100 | [diff] [blame] | 130 | } |
| 131 | // The following functions should only be called if SanityCheck has |
| 132 | // returned true. |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 133 | bool has_error() { return store_[PreparseDataConstants::kHasErrorOffset]; } |
| 134 | unsigned magic() { return store_[PreparseDataConstants::kMagicOffset]; } |
| 135 | unsigned version() { return store_[PreparseDataConstants::kVersionOffset]; } |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 136 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 137 | private: |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 138 | Vector<unsigned> store_; |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 139 | unsigned char* symbol_data_; |
| 140 | unsigned char* symbol_data_end_; |
Iain Merrick | 9ac36c9 | 2010-09-13 15:29:50 +0100 | [diff] [blame] | 141 | int function_index_; |
Iain Merrick | 9ac36c9 | 2010-09-13 15:29:50 +0100 | [diff] [blame] | 142 | bool owns_store_; |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 143 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 144 | unsigned Read(int position); |
| 145 | unsigned* ReadAddress(int position); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 146 | // Reads a number from the current symbols |
| 147 | int ReadNumber(byte** source); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 148 | |
Iain Merrick | 9ac36c9 | 2010-09-13 15:29:50 +0100 | [diff] [blame] | 149 | ScriptDataImpl(const char* backing_store, int length) |
| 150 | : store_(reinterpret_cast<unsigned*>(const_cast<char*>(backing_store)), |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 151 | length / static_cast<int>(sizeof(unsigned))), |
Iain Merrick | 9ac36c9 | 2010-09-13 15:29:50 +0100 | [diff] [blame] | 152 | owns_store_(false) { |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 153 | ASSERT_EQ(0, static_cast<int>( |
| 154 | reinterpret_cast<intptr_t>(backing_store) % sizeof(unsigned))); |
Iain Merrick | 9ac36c9 | 2010-09-13 15:29:50 +0100 | [diff] [blame] | 155 | } |
| 156 | |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 157 | // Read strings written by ParserRecorder::WriteString. |
| 158 | static const char* ReadString(unsigned* start, int* chars); |
Iain Merrick | 9ac36c9 | 2010-09-13 15:29:50 +0100 | [diff] [blame] | 159 | |
| 160 | friend class ScriptData; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 161 | }; |
| 162 | |
| 163 | |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 164 | class ParserApi { |
| 165 | public: |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 166 | // Parses the source code represented by the compilation info and sets its |
| 167 | // function literal. Returns false (and deallocates any allocated AST |
| 168 | // nodes) if parsing failed. |
| 169 | static bool Parse(CompilationInfo* info); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 170 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 171 | // Generic preparser generating full preparse data. |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 172 | static ScriptDataImpl* PreParse(UC16CharacterStream* source, |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 173 | v8::Extension* extension); |
| 174 | |
| 175 | // Preparser that only does preprocessing that makes sense if only used |
| 176 | // immediately after. |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 177 | static ScriptDataImpl* PartialPreParse(UC16CharacterStream* source, |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 178 | v8::Extension* extension); |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 179 | }; |
| 180 | |
| 181 | // ---------------------------------------------------------------------------- |
| 182 | // REGEXP PARSING |
| 183 | |
| 184 | // A BuffferedZoneList is an automatically growing list, just like (and backed |
| 185 | // by) a ZoneList, that is optimized for the case of adding and removing |
| 186 | // a single element. The last element added is stored outside the backing list, |
| 187 | // and if no more than one element is ever added, the ZoneList isn't even |
| 188 | // allocated. |
| 189 | // Elements must not be NULL pointers. |
| 190 | template <typename T, int initial_size> |
| 191 | class BufferedZoneList { |
| 192 | public: |
| 193 | BufferedZoneList() : list_(NULL), last_(NULL) {} |
| 194 | |
| 195 | // Adds element at end of list. This element is buffered and can |
| 196 | // be read using last() or removed using RemoveLast until a new Add or until |
| 197 | // RemoveLast or GetList has been called. |
| 198 | void Add(T* value) { |
| 199 | if (last_ != NULL) { |
| 200 | if (list_ == NULL) { |
| 201 | list_ = new ZoneList<T*>(initial_size); |
| 202 | } |
| 203 | list_->Add(last_); |
| 204 | } |
| 205 | last_ = value; |
| 206 | } |
| 207 | |
| 208 | T* last() { |
| 209 | ASSERT(last_ != NULL); |
| 210 | return last_; |
| 211 | } |
| 212 | |
| 213 | T* RemoveLast() { |
| 214 | ASSERT(last_ != NULL); |
| 215 | T* result = last_; |
| 216 | if ((list_ != NULL) && (list_->length() > 0)) |
| 217 | last_ = list_->RemoveLast(); |
| 218 | else |
| 219 | last_ = NULL; |
| 220 | return result; |
| 221 | } |
| 222 | |
| 223 | T* Get(int i) { |
| 224 | ASSERT((0 <= i) && (i < length())); |
| 225 | if (list_ == NULL) { |
| 226 | ASSERT_EQ(0, i); |
| 227 | return last_; |
| 228 | } else { |
| 229 | if (i == list_->length()) { |
| 230 | ASSERT(last_ != NULL); |
| 231 | return last_; |
| 232 | } else { |
| 233 | return list_->at(i); |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | void Clear() { |
| 239 | list_ = NULL; |
| 240 | last_ = NULL; |
| 241 | } |
| 242 | |
| 243 | int length() { |
| 244 | int length = (list_ == NULL) ? 0 : list_->length(); |
| 245 | return length + ((last_ == NULL) ? 0 : 1); |
| 246 | } |
| 247 | |
| 248 | ZoneList<T*>* GetList() { |
| 249 | if (list_ == NULL) { |
| 250 | list_ = new ZoneList<T*>(initial_size); |
| 251 | } |
| 252 | if (last_ != NULL) { |
| 253 | list_->Add(last_); |
| 254 | last_ = NULL; |
| 255 | } |
| 256 | return list_; |
| 257 | } |
| 258 | |
| 259 | private: |
| 260 | ZoneList<T*>* list_; |
| 261 | T* last_; |
| 262 | }; |
| 263 | |
| 264 | |
| 265 | // Accumulates RegExp atoms and assertions into lists of terms and alternatives. |
| 266 | class RegExpBuilder: public ZoneObject { |
| 267 | public: |
| 268 | RegExpBuilder(); |
| 269 | void AddCharacter(uc16 character); |
| 270 | // "Adds" an empty expression. Does nothing except consume a |
| 271 | // following quantifier |
| 272 | void AddEmpty(); |
| 273 | void AddAtom(RegExpTree* tree); |
| 274 | void AddAssertion(RegExpTree* tree); |
| 275 | void NewAlternative(); // '|' |
| 276 | void AddQuantifierToAtom(int min, int max, RegExpQuantifier::Type type); |
| 277 | RegExpTree* ToRegExp(); |
| 278 | |
| 279 | private: |
| 280 | void FlushCharacters(); |
| 281 | void FlushText(); |
| 282 | void FlushTerms(); |
| 283 | bool pending_empty_; |
| 284 | ZoneList<uc16>* characters_; |
| 285 | BufferedZoneList<RegExpTree, 2> terms_; |
| 286 | BufferedZoneList<RegExpTree, 2> text_; |
| 287 | BufferedZoneList<RegExpTree, 2> alternatives_; |
| 288 | #ifdef DEBUG |
| 289 | enum {ADD_NONE, ADD_CHAR, ADD_TERM, ADD_ASSERT, ADD_ATOM} last_added_; |
| 290 | #define LAST(x) last_added_ = x; |
| 291 | #else |
| 292 | #define LAST(x) |
| 293 | #endif |
| 294 | }; |
| 295 | |
| 296 | |
| 297 | class RegExpParser { |
| 298 | public: |
| 299 | RegExpParser(FlatStringReader* in, |
| 300 | Handle<String>* error, |
| 301 | bool multiline_mode); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 302 | |
| 303 | static bool ParseRegExp(FlatStringReader* input, |
| 304 | bool multiline, |
| 305 | RegExpCompileData* result); |
| 306 | |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 307 | RegExpTree* ParsePattern(); |
| 308 | RegExpTree* ParseDisjunction(); |
| 309 | RegExpTree* ParseGroup(); |
| 310 | RegExpTree* ParseCharacterClass(); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 311 | |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 312 | // Parses a {...,...} quantifier and stores the range in the given |
| 313 | // out parameters. |
| 314 | bool ParseIntervalQuantifier(int* min_out, int* max_out); |
Steve Block | 5915150 | 2010-09-22 15:07:15 +0100 | [diff] [blame] | 315 | |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 316 | // Parses and returns a single escaped character. The character |
| 317 | // must not be 'b' or 'B' since they are usually handle specially. |
| 318 | uc32 ParseClassCharacterEscape(); |
| 319 | |
| 320 | // Checks whether the following is a length-digit hexadecimal number, |
| 321 | // and sets the value if it is. |
| 322 | bool ParseHexEscape(int length, uc32* value); |
| 323 | |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 324 | uc32 ParseOctalLiteral(); |
| 325 | |
| 326 | // Tries to parse the input as a back reference. If successful it |
| 327 | // stores the result in the output parameter and returns true. If |
| 328 | // it fails it will push back the characters read so the same characters |
| 329 | // can be reparsed. |
| 330 | bool ParseBackReferenceIndex(int* index_out); |
| 331 | |
| 332 | CharacterRange ParseClassAtom(uc16* char_class); |
| 333 | RegExpTree* ReportError(Vector<const char> message); |
| 334 | void Advance(); |
| 335 | void Advance(int dist); |
| 336 | void Reset(int pos); |
| 337 | |
| 338 | // Reports whether the pattern might be used as a literal search string. |
| 339 | // Only use if the result of the parse is a single atom node. |
| 340 | bool simple(); |
| 341 | bool contains_anchor() { return contains_anchor_; } |
| 342 | void set_contains_anchor() { contains_anchor_ = true; } |
| 343 | int captures_started() { return captures_ == NULL ? 0 : captures_->length(); } |
| 344 | int position() { return next_pos_ - 1; } |
| 345 | bool failed() { return failed_; } |
| 346 | |
| 347 | static const int kMaxCaptures = 1 << 16; |
| 348 | static const uc32 kEndMarker = (1 << 21); |
| 349 | |
| 350 | private: |
| 351 | enum SubexpressionType { |
| 352 | INITIAL, |
| 353 | CAPTURE, // All positive values represent captures. |
| 354 | POSITIVE_LOOKAHEAD, |
| 355 | NEGATIVE_LOOKAHEAD, |
| 356 | GROUPING |
| 357 | }; |
| 358 | |
| 359 | class RegExpParserState : public ZoneObject { |
| 360 | public: |
| 361 | RegExpParserState(RegExpParserState* previous_state, |
| 362 | SubexpressionType group_type, |
| 363 | int disjunction_capture_index) |
| 364 | : previous_state_(previous_state), |
| 365 | builder_(new RegExpBuilder()), |
| 366 | group_type_(group_type), |
| 367 | disjunction_capture_index_(disjunction_capture_index) {} |
| 368 | // Parser state of containing expression, if any. |
| 369 | RegExpParserState* previous_state() { return previous_state_; } |
| 370 | bool IsSubexpression() { return previous_state_ != NULL; } |
| 371 | // RegExpBuilder building this regexp's AST. |
| 372 | RegExpBuilder* builder() { return builder_; } |
| 373 | // Type of regexp being parsed (parenthesized group or entire regexp). |
| 374 | SubexpressionType group_type() { return group_type_; } |
| 375 | // Index in captures array of first capture in this sub-expression, if any. |
| 376 | // Also the capture index of this sub-expression itself, if group_type |
| 377 | // is CAPTURE. |
| 378 | int capture_index() { return disjunction_capture_index_; } |
| 379 | |
| 380 | private: |
| 381 | // Linked list implementation of stack of states. |
| 382 | RegExpParserState* previous_state_; |
| 383 | // Builder for the stored disjunction. |
| 384 | RegExpBuilder* builder_; |
| 385 | // Stored disjunction type (capture, look-ahead or grouping), if any. |
| 386 | SubexpressionType group_type_; |
| 387 | // Stored disjunction's capture index (if any). |
| 388 | int disjunction_capture_index_; |
| 389 | }; |
| 390 | |
| 391 | uc32 current() { return current_; } |
| 392 | bool has_more() { return has_more_; } |
| 393 | bool has_next() { return next_pos_ < in()->length(); } |
| 394 | uc32 Next(); |
| 395 | FlatStringReader* in() { return in_; } |
| 396 | void ScanForCaptures(); |
| 397 | |
| 398 | Handle<String>* error_; |
| 399 | ZoneList<RegExpCapture*>* captures_; |
| 400 | FlatStringReader* in_; |
| 401 | uc32 current_; |
| 402 | int next_pos_; |
| 403 | // The capture count is only valid after we have scanned for captures. |
| 404 | int capture_count_; |
| 405 | bool has_more_; |
| 406 | bool multiline_; |
| 407 | bool simple_; |
| 408 | bool contains_anchor_; |
| 409 | bool is_scanned_for_captures_; |
| 410 | bool failed_; |
| 411 | }; |
| 412 | |
| 413 | // ---------------------------------------------------------------------------- |
| 414 | // JAVASCRIPT PARSING |
| 415 | |
| 416 | class Parser { |
| 417 | public: |
| 418 | Parser(Handle<Script> script, |
| 419 | bool allow_natives_syntax, |
| 420 | v8::Extension* extension, |
| 421 | ScriptDataImpl* pre_data); |
| 422 | virtual ~Parser() { } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 423 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 424 | // Returns NULL if parsing failed. |
| 425 | FunctionLiteral* ParseProgram(Handle<String> source, |
| 426 | bool in_global_context); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 427 | |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 428 | FunctionLiteral* ParseLazy(Handle<SharedFunctionInfo> info); |
| 429 | |
| 430 | void ReportMessageAt(Scanner::Location loc, |
| 431 | const char* message, |
| 432 | Vector<const char*> args); |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame^] | 433 | void ReportMessageAt(Scanner::Location loc, |
| 434 | const char* message, |
| 435 | Vector<Handle<String> > args); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 436 | |
| 437 | protected: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 438 | FunctionLiteral* ParseLazy(Handle<SharedFunctionInfo> info, |
| 439 | UC16CharacterStream* source, |
| 440 | ZoneScope* zone_scope); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 441 | enum Mode { |
| 442 | PARSE_LAZILY, |
| 443 | PARSE_EAGERLY |
| 444 | }; |
| 445 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 446 | // Called by ParseProgram after setting up the scanner. |
| 447 | FunctionLiteral* DoParseProgram(Handle<String> source, |
| 448 | bool in_global_context, |
| 449 | ZoneScope* zone_scope); |
| 450 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 451 | // Report syntax error |
| 452 | void ReportUnexpectedToken(Token::Value token); |
| 453 | void ReportInvalidPreparseData(Handle<String> name, bool* ok); |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 454 | void ReportMessage(const char* message, Vector<const char*> args); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 455 | |
| 456 | bool inside_with() const { return with_nesting_level_ > 0; } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 457 | V8JavaScriptScanner& scanner() { return scanner_; } |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 458 | Mode mode() const { return mode_; } |
| 459 | ScriptDataImpl* pre_data() const { return pre_data_; } |
| 460 | |
| 461 | // All ParseXXX functions take as the last argument an *ok parameter |
| 462 | // which is set to false if parsing failed; it is unchanged otherwise. |
| 463 | // By making the 'exception handling' explicit, we are forced to check |
| 464 | // for failure at the call sites. |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 465 | void* ParseSourceElements(ZoneList<Statement*>* processor, |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 466 | int end_token, bool* ok); |
| 467 | Statement* ParseStatement(ZoneStringList* labels, bool* ok); |
| 468 | Statement* ParseFunctionDeclaration(bool* ok); |
| 469 | Statement* ParseNativeDeclaration(bool* ok); |
| 470 | Block* ParseBlock(ZoneStringList* labels, bool* ok); |
| 471 | Block* ParseVariableStatement(bool* ok); |
| 472 | Block* ParseVariableDeclarations(bool accept_IN, Expression** var, bool* ok); |
| 473 | Statement* ParseExpressionOrLabelledStatement(ZoneStringList* labels, |
| 474 | bool* ok); |
| 475 | IfStatement* ParseIfStatement(ZoneStringList* labels, bool* ok); |
| 476 | Statement* ParseContinueStatement(bool* ok); |
| 477 | Statement* ParseBreakStatement(ZoneStringList* labels, bool* ok); |
| 478 | Statement* ParseReturnStatement(bool* ok); |
| 479 | Block* WithHelper(Expression* obj, |
| 480 | ZoneStringList* labels, |
| 481 | bool is_catch_block, |
| 482 | bool* ok); |
| 483 | Statement* ParseWithStatement(ZoneStringList* labels, bool* ok); |
| 484 | CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok); |
| 485 | SwitchStatement* ParseSwitchStatement(ZoneStringList* labels, bool* ok); |
| 486 | DoWhileStatement* ParseDoWhileStatement(ZoneStringList* labels, bool* ok); |
| 487 | WhileStatement* ParseWhileStatement(ZoneStringList* labels, bool* ok); |
| 488 | Statement* ParseForStatement(ZoneStringList* labels, bool* ok); |
| 489 | Statement* ParseThrowStatement(bool* ok); |
| 490 | Expression* MakeCatchContext(Handle<String> id, VariableProxy* value); |
| 491 | TryStatement* ParseTryStatement(bool* ok); |
| 492 | DebuggerStatement* ParseDebuggerStatement(bool* ok); |
| 493 | |
| 494 | Expression* ParseExpression(bool accept_IN, bool* ok); |
| 495 | Expression* ParseAssignmentExpression(bool accept_IN, bool* ok); |
| 496 | Expression* ParseConditionalExpression(bool accept_IN, bool* ok); |
| 497 | Expression* ParseBinaryExpression(int prec, bool accept_IN, bool* ok); |
| 498 | Expression* ParseUnaryExpression(bool* ok); |
| 499 | Expression* ParsePostfixExpression(bool* ok); |
| 500 | Expression* ParseLeftHandSideExpression(bool* ok); |
| 501 | Expression* ParseNewExpression(bool* ok); |
| 502 | Expression* ParseMemberExpression(bool* ok); |
| 503 | Expression* ParseNewPrefix(PositionStack* stack, bool* ok); |
| 504 | Expression* ParseMemberWithNewPrefixesExpression(PositionStack* stack, |
| 505 | bool* ok); |
| 506 | Expression* ParsePrimaryExpression(bool* ok); |
| 507 | Expression* ParseArrayLiteral(bool* ok); |
| 508 | Expression* ParseObjectLiteral(bool* ok); |
| 509 | ObjectLiteral::Property* ParseObjectLiteralGetSet(bool is_getter, bool* ok); |
| 510 | Expression* ParseRegExpLiteral(bool seen_equal, bool* ok); |
| 511 | |
| 512 | Expression* NewCompareNode(Token::Value op, |
| 513 | Expression* x, |
| 514 | Expression* y, |
| 515 | int position); |
| 516 | |
| 517 | // Populate the constant properties fixed array for a materialized object |
| 518 | // literal. |
| 519 | void BuildObjectLiteralConstantProperties( |
| 520 | ZoneList<ObjectLiteral::Property*>* properties, |
| 521 | Handle<FixedArray> constants, |
| 522 | bool* is_simple, |
| 523 | bool* fast_elements, |
| 524 | int* depth); |
| 525 | |
| 526 | // Populate the literals fixed array for a materialized array literal. |
| 527 | void BuildArrayLiteralBoilerplateLiterals(ZoneList<Expression*>* properties, |
| 528 | Handle<FixedArray> constants, |
| 529 | bool* is_simple, |
| 530 | int* depth); |
| 531 | |
| 532 | // Decide if a property should be in the object boilerplate. |
| 533 | bool IsBoilerplateProperty(ObjectLiteral::Property* property); |
| 534 | // If the expression is a literal, return the literal value; |
| 535 | // if the expression is a materialized literal and is simple return a |
| 536 | // compile time value as encoded by CompileTimeValue::GetValue(). |
| 537 | // Otherwise, return undefined literal as the placeholder |
| 538 | // in the object literal boilerplate. |
| 539 | Handle<Object> GetBoilerplateValue(Expression* expression); |
| 540 | |
| 541 | enum FunctionLiteralType { |
| 542 | EXPRESSION, |
| 543 | DECLARATION, |
| 544 | NESTED |
| 545 | }; |
| 546 | |
| 547 | ZoneList<Expression*>* ParseArguments(bool* ok); |
| 548 | FunctionLiteral* ParseFunctionLiteral(Handle<String> var_name, |
| 549 | int function_token_position, |
| 550 | FunctionLiteralType type, |
| 551 | bool* ok); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 552 | |
| 553 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 554 | // Magical syntax support. |
| 555 | Expression* ParseV8Intrinsic(bool* ok); |
| 556 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 557 | INLINE(Token::Value peek()) { |
| 558 | if (stack_overflow_) return Token::ILLEGAL; |
| 559 | return scanner().peek(); |
| 560 | } |
| 561 | |
| 562 | INLINE(Token::Value Next()) { |
| 563 | // BUG 1215673: Find a thread safe way to set a stack limit in |
| 564 | // pre-parse mode. Otherwise, we cannot safely pre-parse from other |
| 565 | // threads. |
| 566 | if (stack_overflow_) { |
| 567 | return Token::ILLEGAL; |
| 568 | } |
| 569 | if (StackLimitCheck().HasOverflowed()) { |
| 570 | // Any further calls to Next or peek will return the illegal token. |
| 571 | // The current call must return the next token, which might already |
| 572 | // have been peek'ed. |
| 573 | stack_overflow_ = true; |
| 574 | } |
| 575 | return scanner().Next(); |
| 576 | } |
| 577 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 578 | INLINE(void Consume(Token::Value token)); |
| 579 | void Expect(Token::Value token, bool* ok); |
| 580 | bool Check(Token::Value token); |
| 581 | void ExpectSemicolon(bool* ok); |
| 582 | |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 583 | Handle<String> LiteralString(PretenureFlag tenured) { |
| 584 | if (scanner().is_literal_ascii()) { |
| 585 | return Factory::NewStringFromAscii(scanner().literal_ascii_string(), |
| 586 | tenured); |
| 587 | } else { |
| 588 | return Factory::NewStringFromTwoByte(scanner().literal_uc16_string(), |
| 589 | tenured); |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | Handle<String> NextLiteralString(PretenureFlag tenured) { |
| 594 | if (scanner().is_next_literal_ascii()) { |
| 595 | return Factory::NewStringFromAscii(scanner().next_literal_ascii_string(), |
| 596 | tenured); |
| 597 | } else { |
| 598 | return Factory::NewStringFromTwoByte(scanner().next_literal_uc16_string(), |
| 599 | tenured); |
| 600 | } |
| 601 | } |
| 602 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 603 | Handle<String> GetSymbol(bool* ok); |
| 604 | |
| 605 | // Get odd-ball literals. |
| 606 | Literal* GetLiteralUndefined(); |
| 607 | Literal* GetLiteralTheHole(); |
| 608 | Literal* GetLiteralNumber(double value); |
| 609 | |
| 610 | Handle<String> ParseIdentifier(bool* ok); |
| 611 | Handle<String> ParseIdentifierName(bool* ok); |
| 612 | Handle<String> ParseIdentifierOrGetOrSet(bool* is_get, |
| 613 | bool* is_set, |
| 614 | bool* ok); |
| 615 | |
| 616 | // Parser support |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 617 | VariableProxy* Declare(Handle<String> name, Variable::Mode mode, |
| 618 | FunctionLiteral* fun, |
| 619 | bool resolve, |
| 620 | bool* ok); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 621 | |
| 622 | bool TargetStackContainsLabel(Handle<String> label); |
| 623 | BreakableStatement* LookupBreakTarget(Handle<String> label, bool* ok); |
| 624 | IterationStatement* LookupContinueTarget(Handle<String> label, bool* ok); |
| 625 | |
| 626 | void RegisterTargetUse(BreakTarget* target, Target* stop); |
| 627 | |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 628 | // Factory methods. |
| 629 | |
| 630 | Statement* EmptyStatement() { |
| 631 | static v8::internal::EmptyStatement empty; |
| 632 | return ∅ |
| 633 | } |
| 634 | |
| 635 | Scope* NewScope(Scope* parent, Scope::Type type, bool inside_with); |
| 636 | |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 637 | Handle<String> LookupSymbol(int symbol_id); |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 638 | |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 639 | Handle<String> LookupCachedSymbol(int symbol_id); |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 640 | |
| 641 | Expression* NewCall(Expression* expression, |
| 642 | ZoneList<Expression*>* arguments, |
| 643 | int pos) { |
| 644 | return new Call(expression, arguments, pos); |
| 645 | } |
| 646 | |
| 647 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 648 | // Create a number literal. |
| 649 | Literal* NewNumberLiteral(double value); |
| 650 | |
| 651 | // Generate AST node that throw a ReferenceError with the given type. |
| 652 | Expression* NewThrowReferenceError(Handle<String> type); |
| 653 | |
| 654 | // Generate AST node that throw a SyntaxError with the given |
| 655 | // type. The first argument may be null (in the handle sense) in |
| 656 | // which case no arguments are passed to the constructor. |
| 657 | Expression* NewThrowSyntaxError(Handle<String> type, Handle<Object> first); |
| 658 | |
| 659 | // Generate AST node that throw a TypeError with the given |
| 660 | // type. Both arguments must be non-null (in the handle sense). |
| 661 | Expression* NewThrowTypeError(Handle<String> type, |
| 662 | Handle<Object> first, |
| 663 | Handle<Object> second); |
| 664 | |
| 665 | // Generic AST generator for throwing errors from compiled code. |
| 666 | Expression* NewThrowError(Handle<String> constructor, |
| 667 | Handle<String> type, |
| 668 | Vector< Handle<Object> > arguments); |
| 669 | |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 670 | ZoneList<Handle<String> > symbol_cache_; |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 671 | |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 672 | Handle<Script> script_; |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 673 | V8JavaScriptScanner scanner_; |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 674 | |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 675 | Scope* top_scope_; |
| 676 | int with_nesting_level_; |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 677 | |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 678 | TemporaryScope* temp_scope_; |
| 679 | Mode mode_; |
| 680 | |
| 681 | Target* target_stack_; // for break, continue statements |
| 682 | bool allow_natives_syntax_; |
| 683 | v8::Extension* extension_; |
| 684 | bool is_pre_parsing_; |
| 685 | ScriptDataImpl* pre_data_; |
| 686 | FuncNameInferrer* fni_; |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 687 | bool stack_overflow_; |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame^] | 688 | // If true, the next (and immediately following) function literal is |
| 689 | // preceded by a parenthesis. |
| 690 | // Heuristically that means that the function will be called immediately, |
| 691 | // so never lazily compile it. |
| 692 | bool parenthesized_function_; |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 693 | }; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 694 | |
| 695 | |
| 696 | // Support for handling complex values (array and object literals) that |
| 697 | // can be fully handled at compile time. |
| 698 | class CompileTimeValue: public AllStatic { |
| 699 | public: |
| 700 | enum Type { |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 701 | OBJECT_LITERAL_FAST_ELEMENTS, |
| 702 | OBJECT_LITERAL_SLOW_ELEMENTS, |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 703 | ARRAY_LITERAL |
| 704 | }; |
| 705 | |
| 706 | static bool IsCompileTimeValue(Expression* expression); |
| 707 | |
Iain Merrick | 7568138 | 2010-08-19 15:07:18 +0100 | [diff] [blame] | 708 | static bool ArrayLiteralElementNeedsInitialization(Expression* value); |
| 709 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 710 | // Get the value as a compile time value. |
| 711 | static Handle<FixedArray> GetValue(Expression* expression); |
| 712 | |
| 713 | // Get the type of a compile time value returned by GetValue(). |
| 714 | static Type GetType(Handle<FixedArray> value); |
| 715 | |
| 716 | // Get the elements array of a compile time value returned by GetValue(). |
| 717 | static Handle<FixedArray> GetElements(Handle<FixedArray> value); |
| 718 | |
| 719 | private: |
| 720 | static const int kTypeSlot = 0; |
| 721 | static const int kElementsSlot = 1; |
| 722 | |
| 723 | DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
| 724 | }; |
| 725 | |
| 726 | |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 727 | // ---------------------------------------------------------------------------- |
| 728 | // JSON PARSING |
| 729 | |
| 730 | // JSON is a subset of JavaScript, as specified in, e.g., the ECMAScript 5 |
| 731 | // specification section 15.12.1 (and appendix A.8). |
| 732 | // The grammar is given section 15.12.1.2 (and appendix A.8.2). |
| 733 | class JsonParser BASE_EMBEDDED { |
| 734 | public: |
| 735 | // Parse JSON input as a single JSON value. |
| 736 | // Returns null handle and sets exception if parsing failed. |
| 737 | static Handle<Object> Parse(Handle<String> source) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 738 | if (source->IsExternalTwoByteString()) { |
| 739 | ExternalTwoByteStringUC16CharacterStream stream( |
| 740 | Handle<ExternalTwoByteString>::cast(source), 0, source->length()); |
| 741 | return JsonParser().ParseJson(source, &stream); |
| 742 | } else { |
| 743 | GenericStringUC16CharacterStream stream(source, 0, source->length()); |
| 744 | return JsonParser().ParseJson(source, &stream); |
| 745 | } |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 746 | } |
| 747 | |
| 748 | private: |
| 749 | JsonParser() { } |
| 750 | ~JsonParser() { } |
| 751 | |
| 752 | // Parse a string containing a single JSON value. |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 753 | Handle<Object> ParseJson(Handle<String> script, UC16CharacterStream* source); |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 754 | // Parse a single JSON value from input (grammar production JSONValue). |
| 755 | // A JSON value is either a (double-quoted) string literal, a number literal, |
| 756 | // one of "true", "false", or "null", or an object or array literal. |
| 757 | Handle<Object> ParseJsonValue(); |
| 758 | // Parse a JSON object literal (grammar production JSONObject). |
| 759 | // An object literal is a squiggly-braced and comma separated sequence |
| 760 | // (possibly empty) of key/value pairs, where the key is a JSON string |
| 761 | // literal, the value is a JSON value, and the two are separated by a colon. |
| 762 | // A JSON array dosn't allow numbers and identifiers as keys, like a |
| 763 | // JavaScript array. |
| 764 | Handle<Object> ParseJsonObject(); |
| 765 | // Parses a JSON array literal (grammar production JSONArray). An array |
| 766 | // literal is a square-bracketed and comma separated sequence (possibly empty) |
| 767 | // of JSON values. |
| 768 | // A JSON array doesn't allow leaving out values from the sequence, nor does |
| 769 | // it allow a terminal comma, like a JavaScript array does. |
| 770 | Handle<Object> ParseJsonArray(); |
| 771 | |
| 772 | // Mark that a parsing error has happened at the current token, and |
| 773 | // return a null handle. Primarily for readability. |
| 774 | Handle<Object> ReportUnexpectedToken() { return Handle<Object>::null(); } |
| 775 | // Converts the currently parsed literal to a JavaScript String. |
| 776 | Handle<String> GetString(); |
| 777 | |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 778 | JsonScanner scanner_; |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 779 | bool stack_overflow_; |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 780 | }; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 781 | } } // namespace v8::internal |
| 782 | |
| 783 | #endif // V8_PARSER_H_ |