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

Side by Side Diff: src/parser.cc

Issue 1087543004: [strong] Allow mutually recursive classes. (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 unified diff | Download patch
« no previous file with comments | « src/ast.h ('k') | src/scopes.cc » ('j') | no next file with comments »
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 // 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 1911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 // the caller's scope so we declare all locals, too. 1922 // the caller's scope so we declare all locals, too.
1923 if (declaration_scope->is_function_scope() || 1923 if (declaration_scope->is_function_scope() ||
1924 declaration_scope->is_strict_eval_scope() || 1924 declaration_scope->is_strict_eval_scope() ||
1925 declaration_scope->is_block_scope() || 1925 declaration_scope->is_block_scope() ||
1926 declaration_scope->is_module_scope() || 1926 declaration_scope->is_module_scope() ||
1927 declaration_scope->is_script_scope()) { 1927 declaration_scope->is_script_scope()) {
1928 // Declare the variable in the declaration scope. 1928 // Declare the variable in the declaration scope.
1929 var = declaration_scope->LookupLocal(name); 1929 var = declaration_scope->LookupLocal(name);
1930 if (var == NULL) { 1930 if (var == NULL) {
1931 // Declare the name. 1931 // Declare the name.
1932 Variable::Kind kind = Variable::NORMAL;
1933 if (declaration->IsFunctionDeclaration()) {
1934 kind = Variable::FUNCTION;
1935 } else if (declaration->IsVariableDeclaration() &&
1936 declaration->AsVariableDeclaration()->is_class_declaration()) {
1937 kind = Variable::CLASS;
1938 }
1932 var = declaration_scope->DeclareLocal( 1939 var = declaration_scope->DeclareLocal(
1933 name, mode, declaration->initialization(), 1940 name, mode, declaration->initialization(), kind, kNotAssigned);
1934 declaration->IsFunctionDeclaration() ? Variable::FUNCTION
1935 : Variable::NORMAL,
1936 kNotAssigned);
1937 } else if (IsLexicalVariableMode(mode) || 1941 } else if (IsLexicalVariableMode(mode) ||
1938 IsLexicalVariableMode(var->mode()) || 1942 IsLexicalVariableMode(var->mode()) ||
1939 ((mode == CONST_LEGACY || var->mode() == CONST_LEGACY) && 1943 ((mode == CONST_LEGACY || var->mode() == CONST_LEGACY) &&
1940 !declaration_scope->is_script_scope())) { 1944 !declaration_scope->is_script_scope())) {
1941 // The name was declared in this scope before; check for conflicting 1945 // The name was declared in this scope before; check for conflicting
1942 // re-declarations. We have a conflict if either of the declarations is 1946 // re-declarations. We have a conflict if either of the declarations is
1943 // not a var (in script scope, we also have to ignore legacy const for 1947 // not a var (in script scope, we also have to ignore legacy const for
1944 // compatibility). There is similar code in runtime.cc in the Declare 1948 // compatibility). There is similar code in runtime.cc in the Declare
1945 // functions. The function CheckConflictingVarDeclarations checks for 1949 // functions. The function CheckConflictingVarDeclarations checks for
1946 // var and let bindings from different scopes whereas this is a check for 1950 // var and let bindings from different scopes whereas this is a check for
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
2144 2148
2145 int pos = position(); 2149 int pos = position();
2146 bool is_strict_reserved = false; 2150 bool is_strict_reserved = false;
2147 const AstRawString* name = 2151 const AstRawString* name =
2148 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); 2152 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK);
2149 ClassLiteral* value = ParseClassLiteral(name, scanner()->location(), 2153 ClassLiteral* value = ParseClassLiteral(name, scanner()->location(),
2150 is_strict_reserved, pos, CHECK_OK); 2154 is_strict_reserved, pos, CHECK_OK);
2151 2155
2152 VariableMode mode = is_strong(language_mode()) ? CONST : LET; 2156 VariableMode mode = is_strong(language_mode()) ? CONST : LET;
2153 VariableProxy* proxy = NewUnresolved(name, mode); 2157 VariableProxy* proxy = NewUnresolved(name, mode);
2154 Declaration* declaration = 2158 const bool is_class_declaration = true;
2155 factory()->NewVariableDeclaration(proxy, mode, scope_, pos); 2159 Declaration* declaration = factory()->NewVariableDeclaration(
2160 proxy, mode, scope_, pos, is_class_declaration);
2156 Declare(declaration, true, CHECK_OK); 2161 Declare(declaration, true, CHECK_OK);
2157 proxy->var()->set_initializer_position(position()); 2162 proxy->var()->set_initializer_position(position());
2158 2163
2159 Token::Value init_op = 2164 Token::Value init_op =
2160 is_strong(language_mode()) ? Token::INIT_CONST : Token::INIT_LET; 2165 is_strong(language_mode()) ? Token::INIT_CONST : Token::INIT_LET;
2161 Assignment* assignment = factory()->NewAssignment(init_op, proxy, value, pos); 2166 Assignment* assignment = factory()->NewAssignment(init_op, proxy, value, pos);
2162 Statement* assignment_statement = 2167 Statement* assignment_statement =
2163 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); 2168 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition);
2164 if (names) names->Add(name, zone()); 2169 if (names) names->Add(name, zone());
2165 return assignment_statement; 2170 return assignment_statement;
(...skipping 3607 matching lines...) Expand 10 before | Expand all | Expand 10 after
5773 5778
5774 Expression* Parser::SpreadCallNew(Expression* function, 5779 Expression* Parser::SpreadCallNew(Expression* function,
5775 ZoneList<v8::internal::Expression*>* args, 5780 ZoneList<v8::internal::Expression*>* args,
5776 int pos) { 5781 int pos) {
5777 args->InsertAt(0, function, zone()); 5782 args->InsertAt(0, function, zone());
5778 5783
5779 return factory()->NewCallRuntime( 5784 return factory()->NewCallRuntime(
5780 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 5785 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
5781 } 5786 }
5782 } } // namespace v8::internal 5787 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698