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

Side by Side Diff: src/preparser.h

Issue 908173003: Parsing: Make Parser not know about Isolate during background parsing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
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_PREPARSER_H 5 #ifndef V8_PREPARSER_H
6 #define V8_PREPARSER_H 6 #define V8_PREPARSER_H
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 template <typename Traits> 60 template <typename Traits>
61 class ParserBase : public Traits { 61 class ParserBase : public Traits {
62 public: 62 public:
63 // Shorten type names defined by Traits. 63 // Shorten type names defined by Traits.
64 typedef typename Traits::Type::Expression ExpressionT; 64 typedef typename Traits::Type::Expression ExpressionT;
65 typedef typename Traits::Type::Identifier IdentifierT; 65 typedef typename Traits::Type::Identifier IdentifierT;
66 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT; 66 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT;
67 typedef typename Traits::Type::Literal LiteralT; 67 typedef typename Traits::Type::Literal LiteralT;
68 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT; 68 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT;
69 69
70 ParserBase(Isolate* isolate, Zone* zone, Scanner* scanner, 70 ParserBase(Zone* zone, Scanner* scanner, uintptr_t stack_limit,
71 uintptr_t stack_limit, v8::Extension* extension, 71 v8::Extension* extension, AstValueFactory* ast_value_factory,
72 AstValueFactory* ast_value_factory, ParserRecorder* log, 72 ParserRecorder* log, typename Traits::Type::Parser this_object)
73 typename Traits::Type::Parser this_object)
74 : Traits(this_object), 73 : Traits(this_object),
75 parenthesized_function_(false), 74 parenthesized_function_(false),
76 scope_(NULL), 75 scope_(NULL),
77 function_state_(NULL), 76 function_state_(NULL),
78 extension_(extension), 77 extension_(extension),
79 fni_(NULL), 78 fni_(NULL),
80 ast_value_factory_(ast_value_factory), 79 ast_value_factory_(ast_value_factory),
81 log_(log), 80 log_(log),
82 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. 81 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly.
83 stack_limit_(stack_limit), 82 stack_limit_(stack_limit),
84 isolate_(isolate),
85 zone_(zone), 83 zone_(zone),
86 scanner_(scanner), 84 scanner_(scanner),
87 stack_overflow_(false), 85 stack_overflow_(false),
88 allow_lazy_(false), 86 allow_lazy_(false),
89 allow_natives_(false), 87 allow_natives_(false),
90 allow_harmony_arrow_functions_(false), 88 allow_harmony_arrow_functions_(false),
91 allow_harmony_object_literals_(false), 89 allow_harmony_object_literals_(false),
92 allow_harmony_sloppy_(false), 90 allow_harmony_sloppy_(false),
93 allow_harmony_computed_property_names_(false), 91 allow_harmony_computed_property_names_(false),
94 allow_harmony_rest_params_(false), 92 allow_harmony_rest_params_(false),
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 DCHECK((scope_type == FUNCTION_SCOPE && IsValidFunctionKind(kind)) || 309 DCHECK((scope_type == FUNCTION_SCOPE && IsValidFunctionKind(kind)) ||
312 kind == kNormalFunction); 310 kind == kNormalFunction);
313 Scope* result = 311 Scope* result =
314 new (zone()) Scope(zone(), parent, scope_type, ast_value_factory()); 312 new (zone()) Scope(zone(), parent, scope_type, ast_value_factory());
315 bool uninitialized_this = 313 bool uninitialized_this =
316 FLAG_experimental_classes && IsSubclassConstructor(kind); 314 FLAG_experimental_classes && IsSubclassConstructor(kind);
317 result->Initialize(uninitialized_this); 315 result->Initialize(uninitialized_this);
318 return result; 316 return result;
319 } 317 }
320 318
321 Isolate* isolate() const { return isolate_; }
322 Scanner* scanner() const { return scanner_; } 319 Scanner* scanner() const { return scanner_; }
323 AstValueFactory* ast_value_factory() const { return ast_value_factory_; } 320 AstValueFactory* ast_value_factory() const { return ast_value_factory_; }
324 int position() { return scanner_->location().beg_pos; } 321 int position() { return scanner_->location().beg_pos; }
325 int peek_position() { return scanner_->peek_location().beg_pos; } 322 int peek_position() { return scanner_->peek_location().beg_pos; }
326 bool stack_overflow() const { return stack_overflow_; } 323 bool stack_overflow() const { return stack_overflow_; }
327 void set_stack_overflow() { stack_overflow_ = true; } 324 void set_stack_overflow() { stack_overflow_ = true; }
328 Mode mode() const { return mode_; } 325 Mode mode() const { return mode_; }
329 Zone* zone() const { return zone_; } 326 Zone* zone() const { return zone_; }
330 327
331 INLINE(Token::Value peek()) { 328 INLINE(Token::Value peek()) {
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 Scope* scope_; // Scope stack. 642 Scope* scope_; // Scope stack.
646 FunctionState* function_state_; // Function state stack. 643 FunctionState* function_state_; // Function state stack.
647 v8::Extension* extension_; 644 v8::Extension* extension_;
648 FuncNameInferrer* fni_; 645 FuncNameInferrer* fni_;
649 AstValueFactory* ast_value_factory_; // Not owned. 646 AstValueFactory* ast_value_factory_; // Not owned.
650 ParserRecorder* log_; 647 ParserRecorder* log_;
651 Mode mode_; 648 Mode mode_;
652 uintptr_t stack_limit_; 649 uintptr_t stack_limit_;
653 650
654 private: 651 private:
655 Isolate* isolate_;
656 Zone* zone_; 652 Zone* zone_;
657 653
658 Scanner* scanner_; 654 Scanner* scanner_;
659 bool stack_overflow_; 655 bool stack_overflow_;
660 656
661 bool allow_lazy_; 657 bool allow_lazy_;
662 bool allow_natives_; 658 bool allow_natives_;
663 bool allow_harmony_arrow_functions_; 659 bool allow_harmony_arrow_functions_;
664 bool allow_harmony_object_literals_; 660 bool allow_harmony_object_literals_;
665 bool allow_harmony_sloppy_; 661 bool allow_harmony_sloppy_;
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 public: 1495 public:
1500 typedef PreParserIdentifier Identifier; 1496 typedef PreParserIdentifier Identifier;
1501 typedef PreParserExpression Expression; 1497 typedef PreParserExpression Expression;
1502 typedef PreParserStatement Statement; 1498 typedef PreParserStatement Statement;
1503 1499
1504 enum PreParseResult { 1500 enum PreParseResult {
1505 kPreParseStackOverflow, 1501 kPreParseStackOverflow,
1506 kPreParseSuccess 1502 kPreParseSuccess
1507 }; 1503 };
1508 1504
1509 PreParser(Isolate* isolate, Zone* zone, Scanner* scanner, 1505 PreParser(Zone* zone, Scanner* scanner, AstValueFactory* ast_value_factory,
1510 AstValueFactory* ast_value_factory, ParserRecorder* log, 1506 ParserRecorder* log, uintptr_t stack_limit)
1511 uintptr_t stack_limit) 1507 : ParserBase<PreParserTraits>(zone, scanner, stack_limit, NULL,
1512 : ParserBase<PreParserTraits>(isolate, zone, scanner, stack_limit, NULL,
1513 ast_value_factory, log, this) {} 1508 ast_value_factory, log, this) {}
1514 1509
1515 // Pre-parse the program from the character stream; returns true on 1510 // Pre-parse the program from the character stream; returns true on
1516 // success (even if parsing failed, the pre-parse data successfully 1511 // success (even if parsing failed, the pre-parse data successfully
1517 // captured the syntax error), and false if a stack-overflow happened 1512 // captured the syntax error), and false if a stack-overflow happened
1518 // during parsing. 1513 // during parsing.
1519 PreParseResult PreParseProgram(int* materialized_literals = 0) { 1514 PreParseResult PreParseProgram(int* materialized_literals = 0) {
1520 Scope* scope = NewScope(scope_, SCRIPT_SCOPE); 1515 Scope* scope = NewScope(scope_, SCRIPT_SCOPE);
1521 PreParserFactory factory(NULL); 1516 PreParserFactory factory(NULL);
1522 FunctionState top_scope(&function_state_, &scope_, scope, kNormalFunction, 1517 FunctionState top_scope(&function_state_, &scope_, scope, kNormalFunction,
(...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after
3060 *ok = false; 3055 *ok = false;
3061 return; 3056 return;
3062 } 3057 }
3063 has_seen_constructor_ = true; 3058 has_seen_constructor_ = true;
3064 return; 3059 return;
3065 } 3060 }
3066 } 3061 }
3067 } } // v8::internal 3062 } } // v8::internal
3068 3063
3069 #endif // V8_PREPARSER_H 3064 #endif // V8_PREPARSER_H
OLDNEW
« src/parser.cc ('K') | « src/parser.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698