Chromium Code Reviews| Index: src/parser.cc |
| diff --git a/src/parser.cc b/src/parser.cc |
| index dc5c7d6b5e4cb4bb7c96919282c9f10b3c25985f..c549094a30de3b944a88115cc41f3ccc4806f9b2 100644 |
| --- a/src/parser.cc |
| +++ b/src/parser.cc |
| @@ -659,8 +659,9 @@ FunctionLiteral* Parser::DoParseProgram(Handle<String> source, |
| 0, |
| 0, |
| source->length(), |
| - false, |
| - false); |
| + true, // is_expression |
|
Vyacheslav Egorov (Chromium)
2011/08/09 12:24:57
Can we change it to pass FunctionLiteralType inste
Kevin Millikin (Chromium)
2011/08/09 12:42:52
Good idea. Done. I had to move it to ast to avoi
|
| + true, // is_anonymous |
| + false); // has_duplicate_parameters |
| } else if (stack_overflow_) { |
| isolate()->StackOverflow(); |
| } |
| @@ -729,12 +730,13 @@ FunctionLiteral* Parser::ParseLazy(CompilationInfo* info, |
| top_scope_->EnableStrictMode(); |
| } |
| - FunctionLiteralType type = |
| - shared_info->is_expression() ? EXPRESSION : DECLARATION; |
| - Handle<String> function_name = |
| - shared_info->is_anonymous() ? Handle<String>::null() : name; |
| + FunctionLiteralType type = shared_info->is_expression() |
| + ? (shared_info->is_anonymous() |
| + ? ANONYMOUS_EXPRESSION |
| + : NAMED_EXPRESSION) |
| + : DECLARATION; |
| bool ok = true; |
| - result = ParseFunctionLiteral(function_name, |
| + result = ParseFunctionLiteral(name, |
| false, // Strict mode name already checked. |
| RelocInfo::kNoPosition, |
| type, |
| @@ -2846,10 +2848,12 @@ Expression* Parser::ParseMemberWithNewPrefixesExpression(PositionStack* stack, |
| name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name, |
| CHECK_OK); |
| } |
| + FunctionLiteralType type = |
| + name.is_null() ? ANONYMOUS_EXPRESSION : NAMED_EXPRESSION; |
| result = ParseFunctionLiteral(name, |
| is_strict_reserved_name, |
| function_token_position, |
| - EXPRESSION, |
| + type, |
| CHECK_OK); |
| } else { |
| result = ParsePrimaryExpression(CHECK_OK); |
| @@ -3419,7 +3423,7 @@ ObjectLiteral::Property* Parser::ParseObjectLiteralGetSet(bool is_getter, |
| ParseFunctionLiteral(name, |
| false, // reserved words are allowed here |
| RelocInfo::kNoPosition, |
| - EXPRESSION, |
| + ANONYMOUS_EXPRESSION, |
| CHECK_OK); |
| // Allow any number of parameters for compatiabilty with JSC. |
| // Specification only allows zero parameters for get and one for set. |
| @@ -3709,7 +3713,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name, |
| // NOTE: We create a proxy and resolve it here so that in the |
| // future we can change the AST to only refer to VariableProxies |
| // instead of Variables and Proxis as is the case now. |
| - if (type == EXPRESSION && function_name->length() > 0) { |
| + if (type == NAMED_EXPRESSION) { |
| Variable* fvar = top_scope_->DeclareFunctionVar(function_name); |
| VariableProxy* fproxy = |
| top_scope_->NewUnresolved(function_name, inside_with()); |
| @@ -3827,7 +3831,8 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name, |
| num_parameters, |
| start_pos, |
| end_pos, |
| - type == EXPRESSION, |
| + type != DECLARATION, |
|
Vyacheslav Egorov (Chromium)
2011/08/09 12:24:57
Ditto.
Vyacheslav Egorov (Chromium)
2011/08/09 12:24:57
Ditto.
|
| + type == ANONYMOUS_EXPRESSION, |
| has_duplicate_parameters); |
| function_literal->set_function_token_position(function_token_position); |