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

Side by Side Diff: src/parsing/parser.cc

Issue 2324783002: Include only stuff you need, part 9: variables.h (Closed)
Patch Set: rebased Created 4 years, 3 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/parsing/parser.h ('k') | test/cctest/asmjs/test-asm-typer.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/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/ast/ast-expression-rewriter.h" 10 #include "src/ast/ast-expression-rewriter.h"
(...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 for (int i = 0; i < names.length(); ++i) { 1401 for (int i = 0; i < names.length(); ++i) {
1402 // TODO(neis): Provide better location. 1402 // TODO(neis): Provide better location.
1403 descriptor->AddExport(names[i], names[i], scanner()->location(), zone()); 1403 descriptor->AddExport(names[i], names[i], scanner()->location(), zone());
1404 } 1404 }
1405 1405
1406 DCHECK_NOT_NULL(result); 1406 DCHECK_NOT_NULL(result);
1407 return result; 1407 return result;
1408 } 1408 }
1409 1409
1410 VariableProxy* Parser::NewUnresolved(const AstRawString* name, int begin_pos, 1410 VariableProxy* Parser::NewUnresolved(const AstRawString* name, int begin_pos,
1411 int end_pos, Variable::Kind kind) { 1411 int end_pos, VariableKind kind) {
1412 return scope()->NewUnresolved(factory(), name, begin_pos, end_pos, kind); 1412 return scope()->NewUnresolved(factory(), name, begin_pos, end_pos, kind);
1413 } 1413 }
1414 1414
1415 VariableProxy* Parser::NewUnresolved(const AstRawString* name) { 1415 VariableProxy* Parser::NewUnresolved(const AstRawString* name) {
1416 return scope()->NewUnresolved(factory(), name, scanner()->location().beg_pos, 1416 return scope()->NewUnresolved(factory(), name, scanner()->location().beg_pos,
1417 scanner()->location().end_pos); 1417 scanner()->location().end_pos);
1418 } 1418 }
1419 1419
1420 Declaration* Parser::DeclareVariable(const AstRawString* name, 1420 Declaration* Parser::DeclareVariable(const AstRawString* name,
1421 VariableMode mode, int pos, bool* ok) { 1421 VariableMode mode, int pos, bool* ok) {
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 const AstRawString* name = ast_value_factory()->dot_catch_string(); 2140 const AstRawString* name = ast_value_factory()->dot_catch_string();
2141 Expression* pattern = nullptr; 2141 Expression* pattern = nullptr;
2142 if (peek_any_identifier()) { 2142 if (peek_any_identifier()) {
2143 name = ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK); 2143 name = ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK);
2144 } else { 2144 } else {
2145 ExpressionClassifier pattern_classifier(this); 2145 ExpressionClassifier pattern_classifier(this);
2146 pattern = ParsePrimaryExpression(CHECK_OK); 2146 pattern = ParsePrimaryExpression(CHECK_OK);
2147 ValidateBindingPattern(CHECK_OK); 2147 ValidateBindingPattern(CHECK_OK);
2148 } 2148 }
2149 catch_variable = catch_scope->DeclareLocal( 2149 catch_variable = catch_scope->DeclareLocal(
2150 name, VAR, kCreatedInitialized, Variable::NORMAL); 2150 name, VAR, kCreatedInitialized, NORMAL_VARIABLE);
2151 2151
2152 Expect(Token::RPAREN, CHECK_OK); 2152 Expect(Token::RPAREN, CHECK_OK);
2153 2153
2154 ZoneList<const AstRawString*> bound_names(1, zone()); 2154 ZoneList<const AstRawString*> bound_names(1, zone());
2155 if (pattern != nullptr) { 2155 if (pattern != nullptr) {
2156 DeclarationDescriptor descriptor; 2156 DeclarationDescriptor descriptor;
2157 descriptor.declaration_kind = DeclarationDescriptor::NORMAL; 2157 descriptor.declaration_kind = DeclarationDescriptor::NORMAL;
2158 descriptor.scope = scope(); 2158 descriptor.scope = scope();
2159 descriptor.hoist_scope = nullptr; 2159 descriptor.hoist_scope = nullptr;
2160 descriptor.mode = LET; 2160 descriptor.mode = LET;
(...skipping 1648 matching lines...) Expand 10 before | Expand all | Expand 10 after
3809 BuildDotDebugIsActive(), debug_push_promise, 3809 BuildDotDebugIsActive(), debug_push_promise,
3810 factory()->NewEmptyStatement(kNoSourcePosition), kNoSourcePosition); 3810 factory()->NewEmptyStatement(kNoSourcePosition), kNoSourcePosition);
3811 } 3811 }
3812 result->statements()->Add(conditionally_debug_push_promise, zone()); 3812 result->statements()->Add(conditionally_debug_push_promise, zone());
3813 3813
3814 // catch (.catch) { return %RejectPromise(.promise, .catch), .promise } 3814 // catch (.catch) { return %RejectPromise(.promise, .catch), .promise }
3815 Scope* catch_scope = NewScope(CATCH_SCOPE); 3815 Scope* catch_scope = NewScope(CATCH_SCOPE);
3816 catch_scope->set_is_hidden(); 3816 catch_scope->set_is_hidden();
3817 Variable* catch_variable = 3817 Variable* catch_variable =
3818 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR, 3818 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR,
3819 kCreatedInitialized, Variable::NORMAL); 3819 kCreatedInitialized, NORMAL_VARIABLE);
3820 Block* catch_block = factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); 3820 Block* catch_block = factory()->NewBlock(nullptr, 1, true, kNoSourcePosition);
3821 3821
3822 Expression* promise_reject = BuildRejectPromise( 3822 Expression* promise_reject = BuildRejectPromise(
3823 factory()->NewVariableProxy(catch_variable), kNoSourcePosition); 3823 factory()->NewVariableProxy(catch_variable), kNoSourcePosition);
3824 ReturnStatement* return_promise_reject = 3824 ReturnStatement* return_promise_reject =
3825 factory()->NewReturnStatement(promise_reject, kNoSourcePosition); 3825 factory()->NewReturnStatement(promise_reject, kNoSourcePosition);
3826 catch_block->statements()->Add(return_promise_reject, zone()); 3826 catch_block->statements()->Add(return_promise_reject, zone());
3827 3827
3828 TryStatement* try_catch_statement = factory()->NewTryCatchStatement( 3828 TryStatement* try_catch_statement = factory()->NewTryCatchStatement(
3829 inner_block, catch_scope, catch_variable, catch_block, kNoSourcePosition); 3829 inner_block, catch_scope, catch_variable, catch_block, kNoSourcePosition);
(...skipping 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after
5426 Block* try_block = factory()->NewBlock(nullptr, 2, false, nopos); 5426 Block* try_block = factory()->NewBlock(nullptr, 2, false, nopos);
5427 try_block->statements()->Add(yield_output, zone()); 5427 try_block->statements()->Add(yield_output, zone());
5428 try_block->statements()->Add(set_mode_next, zone()); 5428 try_block->statements()->Add(set_mode_next, zone());
5429 5429
5430 Block* catch_block = factory()->NewBlock(nullptr, 1, false, nopos); 5430 Block* catch_block = factory()->NewBlock(nullptr, 1, false, nopos);
5431 catch_block->statements()->Add(set_mode_throw, zone()); 5431 catch_block->statements()->Add(set_mode_throw, zone());
5432 5432
5433 Scope* catch_scope = NewScope(CATCH_SCOPE); 5433 Scope* catch_scope = NewScope(CATCH_SCOPE);
5434 catch_scope->set_is_hidden(); 5434 catch_scope->set_is_hidden();
5435 const AstRawString* name = ast_value_factory()->dot_catch_string(); 5435 const AstRawString* name = ast_value_factory()->dot_catch_string();
5436 Variable* catch_variable = 5436 Variable* catch_variable = catch_scope->DeclareLocal(
5437 catch_scope->DeclareLocal(name, VAR, kCreatedInitialized, 5437 name, VAR, kCreatedInitialized, NORMAL_VARIABLE);
5438 Variable::NORMAL);
5439 5438
5440 try_catch = factory()->NewTryCatchStatementForDesugaring( 5439 try_catch = factory()->NewTryCatchStatementForDesugaring(
5441 try_block, catch_scope, catch_variable, catch_block, nopos); 5440 try_block, catch_scope, catch_variable, catch_block, nopos);
5442 } 5441 }
5443 5442
5444 // try { ... } finally { ... } 5443 // try { ... } finally { ... }
5445 Statement* try_finally; 5444 Statement* try_finally;
5446 { 5445 {
5447 Block* try_block = factory()->NewBlock(nullptr, 1, false, nopos); 5446 Block* try_block = factory()->NewBlock(nullptr, 1, false, nopos);
5448 try_block->statements()->Add(try_catch, zone()); 5447 try_block->statements()->Add(try_catch, zone());
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
5715 // try { #try_block } 5714 // try { #try_block }
5716 // catch(e) { 5715 // catch(e) {
5717 // #set_completion_throw; 5716 // #set_completion_throw;
5718 // %ReThrow(e); 5717 // %ReThrow(e);
5719 // } 5718 // }
5720 Statement* try_catch; 5719 Statement* try_catch;
5721 { 5720 {
5722 Scope* catch_scope = NewScopeWithParent(scope(), CATCH_SCOPE); 5721 Scope* catch_scope = NewScopeWithParent(scope(), CATCH_SCOPE);
5723 Variable* catch_variable = 5722 Variable* catch_variable =
5724 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR, 5723 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR,
5725 kCreatedInitialized, Variable::NORMAL); 5724 kCreatedInitialized, NORMAL_VARIABLE);
5726 catch_scope->set_is_hidden(); 5725 catch_scope->set_is_hidden();
5727 5726
5728 Statement* rethrow; 5727 Statement* rethrow;
5729 // We use %ReThrow rather than the ordinary throw because we want to 5728 // We use %ReThrow rather than the ordinary throw because we want to
5730 // preserve the original exception message. This is also why we create a 5729 // preserve the original exception message. This is also why we create a
5731 // TryCatchStatementForReThrow below (which does not clear the pending 5730 // TryCatchStatementForReThrow below (which does not clear the pending
5732 // message), rather than a TryCatchStatement. 5731 // message), rather than a TryCatchStatement.
5733 { 5732 {
5734 auto args = new (zone()) ZoneList<Expression*>(1, zone()); 5733 auto args = new (zone()) ZoneList<Expression*>(1, zone());
5735 args->Add(factory()->NewVariableProxy(catch_variable), zone()); 5734 args->Add(factory()->NewVariableProxy(catch_variable), zone());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
5821 5820
5822 Block* try_block = factory()->NewBlock(nullptr, 1, false, nopos); 5821 Block* try_block = factory()->NewBlock(nullptr, 1, false, nopos);
5823 try_block->statements()->Add(factory()->NewExpressionStatement(call, nopos), 5822 try_block->statements()->Add(factory()->NewExpressionStatement(call, nopos),
5824 zone()); 5823 zone());
5825 5824
5826 Block* catch_block = factory()->NewBlock(nullptr, 0, false, nopos); 5825 Block* catch_block = factory()->NewBlock(nullptr, 0, false, nopos);
5827 5826
5828 Scope* catch_scope = NewScope(CATCH_SCOPE); 5827 Scope* catch_scope = NewScope(CATCH_SCOPE);
5829 Variable* catch_variable = 5828 Variable* catch_variable =
5830 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR, 5829 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR,
5831 kCreatedInitialized, Variable::NORMAL); 5830 kCreatedInitialized, NORMAL_VARIABLE);
5832 catch_scope->set_is_hidden(); 5831 catch_scope->set_is_hidden();
5833 5832
5834 try_call_return = factory()->NewTryCatchStatement( 5833 try_call_return = factory()->NewTryCatchStatement(
5835 try_block, catch_scope, catch_variable, catch_block, nopos); 5834 try_block, catch_scope, catch_variable, catch_block, nopos);
5836 } 5835 }
5837 5836
5838 // let output = %_Call(iteratorReturn, iterator); 5837 // let output = %_Call(iteratorReturn, iterator);
5839 // if (!IS_RECEIVER(output)) { 5838 // if (!IS_RECEIVER(output)) {
5840 // %ThrowIteratorResultNotAnObject(output); 5839 // %ThrowIteratorResultNotAnObject(output);
5841 // } 5840 // }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
5975 node->Print(Isolate::Current()); 5974 node->Print(Isolate::Current());
5976 } 5975 }
5977 #endif // DEBUG 5976 #endif // DEBUG
5978 5977
5979 #undef CHECK_OK 5978 #undef CHECK_OK
5980 #undef CHECK_OK_VOID 5979 #undef CHECK_OK_VOID
5981 #undef CHECK_FAILED 5980 #undef CHECK_FAILED
5982 5981
5983 } // namespace internal 5982 } // namespace internal
5984 } // namespace v8 5983 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser.h ('k') | test/cctest/asmjs/test-asm-typer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698