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

Side by Side Diff: src/preparser.cc

Issue 885643004: new classes: assert that constructors are not callable and rewrite 'return;' (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix bit width Created 5 years, 10 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
« no previous file with comments | « src/preparser.h ('k') | src/runtime/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 "src/allocation.h" 7 #include "src/allocation.h"
8 #include "src/base/logging.h" 8 #include "src/base/logging.h"
9 #include "src/conversions-inl.h" 9 #include "src/conversions-inl.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 bool name_is_strict_reserved, FunctionKind kind, 97 bool name_is_strict_reserved, FunctionKind kind,
98 int function_token_position, FunctionLiteral::FunctionType type, 98 int function_token_position, FunctionLiteral::FunctionType type,
99 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { 99 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) {
100 return pre_parser_->ParseFunctionLiteral( 100 return pre_parser_->ParseFunctionLiteral(
101 name, function_name_location, name_is_strict_reserved, kind, 101 name, function_name_location, name_is_strict_reserved, kind,
102 function_token_position, type, arity_restriction, ok); 102 function_token_position, type, arity_restriction, ok);
103 } 103 }
104 104
105 105
106 PreParser::PreParseResult PreParser::PreParseLazyFunction( 106 PreParser::PreParseResult PreParser::PreParseLazyFunction(
107 LanguageMode language_mode, bool is_generator, ParserRecorder* log) { 107 LanguageMode language_mode, FunctionKind kind, ParserRecorder* log) {
108 log_ = log; 108 log_ = log;
109 // Lazy functions always have trivial outer scopes (no with/catch scopes). 109 // Lazy functions always have trivial outer scopes (no with/catch scopes).
110 PreParserScope top_scope(scope_, SCRIPT_SCOPE); 110 PreParserScope top_scope(scope_, SCRIPT_SCOPE);
111 PreParserFactory top_factory(NULL); 111 PreParserFactory top_factory(NULL);
112 FunctionState top_state(&function_state_, &scope_, &top_scope, &top_factory); 112 FunctionState top_state(&function_state_, &scope_, &top_scope,
113 kNormalFunction, &top_factory);
113 scope_->SetLanguageMode(language_mode); 114 scope_->SetLanguageMode(language_mode);
114 PreParserScope function_scope(scope_, FUNCTION_SCOPE); 115 PreParserScope function_scope(scope_, FUNCTION_SCOPE);
115 PreParserFactory function_factory(NULL); 116 PreParserFactory function_factory(NULL);
116 FunctionState function_state(&function_state_, &scope_, &function_scope, 117 FunctionState function_state(&function_state_, &scope_, &function_scope, kind,
117 &function_factory); 118 &function_factory);
118 function_state.set_is_generator(is_generator);
119 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); 119 DCHECK_EQ(Token::LBRACE, scanner()->current_token());
120 bool ok = true; 120 bool ok = true;
121 int start_position = peek_position(); 121 int start_position = peek_position();
122 ParseLazyFunctionLiteralBody(&ok); 122 ParseLazyFunctionLiteralBody(&ok);
123 if (stack_overflow()) return kPreParseStackOverflow; 123 if (stack_overflow()) return kPreParseStackOverflow;
124 if (!ok) { 124 if (!ok) {
125 ReportUnexpectedToken(scanner()->current_token()); 125 ReportUnexpectedToken(scanner()->current_token());
126 } else { 126 } else {
127 DCHECK_EQ(Token::RBRACE, scanner()->peek()); 127 DCHECK_EQ(Token::RBRACE, scanner()->peek());
128 if (is_strict(scope_->language_mode())) { 128 if (is_strict(scope_->language_mode())) {
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, 862 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos,
863 FunctionLiteral::FunctionType function_type, 863 FunctionLiteral::FunctionType function_type,
864 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { 864 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) {
865 // Function :: 865 // Function ::
866 // '(' FormalParameterList? ')' '{' FunctionBody '}' 866 // '(' FormalParameterList? ')' '{' FunctionBody '}'
867 867
868 // Parse function body. 868 // Parse function body.
869 ScopeType outer_scope_type = scope_->type(); 869 ScopeType outer_scope_type = scope_->type();
870 PreParserScope function_scope(scope_, FUNCTION_SCOPE); 870 PreParserScope function_scope(scope_, FUNCTION_SCOPE);
871 PreParserFactory factory(NULL); 871 PreParserFactory factory(NULL);
872 FunctionState function_state(&function_state_, &scope_, &function_scope, 872 FunctionState function_state(&function_state_, &scope_, &function_scope, kind,
873 &factory); 873 &factory);
874 function_state.set_is_generator(IsGeneratorFunction(kind));
875 // FormalParameterList :: 874 // FormalParameterList ::
876 // '(' (Identifier)*[','] ')' 875 // '(' (Identifier)*[','] ')'
877 Expect(Token::LPAREN, CHECK_OK); 876 Expect(Token::LPAREN, CHECK_OK);
878 int start_position = position(); 877 int start_position = position();
879 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); 878 DuplicateFinder duplicate_finder(scanner()->unicode_cache());
880 // We don't yet know if the function will be strict, so we cannot yet produce 879 // We don't yet know if the function will be strict, so we cannot yet produce
881 // errors for parameter names or duplicates. However, we remember the 880 // errors for parameter names or duplicates. However, we remember the
882 // locations of these errors if they occur and produce the errors later. 881 // locations of these errors if they occur and produce the errors later.
883 Scanner::Location eval_args_error_loc = Scanner::Location::invalid(); 882 Scanner::Location eval_args_error_loc = Scanner::Location::invalid();
884 Scanner::Location dupe_error_loc = Scanner::Location::invalid(); 883 Scanner::Location dupe_error_loc = Scanner::Location::invalid();
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); 1046 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK);
1048 ParseArguments(ok); 1047 ParseArguments(ok);
1049 1048
1050 return Expression::Default(); 1049 return Expression::Default();
1051 } 1050 }
1052 1051
1053 #undef CHECK_OK 1052 #undef CHECK_OK
1054 1053
1055 1054
1056 } } // v8::internal 1055 } } // v8::internal
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698