Revision f230a1cf deps/v8/src/parser.h

View differences:

deps/v8/src/parser.h
425 425
// Forward declaration.
426 426
class SingletonLogger;
427 427

  
428
class Parser BASE_EMBEDDED {
428
class Parser : public ParserBase {
429 429
 public:
430 430
  explicit Parser(CompilationInfo* info);
431 431
  ~Parser() {
......
433 433
    reusable_preparser_ = NULL;
434 434
  }
435 435

  
436
  bool allow_natives_syntax() const { return allow_natives_syntax_; }
437
  bool allow_lazy() const { return allow_lazy_; }
438
  bool allow_modules() { return scanner().HarmonyModules(); }
439
  bool allow_harmony_scoping() { return scanner().HarmonyScoping(); }
440
  bool allow_generators() const { return allow_generators_; }
441
  bool allow_for_of() const { return allow_for_of_; }
442
  bool allow_harmony_numeric_literals() {
443
    return scanner().HarmonyNumericLiterals();
444
  }
445

  
446
  void set_allow_natives_syntax(bool allow) { allow_natives_syntax_ = allow; }
447
  void set_allow_lazy(bool allow) { allow_lazy_ = allow; }
448
  void set_allow_modules(bool allow) { scanner().SetHarmonyModules(allow); }
449
  void set_allow_harmony_scoping(bool allow) {
450
    scanner().SetHarmonyScoping(allow);
451
  }
452
  void set_allow_generators(bool allow) { allow_generators_ = allow; }
453
  void set_allow_for_of(bool allow) { allow_for_of_ = allow; }
454
  void set_allow_harmony_numeric_literals(bool allow) {
455
    scanner().SetHarmonyNumericLiterals(allow);
456
  }
457

  
458 436
  // Parses the source code represented by the compilation info and sets its
459 437
  // function literal.  Returns false (and deallocates any allocated AST
460 438
  // nodes) if parsing failed.
461 439
  static bool Parse(CompilationInfo* info) { return Parser(info).Parse(); }
462 440
  bool Parse();
463 441

  
464
  // Returns NULL if parsing failed.
465
  FunctionLiteral* ParseProgram();
466

  
467
  void ReportMessageAt(Scanner::Location loc,
468
                       const char* message,
469
                       Vector<const char*> args);
470
  void ReportMessageAt(Scanner::Location loc,
471
                       const char* message,
472
                       Vector<Handle<String> > args);
473

  
474 442
 private:
475 443
  static const int kMaxNumFunctionLocals = 131071;  // 2^17-1
476 444

  
......
568 536
    Mode old_mode_;
569 537
  };
570 538

  
539
  // Returns NULL if parsing failed.
540
  FunctionLiteral* ParseProgram();
541

  
571 542
  FunctionLiteral* ParseLazy();
572 543
  FunctionLiteral* ParseLazy(Utf16CharacterStream* source);
573 544

  
......
584 555
  void ReportInvalidPreparseData(Handle<String> name, bool* ok);
585 556
  void ReportMessage(const char* message, Vector<const char*> args);
586 557
  void ReportMessage(const char* message, Vector<Handle<String> > args);
558
  void ReportMessageAt(Scanner::Location location, const char* type) {
559
    ReportMessageAt(location, type, Vector<const char*>::empty());
560
  }
561
  void ReportMessageAt(Scanner::Location loc,
562
                       const char* message,
563
                       Vector<const char*> args);
564
  void ReportMessageAt(Scanner::Location loc,
565
                       const char* message,
566
                       Vector<Handle<String> > args);
587 567

  
588 568
  void set_pre_parse_data(ScriptDataImpl *data) {
589 569
    pre_parse_data_ = data;
......
671 651
  Expression* ParsePrimaryExpression(bool* ok);
672 652
  Expression* ParseArrayLiteral(bool* ok);
673 653
  Expression* ParseObjectLiteral(bool* ok);
674
  ObjectLiteral::Property* ParseObjectLiteralGetSet(bool is_getter, bool* ok);
675 654
  Expression* ParseRegExpLiteral(bool seen_equal, bool* ok);
676 655

  
677 656
  // Populate the constant properties fixed array for a materialized object
......
711 690
  // Magical syntax support.
712 691
  Expression* ParseV8Intrinsic(bool* ok);
713 692

  
714
  INLINE(Token::Value peek()) {
715
    if (stack_overflow_) return Token::ILLEGAL;
716
    return scanner().peek();
717
  }
718

  
719
  INLINE(Token::Value Next()) {
720
    // BUG 1215673: Find a thread safe way to set a stack limit in
721
    // pre-parse mode. Otherwise, we cannot safely pre-parse from other
722
    // threads.
723
    if (stack_overflow_) {
724
      return Token::ILLEGAL;
725
    }
726
    if (StackLimitCheck(isolate()).HasOverflowed()) {
727
      // Any further calls to Next or peek will return the illegal token.
728
      // The current call must return the next token, which might already
729
      // have been peek'ed.
730
      stack_overflow_ = true;
731
    }
732
    return scanner().Next();
733
  }
734

  
735 693
  bool is_generator() const { return current_function_state_->is_generator(); }
736 694

  
737 695
  bool CheckInOrOf(bool accept_OF, ForEachStatement::VisitMode* visit_mode);
738 696

  
739
  bool peek_any_identifier();
740

  
741
  INLINE(void Consume(Token::Value token));
742
  void Expect(Token::Value token, bool* ok);
743
  bool Check(Token::Value token);
744
  void ExpectSemicolon(bool* ok);
745
  bool CheckContextualKeyword(Vector<const char> keyword);
746
  void ExpectContextualKeyword(Vector<const char> keyword, bool* ok);
747

  
748 697
  Handle<String> LiteralString(PretenureFlag tenured) {
749 698
    if (scanner().is_literal_ascii()) {
750 699
      return isolate_->factory()->NewStringFromAscii(
......
768 717
  Handle<String> GetSymbol();
769 718

  
770 719
  // Get odd-ball literals.
771
  Literal* GetLiteralUndefined();
772
  Literal* GetLiteralTheHole();
720
  Literal* GetLiteralUndefined(int position);
721
  Literal* GetLiteralTheHole(int position);
773 722

  
774 723
  Handle<String> ParseIdentifier(bool* ok);
775 724
  Handle<String> ParseIdentifierOrStrictReservedWord(
......
789 738
                             const char* error,
790 739
                             bool* ok);
791 740

  
792
  // Strict mode octal literal validation.
793
  void CheckOctalLiteral(int beg_pos, int end_pos, bool* ok);
794

  
795 741
  // For harmony block scoping mode: Check if the scope has conflicting var/let
796 742
  // declarations from different scopes. It covers for example
797 743
  //
......
842 788
                            Handle<String> type,
843 789
                            Vector< Handle<Object> > arguments);
844 790

  
845
  preparser::PreParser::PreParseResult LazyParseFunctionLiteral(
791
  PreParser::PreParseResult LazyParseFunctionLiteral(
846 792
       SingletonLogger* logger);
847 793

  
848 794
  AstNodeFactory<AstConstructionVisitor>* factory() {
......
854 800

  
855 801
  Handle<Script> script_;
856 802
  Scanner scanner_;
857
  preparser::PreParser* reusable_preparser_;
803
  PreParser* reusable_preparser_;
858 804
  Scope* top_scope_;
859 805
  Scope* original_scope_;  // for ES5 function declarations in sloppy eval
860 806
  FunctionState* current_function_state_;
......
864 810
  FuncNameInferrer* fni_;
865 811

  
866 812
  Mode mode_;
867
  bool allow_natives_syntax_;
868
  bool allow_lazy_;
869
  bool allow_generators_;
870
  bool allow_for_of_;
871
  bool stack_overflow_;
872 813
  // If true, the next (and immediately following) function literal is
873 814
  // preceded by a parenthesis.
874 815
  // Heuristically that means that the function will be called immediately,

Also available in: Unified diff