Chromium Code Reviews| Index: runtime/vm/parser.cc |
| diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc |
| index a07921f84cd2cc2b83ce83d852d6296271f20c50..bfd20fed47e4783d80e046cbde47fd1bb4e55a0a 100644 |
| --- a/runtime/vm/parser.cc |
| +++ b/runtime/vm/parser.cc |
| @@ -7597,7 +7597,6 @@ AstNode* Parser::ParseVariableDeclarationList() { |
| AstNode* Parser::ParseFunctionStatement(bool is_literal) { |
| TRACE_PARSER("ParseFunctionStatement"); |
| AbstractType& result_type = AbstractType::Handle(Z); |
| - const String* variable_name = NULL; |
|
Kevin Millikin (Google)
2016/05/27 14:07:36
If is_literal, variable_name is always NULL. If !
|
| const String* function_name = NULL; |
| result_type = Type::DynamicType(); |
| @@ -7617,8 +7616,7 @@ AstNode* Parser::ParseFunctionStatement(bool is_literal) { |
| result_type = ParseType(ClassFinalizer::kCanonicalize); |
| } |
| const TokenPosition name_pos = TokenPos(); |
| - variable_name = ExpectIdentifier("function name expected"); |
| - function_name = variable_name; |
| + function_name = ExpectIdentifier("function name expected"); |
| // Check that the function name has not been referenced |
| // before this declaration. |
| @@ -7666,7 +7664,7 @@ AstNode* Parser::ParseFunctionStatement(bool is_literal) { |
| LocalVariable* function_variable = NULL; |
| Type& function_type = Type::ZoneHandle(Z); |
| - if (variable_name != NULL) { |
| + if (!is_literal) { |
| // Since the function type depends on the signature of the closure function, |
| // it cannot be determined before the formal parameter list of the closure |
| // function is parsed. Therefore, we set the function type to a new |
| @@ -7683,7 +7681,7 @@ AstNode* Parser::ParseFunctionStatement(bool is_literal) { |
| // Add the function variable to the scope before parsing the function in |
| // order to allow self reference from inside the function. |
| function_variable = new(Z) LocalVariable(function_pos, |
| - *variable_name, |
| + *function_name, |
| function_type); |
| function_variable->set_is_final(); |
| ASSERT(current_block_ != NULL); |
| @@ -7727,7 +7725,7 @@ AstNode* Parser::ParseFunctionStatement(bool is_literal) { |
| ASSERT(!signature_type.IsMalformed()); |
| ASSERT(!signature_type.IsMalbounded()); |
| - if (variable_name != NULL) { |
| + if (!is_literal) { |
| // Patch the function type of the variable now that the signature is known. |
| function_type.set_type_class( |
| Class::Handle(Z, signature_type.type_class())); |
| @@ -7740,8 +7738,7 @@ AstNode* Parser::ParseFunctionStatement(bool is_literal) { |
| function_type.ResetIsFinalized(); |
| // The function variable type should have been patched above. |
| - ASSERT((function_variable == NULL) || |
| - (function_variable->type().raw() == function_type.raw())); |
| + ASSERT(function_variable->type().raw() == function_type.raw()); |
| } |
| // The code generator does not compile the closure function when visiting |
| @@ -7766,14 +7763,9 @@ AstNode* Parser::ParseFunctionStatement(bool is_literal) { |
| AstNode* closure = new(Z) ClosureNode( |
| function_pos, function, NULL, statements->scope()); |
| - if (function_variable == NULL) { |
| - ASSERT(is_literal); |
| - return closure; |
| - } else { |
| - AstNode* initialization = new(Z) StoreLocalNode( |
| - function_pos, function_variable, closure); |
| - return initialization; |
| - } |
| + return is_literal |
| + ? closure |
| + : new(Z) StoreLocalNode(function_pos, function_variable, closure); |
| } |
| @@ -13851,11 +13843,7 @@ AstNode* Parser::ParsePrimary() { |
| AstNode* primary = NULL; |
| const Token::Kind token = CurrentToken(); |
| if (IsFunctionLiteral()) { |
| - // The name of a literal function is visible from inside the function, but |
| - // must not collide with names in the scope declaring the literal. |
| - OpenBlock(); |
| primary = ParseFunctionStatement(true); |
| - CloseBlock(); |
| } else if (IsIdentifier()) { |
| TokenPosition qual_ident_pos = TokenPos(); |
| const LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(Z, ParsePrefix()); |