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

Side by Side Diff: src/parser.cc

Issue 177683002: Mode clean-up pt 1: rename classic/non-strict mode to sloppy mode (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 Handle<String> no_name = isolate()->factory()->empty_string(); 675 Handle<String> no_name = isolate()->factory()->empty_string();
676 676
677 FunctionLiteral* result = NULL; 677 FunctionLiteral* result = NULL;
678 { Scope* scope = NewScope(scope_, GLOBAL_SCOPE); 678 { Scope* scope = NewScope(scope_, GLOBAL_SCOPE);
679 info->SetGlobalScope(scope); 679 info->SetGlobalScope(scope);
680 if (!info->context().is_null()) { 680 if (!info->context().is_null()) {
681 scope = Scope::DeserializeScopeChain(*info->context(), scope, zone()); 681 scope = Scope::DeserializeScopeChain(*info->context(), scope, zone());
682 } 682 }
683 original_scope_ = scope; 683 original_scope_ = scope;
684 if (info->is_eval()) { 684 if (info->is_eval()) {
685 if (!scope->is_global_scope() || info->language_mode() != CLASSIC_MODE) { 685 if (!scope->is_global_scope() || info->language_mode() != SLOPPY_MODE) {
686 scope = NewScope(scope, EVAL_SCOPE); 686 scope = NewScope(scope, EVAL_SCOPE);
687 } 687 }
688 } else if (info->is_global()) { 688 } else if (info->is_global()) {
689 scope = NewScope(scope, GLOBAL_SCOPE); 689 scope = NewScope(scope, GLOBAL_SCOPE);
690 } 690 }
691 scope->set_start_position(0); 691 scope->set_start_position(0);
692 scope->set_end_position(source->length()); 692 scope->set_end_position(source->length());
693 693
694 // Compute the parsing mode. 694 // Compute the parsing mode.
695 Mode mode = (FLAG_lazy && allow_lazy()) ? PARSE_LAZILY : PARSE_EAGERLY; 695 Mode mode = (FLAG_lazy && allow_lazy()) ? PARSE_LAZILY : PARSE_EAGERLY;
696 if (allow_natives_syntax() || 696 if (allow_natives_syntax() ||
697 extension_ != NULL || 697 extension_ != NULL ||
698 scope->is_eval_scope()) { 698 scope->is_eval_scope()) {
699 mode = PARSE_EAGERLY; 699 mode = PARSE_EAGERLY;
700 } 700 }
701 ParsingModeScope parsing_mode(this, mode); 701 ParsingModeScope parsing_mode(this, mode);
702 702
703 // Enters 'scope'. 703 // Enters 'scope'.
704 FunctionState function_state(&function_state_, &scope_, scope, zone()); 704 FunctionState function_state(&function_state_, &scope_, scope, zone());
705 705
706 scope_->SetLanguageMode(info->language_mode()); 706 scope_->SetLanguageMode(info->language_mode());
707 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); 707 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone());
708 bool ok = true; 708 bool ok = true;
709 int beg_pos = scanner()->location().beg_pos; 709 int beg_pos = scanner()->location().beg_pos;
710 ParseSourceElements(body, Token::EOS, info->is_eval(), true, &ok); 710 ParseSourceElements(body, Token::EOS, info->is_eval(), true, &ok);
711 if (ok && !scope_->is_classic_mode()) { 711 if (ok && !scope_->is_sloppy_mode()) {
712 CheckOctalLiteral(beg_pos, scanner()->location().end_pos, &ok); 712 CheckOctalLiteral(beg_pos, scanner()->location().end_pos, &ok);
713 } 713 }
714 714
715 if (ok && is_extended_mode()) { 715 if (ok && is_extended_mode()) {
716 CheckConflictingVarDeclarations(scope_, &ok); 716 CheckConflictingVarDeclarations(scope_, &ok);
717 } 717 }
718 718
719 if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) { 719 if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) {
720 if (body->length() != 1 || 720 if (body->length() != 1 ||
721 !body->at(0)->IsExpressionStatement() || 721 !body->at(0)->IsExpressionStatement() ||
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 { 810 {
811 // Parse the function literal. 811 // Parse the function literal.
812 Scope* scope = NewScope(scope_, GLOBAL_SCOPE); 812 Scope* scope = NewScope(scope_, GLOBAL_SCOPE);
813 info()->SetGlobalScope(scope); 813 info()->SetGlobalScope(scope);
814 if (!info()->closure().is_null()) { 814 if (!info()->closure().is_null()) {
815 scope = Scope::DeserializeScopeChain(info()->closure()->context(), scope, 815 scope = Scope::DeserializeScopeChain(info()->closure()->context(), scope,
816 zone()); 816 zone());
817 } 817 }
818 original_scope_ = scope; 818 original_scope_ = scope;
819 FunctionState function_state(&function_state_, &scope_, scope, zone()); 819 FunctionState function_state(&function_state_, &scope_, scope, zone());
820 ASSERT(scope->language_mode() != STRICT_MODE || !info()->is_classic_mode()); 820 ASSERT(scope->language_mode() != STRICT_MODE || !info()->is_sloppy_mode());
821 ASSERT(scope->language_mode() != EXTENDED_MODE || 821 ASSERT(scope->language_mode() != EXTENDED_MODE ||
822 info()->is_extended_mode()); 822 info()->is_extended_mode());
823 ASSERT(info()->language_mode() == shared_info->language_mode()); 823 ASSERT(info()->language_mode() == shared_info->language_mode());
824 scope->SetLanguageMode(shared_info->language_mode()); 824 scope->SetLanguageMode(shared_info->language_mode());
825 FunctionLiteral::FunctionType function_type = shared_info->is_expression() 825 FunctionLiteral::FunctionType function_type = shared_info->is_expression()
826 ? (shared_info->is_anonymous() 826 ? (shared_info->is_anonymous()
827 ? FunctionLiteral::ANONYMOUS_EXPRESSION 827 ? FunctionLiteral::ANONYMOUS_EXPRESSION
828 : FunctionLiteral::NAMED_EXPRESSION) 828 : FunctionLiteral::NAMED_EXPRESSION)
829 : FunctionLiteral::DECLARATION; 829 : FunctionLiteral::DECLARATION;
830 bool ok = true; 830 bool ok = true;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 // A shot at a directive. 890 // A shot at a directive.
891 ExpressionStatement* e_stat; 891 ExpressionStatement* e_stat;
892 Literal* literal; 892 Literal* literal;
893 // Still processing directive prologue? 893 // Still processing directive prologue?
894 if ((e_stat = stat->AsExpressionStatement()) != NULL && 894 if ((e_stat = stat->AsExpressionStatement()) != NULL &&
895 (literal = e_stat->expression()->AsLiteral()) != NULL && 895 (literal = e_stat->expression()->AsLiteral()) != NULL &&
896 literal->value()->IsString()) { 896 literal->value()->IsString()) {
897 Handle<String> directive = Handle<String>::cast(literal->value()); 897 Handle<String> directive = Handle<String>::cast(literal->value());
898 898
899 // Check "use strict" directive (ES5 14.1). 899 // Check "use strict" directive (ES5 14.1).
900 if (scope_->is_classic_mode() && 900 if (scope_->is_sloppy_mode() &&
901 directive->Equals(isolate()->heap()->use_strict_string()) && 901 directive->Equals(isolate()->heap()->use_strict_string()) &&
902 token_loc.end_pos - token_loc.beg_pos == 902 token_loc.end_pos - token_loc.beg_pos ==
903 isolate()->heap()->use_strict_string()->length() + 2) { 903 isolate()->heap()->use_strict_string()->length() + 2) {
904 // TODO(mstarzinger): Global strict eval calls, need their own scope 904 // TODO(mstarzinger): Global strict eval calls, need their own scope
905 // as specified in ES5 10.4.2(3). The correct fix would be to always 905 // as specified in ES5 10.4.2(3). The correct fix would be to always
906 // add this scope in DoParseProgram(), but that requires adaptations 906 // add this scope in DoParseProgram(), but that requires adaptations
907 // all over the code base, so we go with a quick-fix for now. 907 // all over the code base, so we go with a quick-fix for now.
908 // In the same manner, we have to patch the parsing mode. 908 // In the same manner, we have to patch the parsing mode.
909 if (is_eval && !scope_->is_eval_scope()) { 909 if (is_eval && !scope_->is_eval_scope()) {
910 ASSERT(scope_->is_global_scope()); 910 ASSERT(scope_->is_global_scope());
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 // (Ecma 262 5th Edition, clause 14): 1436 // (Ecma 262 5th Edition, clause 14):
1437 // SourceElement: 1437 // SourceElement:
1438 // Statement 1438 // Statement
1439 // FunctionDeclaration 1439 // FunctionDeclaration
1440 // Common language extension is to allow function declaration in place 1440 // Common language extension is to allow function declaration in place
1441 // of any statement. This language extension is disabled in strict mode. 1441 // of any statement. This language extension is disabled in strict mode.
1442 // 1442 //
1443 // In Harmony mode, this case also handles the extension: 1443 // In Harmony mode, this case also handles the extension:
1444 // Statement: 1444 // Statement:
1445 // GeneratorDeclaration 1445 // GeneratorDeclaration
1446 if (!scope_->is_classic_mode()) { 1446 if (!scope_->is_sloppy_mode()) {
1447 ReportMessageAt(scanner()->peek_location(), "strict_function"); 1447 ReportMessageAt(scanner()->peek_location(), "strict_function");
1448 *ok = false; 1448 *ok = false;
1449 return NULL; 1449 return NULL;
1450 } 1450 }
1451 return ParseFunctionDeclaration(NULL, ok); 1451 return ParseFunctionDeclaration(NULL, ok);
1452 } 1452 }
1453 1453
1454 case Token::DEBUGGER: 1454 case Token::DEBUGGER:
1455 return ParseDebuggerStatement(ok); 1455 return ParseDebuggerStatement(ok);
1456 1456
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 declaration_scope->AddDeclaration(declaration); 1560 declaration_scope->AddDeclaration(declaration);
1561 1561
1562 if (mode == CONST && declaration_scope->is_global_scope()) { 1562 if (mode == CONST && declaration_scope->is_global_scope()) {
1563 // For global const variables we bind the proxy to a variable. 1563 // For global const variables we bind the proxy to a variable.
1564 ASSERT(resolve); // should be set by all callers 1564 ASSERT(resolve); // should be set by all callers
1565 Variable::Kind kind = Variable::NORMAL; 1565 Variable::Kind kind = Variable::NORMAL;
1566 var = new(zone()) Variable( 1566 var = new(zone()) Variable(
1567 declaration_scope, name, mode, true, kind, 1567 declaration_scope, name, mode, true, kind,
1568 kNeedsInitialization, proxy->interface()); 1568 kNeedsInitialization, proxy->interface());
1569 } else if (declaration_scope->is_eval_scope() && 1569 } else if (declaration_scope->is_eval_scope() &&
1570 declaration_scope->is_classic_mode()) { 1570 declaration_scope->is_sloppy_mode()) {
1571 // For variable declarations in a non-strict eval scope the proxy is bound 1571 // For variable declarations in a sloppy eval scope the proxy is bound
1572 // to a lookup variable to force a dynamic declaration using the 1572 // to a lookup variable to force a dynamic declaration using the
1573 // DeclareContextSlot runtime function. 1573 // DeclareContextSlot runtime function.
1574 Variable::Kind kind = Variable::NORMAL; 1574 Variable::Kind kind = Variable::NORMAL;
1575 var = new(zone()) Variable( 1575 var = new(zone()) Variable(
1576 declaration_scope, name, mode, true, kind, 1576 declaration_scope, name, mode, true, kind,
1577 declaration->initialization(), proxy->interface()); 1577 declaration->initialization(), proxy->interface());
1578 var->AllocateTo(Variable::LOOKUP, -1); 1578 var->AllocateTo(Variable::LOOKUP, -1);
1579 resolve = true; 1579 resolve = true;
1580 } 1580 }
1581 1581
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1819 if (peek() == Token::VAR) { 1819 if (peek() == Token::VAR) {
1820 Consume(Token::VAR); 1820 Consume(Token::VAR);
1821 } else if (peek() == Token::CONST) { 1821 } else if (peek() == Token::CONST) {
1822 // TODO(ES6): The ES6 Draft Rev4 section 12.2.2 reads: 1822 // TODO(ES6): The ES6 Draft Rev4 section 12.2.2 reads:
1823 // 1823 //
1824 // ConstDeclaration : const ConstBinding (',' ConstBinding)* ';' 1824 // ConstDeclaration : const ConstBinding (',' ConstBinding)* ';'
1825 // 1825 //
1826 // * It is a Syntax Error if the code that matches this production is not 1826 // * It is a Syntax Error if the code that matches this production is not
1827 // contained in extended code. 1827 // contained in extended code.
1828 // 1828 //
1829 // However disallowing const in classic mode will break compatibility with 1829 // However disallowing const in sloppy mode will break compatibility with
1830 // existing pages. Therefore we keep allowing const with the old 1830 // existing pages. Therefore we keep allowing const with the old
1831 // non-harmony semantics in classic mode. 1831 // non-harmony semantics in sloppy mode.
1832 Consume(Token::CONST); 1832 Consume(Token::CONST);
1833 switch (scope_->language_mode()) { 1833 switch (scope_->language_mode()) {
1834 case CLASSIC_MODE: 1834 case SLOPPY_MODE:
1835 mode = CONST; 1835 mode = CONST;
1836 init_op = Token::INIT_CONST; 1836 init_op = Token::INIT_CONST;
1837 break; 1837 break;
1838 case STRICT_MODE: 1838 case STRICT_MODE:
1839 ReportMessage("strict_const", Vector<const char*>::empty()); 1839 ReportMessage("strict_const", Vector<const char*>::empty());
1840 *ok = false; 1840 *ok = false;
1841 return NULL; 1841 return NULL;
1842 case EXTENDED_MODE: 1842 case EXTENDED_MODE:
1843 if (var_context == kStatement) { 1843 if (var_context == kStatement) {
1844 // In extended mode 'const' declarations are only allowed in source 1844 // In extended mode 'const' declarations are only allowed in source
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
2326 } 2326 }
2327 2327
2328 2328
2329 Statement* Parser::ParseWithStatement(ZoneStringList* labels, bool* ok) { 2329 Statement* Parser::ParseWithStatement(ZoneStringList* labels, bool* ok) {
2330 // WithStatement :: 2330 // WithStatement ::
2331 // 'with' '(' Expression ')' Statement 2331 // 'with' '(' Expression ')' Statement
2332 2332
2333 Expect(Token::WITH, CHECK_OK); 2333 Expect(Token::WITH, CHECK_OK);
2334 int pos = position(); 2334 int pos = position();
2335 2335
2336 if (!scope_->is_classic_mode()) { 2336 if (!scope_->is_sloppy_mode()) {
2337 ReportMessage("strict_mode_with", Vector<const char*>::empty()); 2337 ReportMessage("strict_mode_with", Vector<const char*>::empty());
2338 *ok = false; 2338 *ok = false;
2339 return NULL; 2339 return NULL;
2340 } 2340 }
2341 2341
2342 Expect(Token::LPAREN, CHECK_OK); 2342 Expect(Token::LPAREN, CHECK_OK);
2343 Expression* expr = ParseExpression(true, CHECK_OK); 2343 Expression* expr = ParseExpression(true, CHECK_OK);
2344 Expect(Token::RPAREN, CHECK_OK); 2344 Expect(Token::RPAREN, CHECK_OK);
2345 2345
2346 scope_->DeclarationScope()->RecordWithStatement(); 2346 scope_->DeclarationScope()->RecordWithStatement();
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
2900 // side expression. We could report this as a syntax error here but 2900 // side expression. We could report this as a syntax error here but
2901 // for compatibility with JSC we choose to report the error at 2901 // for compatibility with JSC we choose to report the error at
2902 // runtime. 2902 // runtime.
2903 // TODO(ES5): Should change parsing for spec conformance. 2903 // TODO(ES5): Should change parsing for spec conformance.
2904 if (expression == NULL || !expression->IsValidLeftHandSide()) { 2904 if (expression == NULL || !expression->IsValidLeftHandSide()) {
2905 Handle<String> message = 2905 Handle<String> message =
2906 isolate()->factory()->invalid_lhs_in_assignment_string(); 2906 isolate()->factory()->invalid_lhs_in_assignment_string();
2907 expression = NewThrowReferenceError(message); 2907 expression = NewThrowReferenceError(message);
2908 } 2908 }
2909 2909
2910 if (!scope_->is_classic_mode()) { 2910 if (!scope_->is_sloppy_mode()) {
2911 // Assignment to eval or arguments is disallowed in strict mode. 2911 // Assignment to eval or arguments is disallowed in strict mode.
2912 CheckStrictModeLValue(expression, CHECK_OK); 2912 CheckStrictModeLValue(expression, CHECK_OK);
2913 } 2913 }
2914 MarkAsLValue(expression); 2914 MarkAsLValue(expression);
2915 2915
2916 Token::Value op = Next(); // Get assignment operator. 2916 Token::Value op = Next(); // Get assignment operator.
2917 int pos = position(); 2917 int pos = position();
2918 Expression* right = ParseAssignmentExpression(accept_IN, CHECK_OK); 2918 Expression* right = ParseAssignmentExpression(accept_IN, CHECK_OK);
2919 2919
2920 // TODO(1231235): We try to estimate the set of properties set by 2920 // TODO(1231235): We try to estimate the set of properties set by
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
3124 return factory()->NewNumberLiteral(-value, pos); 3124 return factory()->NewNumberLiteral(-value, pos);
3125 case Token::BIT_NOT: 3125 case Token::BIT_NOT:
3126 return factory()->NewNumberLiteral(~DoubleToInt32(value), pos); 3126 return factory()->NewNumberLiteral(~DoubleToInt32(value), pos);
3127 default: 3127 default:
3128 break; 3128 break;
3129 } 3129 }
3130 } 3130 }
3131 } 3131 }
3132 3132
3133 // "delete identifier" is a syntax error in strict mode. 3133 // "delete identifier" is a syntax error in strict mode.
3134 if (op == Token::DELETE && !scope_->is_classic_mode()) { 3134 if (op == Token::DELETE && !scope_->is_sloppy_mode()) {
3135 VariableProxy* operand = expression->AsVariableProxy(); 3135 VariableProxy* operand = expression->AsVariableProxy();
3136 if (operand != NULL && !operand->is_this()) { 3136 if (operand != NULL && !operand->is_this()) {
3137 ReportMessage("strict_delete", Vector<const char*>::empty()); 3137 ReportMessage("strict_delete", Vector<const char*>::empty());
3138 *ok = false; 3138 *ok = false;
3139 return NULL; 3139 return NULL;
3140 } 3140 }
3141 } 3141 }
3142 3142
3143 // Desugar '+foo' into 'foo*1', this enables the collection of type feedback 3143 // Desugar '+foo' into 'foo*1', this enables the collection of type feedback
3144 // without any special stub and the multiplication is removed later in 3144 // without any special stub and the multiplication is removed later in
(...skipping 27 matching lines...) Expand all
3172 // Signal a reference error if the expression is an invalid 3172 // Signal a reference error if the expression is an invalid
3173 // left-hand side expression. We could report this as a syntax 3173 // left-hand side expression. We could report this as a syntax
3174 // error here but for compatibility with JSC we choose to report the 3174 // error here but for compatibility with JSC we choose to report the
3175 // error at runtime. 3175 // error at runtime.
3176 if (expression == NULL || !expression->IsValidLeftHandSide()) { 3176 if (expression == NULL || !expression->IsValidLeftHandSide()) {
3177 Handle<String> message = 3177 Handle<String> message =
3178 isolate()->factory()->invalid_lhs_in_prefix_op_string(); 3178 isolate()->factory()->invalid_lhs_in_prefix_op_string();
3179 expression = NewThrowReferenceError(message); 3179 expression = NewThrowReferenceError(message);
3180 } 3180 }
3181 3181
3182 if (!scope_->is_classic_mode()) { 3182 if (!scope_->is_sloppy_mode()) {
3183 // Prefix expression operand in strict mode may not be eval or arguments. 3183 // Prefix expression operand in strict mode may not be eval or arguments.
3184 CheckStrictModeLValue(expression, CHECK_OK); 3184 CheckStrictModeLValue(expression, CHECK_OK);
3185 } 3185 }
3186 MarkAsLValue(expression); 3186 MarkAsLValue(expression);
3187 3187
3188 return factory()->NewCountOperation(op, 3188 return factory()->NewCountOperation(op,
3189 true /* prefix */, 3189 true /* prefix */,
3190 expression, 3190 expression,
3191 position()); 3191 position());
3192 3192
(...skipping 13 matching lines...) Expand all
3206 // Signal a reference error if the expression is an invalid 3206 // Signal a reference error if the expression is an invalid
3207 // left-hand side expression. We could report this as a syntax 3207 // left-hand side expression. We could report this as a syntax
3208 // error here but for compatibility with JSC we choose to report the 3208 // error here but for compatibility with JSC we choose to report the
3209 // error at runtime. 3209 // error at runtime.
3210 if (expression == NULL || !expression->IsValidLeftHandSide()) { 3210 if (expression == NULL || !expression->IsValidLeftHandSide()) {
3211 Handle<String> message = 3211 Handle<String> message =
3212 isolate()->factory()->invalid_lhs_in_postfix_op_string(); 3212 isolate()->factory()->invalid_lhs_in_postfix_op_string();
3213 expression = NewThrowReferenceError(message); 3213 expression = NewThrowReferenceError(message);
3214 } 3214 }
3215 3215
3216 if (!scope_->is_classic_mode()) { 3216 if (!scope_->is_sloppy_mode()) {
3217 // Postfix expression operand in strict mode may not be eval or arguments. 3217 // Postfix expression operand in strict mode may not be eval or arguments.
3218 CheckStrictModeLValue(expression, CHECK_OK); 3218 CheckStrictModeLValue(expression, CHECK_OK);
3219 } 3219 }
3220 MarkAsLValue(expression); 3220 MarkAsLValue(expression);
3221 3221
3222 Token::Value next = Next(); 3222 Token::Value next = Next();
3223 expression = 3223 expression =
3224 factory()->NewCountOperation(next, 3224 factory()->NewCountOperation(next,
3225 false /* postfix */, 3225 false /* postfix */,
3226 expression, 3226 expression,
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
4095 materialized_literal_count = function_state.materialized_literal_count(); 4095 materialized_literal_count = function_state.materialized_literal_count();
4096 expected_property_count = function_state.expected_property_count(); 4096 expected_property_count = function_state.expected_property_count();
4097 handler_count = function_state.handler_count(); 4097 handler_count = function_state.handler_count();
4098 4098
4099 Expect(Token::RBRACE, CHECK_OK); 4099 Expect(Token::RBRACE, CHECK_OK);
4100 scope->set_end_position(scanner()->location().end_pos); 4100 scope->set_end_position(scanner()->location().end_pos);
4101 } 4101 }
4102 4102
4103 // Validate strict mode. We can do this only after parsing the function, 4103 // Validate strict mode. We can do this only after parsing the function,
4104 // since the function can declare itself strict. 4104 // since the function can declare itself strict.
4105 if (!scope_->is_classic_mode()) { 4105 if (!scope_->is_sloppy_mode()) {
4106 if (IsEvalOrArguments(function_name)) { 4106 if (IsEvalOrArguments(function_name)) {
4107 ReportMessageAt(function_name_location, "strict_eval_arguments"); 4107 ReportMessageAt(function_name_location, "strict_eval_arguments");
4108 *ok = false; 4108 *ok = false;
4109 return NULL; 4109 return NULL;
4110 } 4110 }
4111 if (name_is_strict_reserved) { 4111 if (name_is_strict_reserved) {
4112 ReportMessageAt(function_name_location, "unexpected_strict_reserved"); 4112 ReportMessageAt(function_name_location, "unexpected_strict_reserved");
4113 *ok = false; 4113 *ok = false;
4114 return NULL; 4114 return NULL;
4115 } 4115 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
4258 : NULL; 4258 : NULL;
4259 4259
4260 if (proxy != NULL) proxy->MarkAsLValue(); 4260 if (proxy != NULL) proxy->MarkAsLValue();
4261 } 4261 }
4262 4262
4263 4263
4264 // Checks LHS expression for assignment and prefix/postfix increment/decrement 4264 // Checks LHS expression for assignment and prefix/postfix increment/decrement
4265 // in strict mode. 4265 // in strict mode.
4266 void Parser::CheckStrictModeLValue(Expression* expression, 4266 void Parser::CheckStrictModeLValue(Expression* expression,
4267 bool* ok) { 4267 bool* ok) {
4268 ASSERT(!scope_->is_classic_mode()); 4268 ASSERT(!scope_->is_sloppy_mode());
4269 VariableProxy* lhs = expression != NULL 4269 VariableProxy* lhs = expression != NULL
4270 ? expression->AsVariableProxy() 4270 ? expression->AsVariableProxy()
4271 : NULL; 4271 : NULL;
4272 4272
4273 if (lhs != NULL && !lhs->is_this() && IsEvalOrArguments(lhs->name())) { 4273 if (lhs != NULL && !lhs->is_this() && IsEvalOrArguments(lhs->name())) {
4274 ReportMessage("strict_eval_arguments", Vector<const char*>::empty()); 4274 ReportMessage("strict_eval_arguments", Vector<const char*>::empty());
4275 *ok = false; 4275 *ok = false;
4276 } 4276 }
4277 } 4277 }
4278 4278
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
5353 ASSERT(info()->isolate()->has_pending_exception()); 5353 ASSERT(info()->isolate()->has_pending_exception());
5354 } else { 5354 } else {
5355 result = ParseProgram(); 5355 result = ParseProgram();
5356 } 5356 }
5357 } 5357 }
5358 info()->SetFunction(result); 5358 info()->SetFunction(result);
5359 return (result != NULL); 5359 return (result != NULL);
5360 } 5360 }
5361 5361
5362 } } // namespace v8::internal 5362 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698