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

Unified Diff: src/preparser.h

Issue 1060913005: [strong] Stricter check for referring to other classes inside methods. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: . Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index 0440d831eea5105552c2c268534faead9ff44f0e..2e6e9ddf31b5a12c30ef5e8e15d44b4bcf397151 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -238,6 +238,14 @@ class ParserBase : public Traits {
typename Traits::Type::Factory* factory() { return factory_; }
+ void set_consecutive_class_declaration_batch_start(int position) {
+ consecutive_class_declaration_batch_start_ = position;
+ }
+
+ int consecutive_class_declaration_batch_start() const {
+ return consecutive_class_declaration_batch_start_;
+ }
+
private:
// Used to assign an index to each literal that needs materialization in
// the function. Includes regexp literals, and boilerplate for object and
@@ -267,6 +275,9 @@ class ParserBase : public Traits {
Scope** scope_stack_;
Scope* outer_scope_;
typename Traits::Type::Factory* factory_;
+ // For tracking which classes are declared consecutively. Needed for strong
+ // mode.
+ int consecutive_class_declaration_batch_start_;
friend class ParserTraits;
friend class Checkpoint;
@@ -1632,6 +1643,7 @@ class PreParser : public ParserBase<PreParserTraits> {
&factory);
bool ok = true;
int start_position = scanner()->peek_location().beg_pos;
+ top_scope.set_consecutive_class_declaration_batch_start(start_position);
ParseStatementList(Token::EOS, &ok);
if (stack_overflow()) return kPreParseStackOverflow;
if (!ok) {
@@ -1784,7 +1796,8 @@ ParserBase<Traits>::FunctionState::FunctionState(
outer_function_state_(*function_state_stack),
scope_stack_(scope_stack),
outer_scope_(*scope_stack),
- factory_(factory) {
+ factory_(factory),
+ consecutive_class_declaration_batch_start_(scope->start_position()) {
*scope_stack_ = scope;
*function_state_stack = this;
}
@@ -3092,6 +3105,8 @@ ParserBase<Traits>::ParseArrowFunctionLiteral(int start_pos,
Expect(Token::ARROW, CHECK_OK);
+ function_state.set_consecutive_class_declaration_batch_start(
+ scanner()->location().beg_pos);
if (peek() == Token::LBRACE) {
// Multiple statement body
Consume(Token::LBRACE);

Powered by Google App Engine
This is Rietveld 408576698