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

Side by Side Diff: src/preparser.h

Issue 12646003: Add parser support for generators. (Closed) Base URL: git://github.com/v8/v8.git@bleeding_edge
Patch Set: Created 7 years, 9 months 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/parser.cc ('k') | src/preparser.cc » ('j') | src/preparser.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } 233 }
234 static Identifier Arguments() { 234 static Identifier Arguments() {
235 return Identifier(kArgumentsIdentifier); 235 return Identifier(kArgumentsIdentifier);
236 } 236 }
237 static Identifier FutureReserved() { 237 static Identifier FutureReserved() {
238 return Identifier(kFutureReservedIdentifier); 238 return Identifier(kFutureReservedIdentifier);
239 } 239 }
240 static Identifier FutureStrictReserved() { 240 static Identifier FutureStrictReserved() {
241 return Identifier(kFutureStrictReservedIdentifier); 241 return Identifier(kFutureStrictReservedIdentifier);
242 } 242 }
243 static Identifier Yield() {
244 return Identifier(kFutureStrictReservedIdentifier);
245 }
243 bool IsEval() { return type_ == kEvalIdentifier; } 246 bool IsEval() { return type_ == kEvalIdentifier; }
244 bool IsArguments() { return type_ == kArgumentsIdentifier; } 247 bool IsArguments() { return type_ == kArgumentsIdentifier; }
245 bool IsEvalOrArguments() { return type_ >= kEvalIdentifier; } 248 bool IsEvalOrArguments() { return type_ >= kEvalIdentifier; }
249 bool IsYield() { return type_ == kYieldIdentifier; }
246 bool IsFutureReserved() { return type_ == kFutureReservedIdentifier; } 250 bool IsFutureReserved() { return type_ == kFutureReservedIdentifier; }
247 bool IsFutureStrictReserved() { 251 bool IsFutureStrictReserved() {
248 return type_ == kFutureStrictReservedIdentifier; 252 return type_ == kFutureStrictReservedIdentifier;
249 } 253 }
250 bool IsValidStrictVariable() { return type_ == kUnknownIdentifier; } 254 bool IsValidStrictVariable() { return type_ == kUnknownIdentifier; }
251 255
252 private: 256 private:
253 enum Type { 257 enum Type {
254 kUnknownIdentifier, 258 kUnknownIdentifier,
255 kFutureReservedIdentifier, 259 kFutureReservedIdentifier,
256 kFutureStrictReservedIdentifier, 260 kFutureStrictReservedIdentifier,
261 kYieldIdentifier,
257 kEvalIdentifier, 262 kEvalIdentifier,
258 kArgumentsIdentifier 263 kArgumentsIdentifier
259 }; 264 };
260 explicit Identifier(Type type) : type_(type) { } 265 explicit Identifier(Type type) : type_(type) { }
261 Type type_; 266 Type type_;
262 267
263 friend class Expression; 268 friend class Expression;
264 }; 269 };
265 270
266 // Bits 0 and 1 are used to identify the type of expression: 271 // Bits 0 and 1 are used to identify the type of expression:
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 class Scope { 449 class Scope {
445 public: 450 public:
446 Scope(Scope** variable, ScopeType type) 451 Scope(Scope** variable, ScopeType type)
447 : variable_(variable), 452 : variable_(variable),
448 prev_(*variable), 453 prev_(*variable),
449 type_(type), 454 type_(type),
450 materialized_literal_count_(0), 455 materialized_literal_count_(0),
451 expected_properties_(0), 456 expected_properties_(0),
452 with_nesting_count_(0), 457 with_nesting_count_(0),
453 language_mode_( 458 language_mode_(
454 (prev_ != NULL) ? prev_->language_mode() : i::CLASSIC_MODE) { 459 (prev_ != NULL) ? prev_->language_mode() : i::CLASSIC_MODE),
460 is_generator_(false) {
455 *variable = this; 461 *variable = this;
456 } 462 }
457 ~Scope() { *variable_ = prev_; } 463 ~Scope() { *variable_ = prev_; }
458 void NextMaterializedLiteralIndex() { materialized_literal_count_++; } 464 void NextMaterializedLiteralIndex() { materialized_literal_count_++; }
459 void AddProperty() { expected_properties_++; } 465 void AddProperty() { expected_properties_++; }
460 ScopeType type() { return type_; } 466 ScopeType type() { return type_; }
461 int expected_properties() { return expected_properties_; } 467 int expected_properties() { return expected_properties_; }
462 int materialized_literal_count() { return materialized_literal_count_; } 468 int materialized_literal_count() { return materialized_literal_count_; }
463 bool IsInsideWith() { return with_nesting_count_ != 0; } 469 bool IsInsideWith() { return with_nesting_count_ != 0; }
470 bool is_generator() { return is_generator_; }
471 void set_is_generator(bool is_generator) { is_generator_ = is_generator; }
464 bool is_classic_mode() { 472 bool is_classic_mode() {
465 return language_mode_ == i::CLASSIC_MODE; 473 return language_mode_ == i::CLASSIC_MODE;
466 } 474 }
467 i::LanguageMode language_mode() { 475 i::LanguageMode language_mode() {
468 return language_mode_; 476 return language_mode_;
469 } 477 }
470 void set_language_mode(i::LanguageMode language_mode) { 478 void set_language_mode(i::LanguageMode language_mode) {
471 language_mode_ = language_mode; 479 language_mode_ = language_mode;
472 } 480 }
473 481
(...skipping 11 matching lines...) Expand all
485 }; 493 };
486 494
487 private: 495 private:
488 Scope** const variable_; 496 Scope** const variable_;
489 Scope* const prev_; 497 Scope* const prev_;
490 const ScopeType type_; 498 const ScopeType type_;
491 int materialized_literal_count_; 499 int materialized_literal_count_;
492 int expected_properties_; 500 int expected_properties_;
493 int with_nesting_count_; 501 int with_nesting_count_;
494 i::LanguageMode language_mode_; 502 i::LanguageMode language_mode_;
503 bool is_generator_;
495 }; 504 };
496 505
497 // Preparse the program. Only called in PreParseProgram after creating 506 // Preparse the program. Only called in PreParseProgram after creating
498 // the instance. 507 // the instance.
499 PreParseResult PreParse() { 508 PreParseResult PreParse() {
500 Scope top_scope(&scope_, kTopLevelScope); 509 Scope top_scope(&scope_, kTopLevelScope);
501 bool ok = true; 510 bool ok = true;
502 int start_position = scanner_->peek_location().beg_pos; 511 int start_position = scanner_->peek_location().beg_pos;
503 ParseSourceElements(i::Token::EOS, &ok); 512 ParseSourceElements(i::Token::EOS, &ok);
504 if (stack_overflow_) return kPreParseStackOverflow; 513 if (stack_overflow_) return kPreParseStackOverflow;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 bool stack_overflow_; 672 bool stack_overflow_;
664 bool allow_lazy_; 673 bool allow_lazy_;
665 bool allow_modules_; 674 bool allow_modules_;
666 bool allow_natives_syntax_; 675 bool allow_natives_syntax_;
667 bool parenthesized_function_; 676 bool parenthesized_function_;
668 bool harmony_scoping_; 677 bool harmony_scoping_;
669 }; 678 };
670 } } // v8::preparser 679 } } // v8::preparser
671 680
672 #endif // V8_PREPARSER_H 681 #endif // V8_PREPARSER_H
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/preparser.cc » ('j') | src/preparser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698