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

Side by Side Diff: src/parser.cc

Issue 7207007: Proper handling of future reserved words in strict and normal mode. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 9 years, 6 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
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 return new(zone()) ExpressionStatement(new(zone()) Assignment( 1438 return new(zone()) ExpressionStatement(new(zone()) Assignment(
1439 Token::INIT_VAR, var, lit, RelocInfo::kNoPosition)); 1439 Token::INIT_VAR, var, lit, RelocInfo::kNoPosition));
1440 } 1440 }
1441 1441
1442 1442
1443 Statement* Parser::ParseFunctionDeclaration(bool* ok) { 1443 Statement* Parser::ParseFunctionDeclaration(bool* ok) {
1444 // FunctionDeclaration :: 1444 // FunctionDeclaration ::
1445 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}' 1445 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}'
1446 Expect(Token::FUNCTION, CHECK_OK); 1446 Expect(Token::FUNCTION, CHECK_OK);
1447 int function_token_position = scanner().location().beg_pos; 1447 int function_token_position = scanner().location().beg_pos;
1448 bool is_reserved = false; 1448 bool is_strict_reserved = false;
1449 Handle<String> name = ParseIdentifierOrReservedWord(&is_reserved, CHECK_OK); 1449 Handle<String> name = ParseIdentifierOrStrictReservedWord(
1450 &is_strict_reserved, CHECK_OK);
1450 FunctionLiteral* fun = ParseFunctionLiteral(name, 1451 FunctionLiteral* fun = ParseFunctionLiteral(name,
1451 is_reserved, 1452 is_strict_reserved,
1452 function_token_position, 1453 function_token_position,
1453 DECLARATION, 1454 DECLARATION,
1454 CHECK_OK); 1455 CHECK_OK);
1455 // Even if we're not at the top-level of the global or a function 1456 // Even if we're not at the top-level of the global or a function
1456 // scope, we treat is as such and introduce the function with it's 1457 // scope, we treat is as such and introduce the function with it's
1457 // initial value upon entering the corresponding scope. 1458 // initial value upon entering the corresponding scope.
1458 Declare(name, Variable::VAR, fun, true, CHECK_OK); 1459 Declare(name, Variable::VAR, fun, true, CHECK_OK);
1459 return EmptyStatement(); 1460 return EmptyStatement();
1460 } 1461 }
1461 1462
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after
2763 // MemberExpression :: 2764 // MemberExpression ::
2764 // (PrimaryExpression | FunctionLiteral) 2765 // (PrimaryExpression | FunctionLiteral)
2765 // ('[' Expression ']' | '.' Identifier | Arguments)* 2766 // ('[' Expression ']' | '.' Identifier | Arguments)*
2766 2767
2767 // Parse the initial primary or function expression. 2768 // Parse the initial primary or function expression.
2768 Expression* result = NULL; 2769 Expression* result = NULL;
2769 if (peek() == Token::FUNCTION) { 2770 if (peek() == Token::FUNCTION) {
2770 Expect(Token::FUNCTION, CHECK_OK); 2771 Expect(Token::FUNCTION, CHECK_OK);
2771 int function_token_position = scanner().location().beg_pos; 2772 int function_token_position = scanner().location().beg_pos;
2772 Handle<String> name; 2773 Handle<String> name;
2773 bool is_reserved_name = false; 2774 bool is_strict_reserved_name = false;
2774 if (peek_any_identifier()) { 2775 if (peek_any_identifier()) {
2775 name = ParseIdentifierOrReservedWord(&is_reserved_name, CHECK_OK); 2776 name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name,
2777 CHECK_OK);
2776 } 2778 }
2777 result = ParseFunctionLiteral(name, is_reserved_name, 2779 result = ParseFunctionLiteral(name, is_strict_reserved_name,
2778 function_token_position, NESTED, CHECK_OK); 2780 function_token_position, NESTED, CHECK_OK);
2779 } else { 2781 } else {
2780 result = ParsePrimaryExpression(CHECK_OK); 2782 result = ParsePrimaryExpression(CHECK_OK);
2781 } 2783 }
2782 2784
2783 while (true) { 2785 while (true) {
2784 switch (peek()) { 2786 switch (peek()) {
2785 case Token::LBRACK: { 2787 case Token::LBRACK: {
2786 Consume(Token::LBRACK); 2788 Consume(Token::LBRACK);
2787 int pos = scanner().location().beg_pos; 2789 int pos = scanner().location().beg_pos;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2838 case Token::NUMBER: 2840 case Token::NUMBER:
2839 return ReportMessage("unexpected_token_number", 2841 return ReportMessage("unexpected_token_number",
2840 Vector<const char*>::empty()); 2842 Vector<const char*>::empty());
2841 case Token::STRING: 2843 case Token::STRING:
2842 return ReportMessage("unexpected_token_string", 2844 return ReportMessage("unexpected_token_string",
2843 Vector<const char*>::empty()); 2845 Vector<const char*>::empty());
2844 case Token::IDENTIFIER: 2846 case Token::IDENTIFIER:
2845 return ReportMessage("unexpected_token_identifier", 2847 return ReportMessage("unexpected_token_identifier",
2846 Vector<const char*>::empty()); 2848 Vector<const char*>::empty());
2847 case Token::FUTURE_RESERVED_WORD: 2849 case Token::FUTURE_RESERVED_WORD:
2850 return ReportMessage("unexpected_reserved",
2851 Vector<const char*>::empty());
2852 case Token::FUTURE_STRICT_RESERVED_WORD:
2848 return ReportMessage(top_scope_->is_strict_mode() ? 2853 return ReportMessage(top_scope_->is_strict_mode() ?
2849 "unexpected_strict_reserved" : 2854 "unexpected_strict_reserved" :
2850 "unexpected_token_identifier", 2855 "unexpected_token_identifier",
2851 Vector<const char*>::empty()); 2856 Vector<const char*>::empty());
2852 default: 2857 default:
2853 const char* name = Token::String(token); 2858 const char* name = Token::String(token);
2854 ASSERT(name != NULL); 2859 ASSERT(name != NULL);
2855 ReportMessage("unexpected_token", Vector<const char*>(&name, 1)); 2860 ReportMessage("unexpected_token", Vector<const char*>(&name, 1));
2856 } 2861 }
2857 } 2862 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2898 Consume(Token::TRUE_LITERAL); 2903 Consume(Token::TRUE_LITERAL);
2899 result = new(zone()) Literal(isolate()->factory()->true_value()); 2904 result = new(zone()) Literal(isolate()->factory()->true_value());
2900 break; 2905 break;
2901 2906
2902 case Token::FALSE_LITERAL: 2907 case Token::FALSE_LITERAL:
2903 Consume(Token::FALSE_LITERAL); 2908 Consume(Token::FALSE_LITERAL);
2904 result = new(zone()) Literal(isolate()->factory()->false_value()); 2909 result = new(zone()) Literal(isolate()->factory()->false_value());
2905 break; 2910 break;
2906 2911
2907 case Token::IDENTIFIER: 2912 case Token::IDENTIFIER:
2908 case Token::FUTURE_RESERVED_WORD: { 2913 case Token::FUTURE_STRICT_RESERVED_WORD: {
2909 Handle<String> name = ParseIdentifier(CHECK_OK); 2914 Handle<String> name = ParseIdentifier(CHECK_OK);
2910 if (fni_ != NULL) fni_->PushVariableName(name); 2915 if (fni_ != NULL) fni_->PushVariableName(name);
2911 result = top_scope_->NewUnresolved(name, 2916 result = top_scope_->NewUnresolved(name,
2912 inside_with(), 2917 inside_with(),
2913 scanner().location().beg_pos); 2918 scanner().location().beg_pos);
2914 break; 2919 break;
2915 } 2920 }
2916 2921
2917 case Token::NUMBER: { 2922 case Token::NUMBER: {
2918 Consume(Token::NUMBER); 2923 Consume(Token::NUMBER);
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
3309 3314
3310 ObjectLiteral::Property* Parser::ParseObjectLiteralGetSet(bool is_getter, 3315 ObjectLiteral::Property* Parser::ParseObjectLiteralGetSet(bool is_getter,
3311 bool* ok) { 3316 bool* ok) {
3312 // Special handling of getter and setter syntax: 3317 // Special handling of getter and setter syntax:
3313 // { ... , get foo() { ... }, ... , set foo(v) { ... v ... } , ... } 3318 // { ... , get foo() { ... }, ... , set foo(v) { ... v ... } , ... }
3314 // We have already read the "get" or "set" keyword. 3319 // We have already read the "get" or "set" keyword.
3315 Token::Value next = Next(); 3320 Token::Value next = Next();
3316 bool is_keyword = Token::IsKeyword(next); 3321 bool is_keyword = Token::IsKeyword(next);
3317 if (next == Token::IDENTIFIER || next == Token::NUMBER || 3322 if (next == Token::IDENTIFIER || next == Token::NUMBER ||
3318 next == Token::FUTURE_RESERVED_WORD || 3323 next == Token::FUTURE_RESERVED_WORD ||
3324 next == Token::FUTURE_STRICT_RESERVED_WORD ||
3319 next == Token::STRING || is_keyword) { 3325 next == Token::STRING || is_keyword) {
3320 Handle<String> name; 3326 Handle<String> name;
3321 if (is_keyword) { 3327 if (is_keyword) {
3322 name = isolate_->factory()->LookupAsciiSymbol(Token::String(next)); 3328 name = isolate_->factory()->LookupAsciiSymbol(Token::String(next));
3323 } else { 3329 } else {
3324 name = GetSymbol(CHECK_OK); 3330 name = GetSymbol(CHECK_OK);
3325 } 3331 }
3326 FunctionLiteral* value = 3332 FunctionLiteral* value =
3327 ParseFunctionLiteral(name, 3333 ParseFunctionLiteral(name,
3328 false, // reserved words are allowed here 3334 false, // reserved words are allowed here
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3363 if (fni_ != NULL) fni_->Enter(); 3369 if (fni_ != NULL) fni_->Enter();
3364 3370
3365 Literal* key = NULL; 3371 Literal* key = NULL;
3366 Token::Value next = peek(); 3372 Token::Value next = peek();
3367 3373
3368 // Location of the property name token 3374 // Location of the property name token
3369 Scanner::Location loc = scanner().peek_location(); 3375 Scanner::Location loc = scanner().peek_location();
3370 3376
3371 switch (next) { 3377 switch (next) {
3372 case Token::FUTURE_RESERVED_WORD: 3378 case Token::FUTURE_RESERVED_WORD:
3379 case Token::FUTURE_STRICT_RESERVED_WORD:
3373 case Token::IDENTIFIER: { 3380 case Token::IDENTIFIER: {
3374 bool is_getter = false; 3381 bool is_getter = false;
3375 bool is_setter = false; 3382 bool is_setter = false;
3376 Handle<String> id = 3383 Handle<String> id =
3377 ParseIdentifierOrGetOrSet(&is_getter, &is_setter, CHECK_OK); 3384 ParseIdentifierNameOrGetOrSet(&is_getter, &is_setter, CHECK_OK);
3378 if (fni_ != NULL) fni_->PushLiteralName(id); 3385 if (fni_ != NULL) fni_->PushLiteralName(id);
3379 3386
3380 if ((is_getter || is_setter) && peek() != Token::COLON) { 3387 if ((is_getter || is_setter) && peek() != Token::COLON) {
3381 // Update loc to point to the identifier 3388 // Update loc to point to the identifier
3382 loc = scanner().peek_location(); 3389 loc = scanner().peek_location();
3383 ObjectLiteral::Property* property = 3390 ObjectLiteral::Property* property =
3384 ParseObjectLiteralGetSet(is_getter, CHECK_OK); 3391 ParseObjectLiteralGetSet(is_getter, CHECK_OK);
3385 if (IsBoilerplateProperty(property)) { 3392 if (IsBoilerplateProperty(property)) {
3386 number_of_boilerplate_properties++; 3393 number_of_boilerplate_properties++;
3387 } 3394 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
3526 } 3533 }
3527 done = (peek() == Token::RPAREN); 3534 done = (peek() == Token::RPAREN);
3528 if (!done) Expect(Token::COMMA, CHECK_OK); 3535 if (!done) Expect(Token::COMMA, CHECK_OK);
3529 } 3536 }
3530 Expect(Token::RPAREN, CHECK_OK); 3537 Expect(Token::RPAREN, CHECK_OK);
3531 return result; 3538 return result;
3532 } 3539 }
3533 3540
3534 3541
3535 FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> var_name, 3542 FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> var_name,
3536 bool name_is_reserved, 3543 bool name_is_strict_reserved,
3537 int function_token_position, 3544 int function_token_position,
3538 FunctionLiteralType type, 3545 FunctionLiteralType type,
3539 bool* ok) { 3546 bool* ok) {
3540 // Function :: 3547 // Function ::
3541 // '(' FormalParameterList? ')' '{' FunctionBody '}' 3548 // '(' FormalParameterList? ')' '{' FunctionBody '}'
3542 bool is_named = !var_name.is_null(); 3549 bool is_named = !var_name.is_null();
3543 3550
3544 // The name associated with this function. If it's a function expression, 3551 // The name associated with this function. If it's a function expression,
3545 // this is the actual function name, otherwise this is the name of the 3552 // this is the actual function name, otherwise this is the name of the
3546 // variable declared and initialized with the function (expression). In 3553 // variable declared and initialized with the function (expression). In
(...skipping 23 matching lines...) Expand all
3570 // FormalParameterList :: 3577 // FormalParameterList ::
3571 // '(' (Identifier)*[','] ')' 3578 // '(' (Identifier)*[','] ')'
3572 Expect(Token::LPAREN, CHECK_OK); 3579 Expect(Token::LPAREN, CHECK_OK);
3573 start_pos = scanner().location().beg_pos; 3580 start_pos = scanner().location().beg_pos;
3574 Scanner::Location name_loc = Scanner::Location::invalid(); 3581 Scanner::Location name_loc = Scanner::Location::invalid();
3575 Scanner::Location dupe_loc = Scanner::Location::invalid(); 3582 Scanner::Location dupe_loc = Scanner::Location::invalid();
3576 Scanner::Location reserved_loc = Scanner::Location::invalid(); 3583 Scanner::Location reserved_loc = Scanner::Location::invalid();
3577 3584
3578 bool done = (peek() == Token::RPAREN); 3585 bool done = (peek() == Token::RPAREN);
3579 while (!done) { 3586 while (!done) {
3580 bool is_reserved = false; 3587 bool is_strict_reserved = false;
3581 Handle<String> param_name = 3588 Handle<String> param_name =
3582 ParseIdentifierOrReservedWord(&is_reserved, CHECK_OK); 3589 ParseIdentifierOrStrictReservedWord(&is_strict_reserved,
3590 CHECK_OK);
3583 3591
3584 // Store locations for possible future error reports. 3592 // Store locations for possible future error reports.
3585 if (!name_loc.IsValid() && IsEvalOrArguments(param_name)) { 3593 if (!name_loc.IsValid() && IsEvalOrArguments(param_name)) {
3586 name_loc = scanner().location(); 3594 name_loc = scanner().location();
3587 } 3595 }
3588 if (!dupe_loc.IsValid() && top_scope_->IsDeclared(param_name)) { 3596 if (!dupe_loc.IsValid() && top_scope_->IsDeclared(param_name)) {
3589 has_duplicate_parameters = true; 3597 has_duplicate_parameters = true;
3590 dupe_loc = scanner().location(); 3598 dupe_loc = scanner().location();
3591 } 3599 }
3592 if (!reserved_loc.IsValid() && is_reserved) { 3600 if (!reserved_loc.IsValid() && is_strict_reserved) {
3593 reserved_loc = scanner().location(); 3601 reserved_loc = scanner().location();
3594 } 3602 }
3595 3603
3596 top_scope_->DeclareParameter(param_name); 3604 top_scope_->DeclareParameter(param_name);
3597 num_parameters++; 3605 num_parameters++;
3598 if (num_parameters > kMaxNumFunctionParameters) { 3606 if (num_parameters > kMaxNumFunctionParameters) {
3599 ReportMessageAt(scanner().location(), "too_many_parameters", 3607 ReportMessageAt(scanner().location(), "too_many_parameters",
3600 Vector<const char*>::empty()); 3608 Vector<const char*>::empty());
3601 *ok = false; 3609 *ok = false;
3602 return NULL; 3610 return NULL;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
3684 Vector<const char*>::empty()); 3692 Vector<const char*>::empty());
3685 *ok = false; 3693 *ok = false;
3686 return NULL; 3694 return NULL;
3687 } 3695 }
3688 if (dupe_loc.IsValid()) { 3696 if (dupe_loc.IsValid()) {
3689 ReportMessageAt(dupe_loc, "strict_param_dupe", 3697 ReportMessageAt(dupe_loc, "strict_param_dupe",
3690 Vector<const char*>::empty()); 3698 Vector<const char*>::empty());
3691 *ok = false; 3699 *ok = false;
3692 return NULL; 3700 return NULL;
3693 } 3701 }
3694 if (name_is_reserved) { 3702 if (name_is_strict_reserved) {
3695 int position = function_token_position != RelocInfo::kNoPosition 3703 int position = function_token_position != RelocInfo::kNoPosition
3696 ? function_token_position 3704 ? function_token_position
3697 : (start_pos > 0 ? start_pos - 1 : start_pos); 3705 : (start_pos > 0 ? start_pos - 1 : start_pos);
3698 Scanner::Location location = Scanner::Location(position, start_pos); 3706 Scanner::Location location = Scanner::Location(position, start_pos);
3699 ReportMessageAt(location, "strict_reserved_word", 3707 ReportMessageAt(location, "strict_reserved_word",
3700 Vector<const char*>::empty()); 3708 Vector<const char*>::empty());
3701 *ok = false; 3709 *ok = false;
3702 return NULL; 3710 return NULL;
3703 } 3711 }
3704 if (reserved_loc.IsValid()) { 3712 if (reserved_loc.IsValid()) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3773 } 3781 }
3774 3782
3775 // We have a valid intrinsics call or a call to a builtin. 3783 // We have a valid intrinsics call or a call to a builtin.
3776 return new(zone()) CallRuntime(name, function, args); 3784 return new(zone()) CallRuntime(name, function, args);
3777 } 3785 }
3778 3786
3779 3787
3780 bool Parser::peek_any_identifier() { 3788 bool Parser::peek_any_identifier() {
3781 Token::Value next = peek(); 3789 Token::Value next = peek();
3782 return next == Token::IDENTIFIER || 3790 return next == Token::IDENTIFIER ||
3783 next == Token::FUTURE_RESERVED_WORD; 3791 next == Token::FUTURE_RESERVED_WORD ||
3792 next == Token::FUTURE_STRICT_RESERVED_WORD;
3784 } 3793 }
3785 3794
3786 3795
3787 void Parser::Consume(Token::Value token) { 3796 void Parser::Consume(Token::Value token) {
3788 Token::Value next = Next(); 3797 Token::Value next = Next();
3789 USE(next); 3798 USE(next);
3790 USE(token); 3799 USE(token);
3791 ASSERT(next == token); 3800 ASSERT(next == token);
3792 } 3801 }
3793 3802
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3836 return new(zone()) Literal(isolate()->factory()->the_hole_value()); 3845 return new(zone()) Literal(isolate()->factory()->the_hole_value());
3837 } 3846 }
3838 3847
3839 3848
3840 Literal* Parser::GetLiteralNumber(double value) { 3849 Literal* Parser::GetLiteralNumber(double value) {
3841 return NewNumberLiteral(value); 3850 return NewNumberLiteral(value);
3842 } 3851 }
3843 3852
3844 3853
3845 Handle<String> Parser::ParseIdentifier(bool* ok) { 3854 Handle<String> Parser::ParseIdentifier(bool* ok) {
3846 bool is_reserved; 3855 if (top_scope_->is_strict_mode()) {
3847 return ParseIdentifierOrReservedWord(&is_reserved, ok); 3856 Expect(Token::IDENTIFIER, ok);
3857 } else if (!Check(Token::IDENTIFIER)) {
3858 Expect(Token::FUTURE_STRICT_RESERVED_WORD, ok);
3859 }
3860 if (!*ok) return Handle<String>();
3861 return GetSymbol(ok);
3848 } 3862 }
3849 3863
3850 3864
3851 Handle<String> Parser::ParseIdentifierOrReservedWord(bool* is_reserved, 3865 Handle<String> Parser::ParseIdentifierOrStrictReservedWord(
3852 bool* ok) { 3866 bool* is_strict_reserved, bool* ok) {
3853 *is_reserved = false; 3867 *is_strict_reserved = false;
3854 if (top_scope_->is_strict_mode()) { 3868 if (!Check(Token::IDENTIFIER)) {
3855 Expect(Token::IDENTIFIER, ok); 3869 Expect(Token::FUTURE_STRICT_RESERVED_WORD, ok);
3856 } else { 3870 *is_strict_reserved = true;
3857 if (!Check(Token::IDENTIFIER)) {
3858 Expect(Token::FUTURE_RESERVED_WORD, ok);
3859 *is_reserved = true;
3860 }
3861 } 3871 }
3862 if (!*ok) return Handle<String>(); 3872 if (!*ok) return Handle<String>();
3863 return GetSymbol(ok); 3873 return GetSymbol(ok);
3864 } 3874 }
3865 3875
3866 3876
3867 Handle<String> Parser::ParseIdentifierName(bool* ok) { 3877 Handle<String> Parser::ParseIdentifierName(bool* ok) {
3868 Token::Value next = Next(); 3878 Token::Value next = Next();
3869 if (next != Token::IDENTIFIER && 3879 if (next != Token::IDENTIFIER &&
3870 next != Token::FUTURE_RESERVED_WORD && 3880 next != Token::FUTURE_RESERVED_WORD &&
3871 !Token::IsKeyword(next)) { 3881 next != Token::FUTURE_STRICT_RESERVED_WORD &&
3882 !Token::IsKeyword(next)) {
3872 ReportUnexpectedToken(next); 3883 ReportUnexpectedToken(next);
3873 *ok = false; 3884 *ok = false;
3874 return Handle<String>(); 3885 return Handle<String>();
3875 } 3886 }
3876 return GetSymbol(ok); 3887 return GetSymbol(ok);
3877 } 3888 }
3878 3889
3879 3890
3880 // Checks LHS expression for assignment and prefix/postfix increment/decrement 3891 // Checks LHS expression for assignment and prefix/postfix increment/decrement
3881 // in strict mode. 3892 // in strict mode.
(...skipping 22 matching lines...) Expand all
3904 ReportMessageAt(octal, "strict_octal_literal", 3915 ReportMessageAt(octal, "strict_octal_literal",
3905 Vector<const char*>::empty()); 3916 Vector<const char*>::empty());
3906 scanner().clear_octal_position(); 3917 scanner().clear_octal_position();
3907 *ok = false; 3918 *ok = false;
3908 } 3919 }
3909 } 3920 }
3910 3921
3911 3922
3912 // This function reads an identifier and determines whether or not it 3923 // This function reads an identifier and determines whether or not it
3913 // is 'get' or 'set'. 3924 // is 'get' or 'set'.
3914 Handle<String> Parser::ParseIdentifierOrGetOrSet(bool* is_get, 3925 Handle<String> Parser::ParseIdentifierNameOrGetOrSet(bool* is_get,
3915 bool* is_set, 3926 bool* is_set,
3916 bool* ok) { 3927 bool* ok) {
3917 Handle<String> result = ParseIdentifier(ok); 3928 Handle<String> result = ParseIdentifierName(ok);
3918 if (!*ok) return Handle<String>(); 3929 if (!*ok) return Handle<String>();
3919 if (scanner().is_literal_ascii() && scanner().literal_length() == 3) { 3930 if (scanner().is_literal_ascii() && scanner().literal_length() == 3) {
3920 const char* token = scanner().literal_ascii_string().start(); 3931 const char* token = scanner().literal_ascii_string().start();
3921 *is_get = strncmp(token, "get", 3) == 0; 3932 *is_get = strncmp(token, "get", 3) == 0;
3922 *is_set = !*is_get && strncmp(token, "set", 3) == 0; 3933 *is_set = !*is_get && strncmp(token, "set", 3) == 0;
3923 } 3934 }
3924 return result; 3935 return result;
3925 } 3936 }
3926 3937
3927 3938
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
5008 info->is_global(), 5019 info->is_global(),
5009 info->StrictMode()); 5020 info->StrictMode());
5010 } 5021 }
5011 } 5022 }
5012 5023
5013 info->SetFunction(result); 5024 info->SetFunction(result);
5014 return (result != NULL); 5025 return (result != NULL);
5015 } 5026 }
5016 5027
5017 } } // namespace v8::internal 5028 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698