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

Side by Side Diff: src/preparser.cc

Issue 477263002: ES6: Add support for method shorthand in object literals (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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
« src/ast.h ('K') | « src/preparser.h ('k') | src/runtime.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 // 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 <cmath> 5 #include <cmath>
6 6
7 #include "include/v8stdint.h" 7 #include "include/v8stdint.h"
8 8
9 #include "src/allocation.h" 9 #include "src/allocation.h"
10 #include "src/base/logging.h" 10 #include "src/base/logging.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 return PreParserExpression::StringLiteral(); 84 return PreParserExpression::StringLiteral();
85 } 85 }
86 86
87 87
88 PreParserExpression PreParserTraits::ParseV8Intrinsic(bool* ok) { 88 PreParserExpression PreParserTraits::ParseV8Intrinsic(bool* ok) {
89 return pre_parser_->ParseV8Intrinsic(ok); 89 return pre_parser_->ParseV8Intrinsic(ok);
90 } 90 }
91 91
92 92
93 PreParserExpression PreParserTraits::ParseFunctionLiteral( 93 PreParserExpression PreParserTraits::ParseFunctionLiteral(
94 PreParserIdentifier name, 94 PreParserIdentifier name, Scanner::Location function_name_location,
95 Scanner::Location function_name_location, 95 bool name_is_strict_reserved, FunctionLiteral::IsGeneratorFlag is_generator,
96 bool name_is_strict_reserved, 96 FunctionLiteral::IsArrowFlag is_arrow,
97 bool is_generator, 97 FunctionLiteral::IsConciseMethodFlag is_concise_method,
98 int function_token_position, 98 int function_token_position, FunctionLiteral::FunctionType type,
99 FunctionLiteral::FunctionType type, 99 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) {
100 FunctionLiteral::ArityRestriction arity_restriction,
101 bool* ok) {
102 return pre_parser_->ParseFunctionLiteral( 100 return pre_parser_->ParseFunctionLiteral(
103 name, function_name_location, name_is_strict_reserved, is_generator, 101 name, function_name_location, name_is_strict_reserved, is_generator,
104 function_token_position, type, arity_restriction, ok); 102 is_arrow, is_concise_method, function_token_position, type,
103 arity_restriction, ok);
105 } 104 }
106 105
107 106
108 PreParser::PreParseResult PreParser::PreParseLazyFunction( 107 PreParser::PreParseResult PreParser::PreParseLazyFunction(
109 StrictMode strict_mode, bool is_generator, ParserRecorder* log) { 108 StrictMode strict_mode, bool is_generator, ParserRecorder* log) {
110 log_ = log; 109 log_ = log;
111 // Lazy functions always have trivial outer scopes (no with/catch scopes). 110 // Lazy functions always have trivial outer scopes (no with/catch scopes).
112 PreParserScope top_scope(scope_, GLOBAL_SCOPE); 111 PreParserScope top_scope(scope_, GLOBAL_SCOPE);
113 FunctionState top_state(&function_state_, &scope_, &top_scope, NULL, 112 FunctionState top_state(&function_state_, &scope_, &top_scope, NULL,
114 this->ast_value_factory()); 113 this->ast_value_factory());
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}' 321 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}'
323 // GeneratorDeclaration :: 322 // GeneratorDeclaration ::
324 // 'function' '*' Identifier '(' FormalParameterListopt ')' 323 // 'function' '*' Identifier '(' FormalParameterListopt ')'
325 // '{' FunctionBody '}' 324 // '{' FunctionBody '}'
326 Expect(Token::FUNCTION, CHECK_OK); 325 Expect(Token::FUNCTION, CHECK_OK);
327 int pos = position(); 326 int pos = position();
328 bool is_generator = allow_generators() && Check(Token::MUL); 327 bool is_generator = allow_generators() && Check(Token::MUL);
329 bool is_strict_reserved = false; 328 bool is_strict_reserved = false;
330 Identifier name = ParseIdentifierOrStrictReservedWord( 329 Identifier name = ParseIdentifierOrStrictReservedWord(
331 &is_strict_reserved, CHECK_OK); 330 &is_strict_reserved, CHECK_OK);
332 ParseFunctionLiteral(name, 331 ParseFunctionLiteral(
333 scanner()->location(), 332 name, scanner()->location(), is_strict_reserved,
334 is_strict_reserved, 333 is_generator ? FunctionLiteral::kIsGenerator
335 is_generator, 334 : FunctionLiteral::kNotGenerator,
336 pos, 335 FunctionLiteral::kNotArrow, FunctionLiteral::kNotConciseMethod, pos,
337 FunctionLiteral::DECLARATION, 336 FunctionLiteral::DECLARATION, FunctionLiteral::NORMAL_ARITY, CHECK_OK);
338 FunctionLiteral::NORMAL_ARITY,
339 CHECK_OK);
340 return Statement::FunctionDeclaration(); 337 return Statement::FunctionDeclaration();
341 } 338 }
342 339
343 340
344 PreParser::Statement PreParser::ParseBlock(bool* ok) { 341 PreParser::Statement PreParser::ParseBlock(bool* ok) {
345 // Block :: 342 // Block ::
346 // '{' Statement* '}' 343 // '{' Statement* '}'
347 344
348 // Note that a Block does not introduce a new execution scope! 345 // Note that a Block does not introduce a new execution scope!
349 // (ECMA-262, 3rd, 12.2) 346 // (ECMA-262, 3rd, 12.2)
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 784
788 #undef CHECK_OK 785 #undef CHECK_OK
789 #define CHECK_OK ok); \ 786 #define CHECK_OK ok); \
790 if (!*ok) return Expression::Default(); \ 787 if (!*ok) return Expression::Default(); \
791 ((void)0 788 ((void)0
792 #define DUMMY ) // to make indentation work 789 #define DUMMY ) // to make indentation work
793 #undef DUMMY 790 #undef DUMMY
794 791
795 792
796 PreParser::Expression PreParser::ParseFunctionLiteral( 793 PreParser::Expression PreParser::ParseFunctionLiteral(
797 Identifier function_name, 794 Identifier function_name, Scanner::Location function_name_location,
798 Scanner::Location function_name_location, 795 bool name_is_strict_reserved, FunctionLiteral::IsGeneratorFlag is_generator,
799 bool name_is_strict_reserved, 796 FunctionLiteral::IsArrowFlag is_arrow,
800 bool is_generator, 797 FunctionLiteral::IsConciseMethodFlag is_concise_method,
801 int function_token_pos, 798 int function_token_pos, FunctionLiteral::FunctionType function_type,
802 FunctionLiteral::FunctionType function_type, 799 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) {
803 FunctionLiteral::ArityRestriction arity_restriction,
804 bool* ok) {
805 // Function :: 800 // Function ::
806 // '(' FormalParameterList? ')' '{' FunctionBody '}' 801 // '(' FormalParameterList? ')' '{' FunctionBody '}'
807 802
808 // Parse function body. 803 // Parse function body.
809 ScopeType outer_scope_type = scope_->type(); 804 ScopeType outer_scope_type = scope_->type();
810 PreParserScope function_scope(scope_, FUNCTION_SCOPE); 805 PreParserScope function_scope(scope_, FUNCTION_SCOPE);
811 FunctionState function_state(&function_state_, &scope_, &function_scope, NULL, 806 FunctionState function_state(&function_state_, &scope_, &function_scope, NULL,
812 this->ast_value_factory()); 807 this->ast_value_factory());
813 function_state.set_is_generator(is_generator); 808 function_state.set_is_generator(is_generator);
814 // FormalParameterList :: 809 // FormalParameterList ::
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); 922 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK);
928 ParseArguments(ok); 923 ParseArguments(ok);
929 924
930 return Expression::Default(); 925 return Expression::Default();
931 } 926 }
932 927
933 #undef CHECK_OK 928 #undef CHECK_OK
934 929
935 930
936 } } // v8::internal 931 } } // v8::internal
OLDNEW
« src/ast.h ('K') | « src/preparser.h ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698