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

Side by Side Diff: src/preparser.cc

Issue 716833002: Various clean-ups after top-level lexical declarations are done. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Patch for landing Created 6 years, 1 month 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/preparser.h ('k') | src/rewriter.cc » ('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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 return pre_parser_->ParseFunctionLiteral( 98 return pre_parser_->ParseFunctionLiteral(
99 name, function_name_location, name_is_strict_reserved, kind, 99 name, function_name_location, name_is_strict_reserved, kind,
100 function_token_position, type, arity_restriction, ok); 100 function_token_position, type, arity_restriction, ok);
101 } 101 }
102 102
103 103
104 PreParser::PreParseResult PreParser::PreParseLazyFunction( 104 PreParser::PreParseResult PreParser::PreParseLazyFunction(
105 StrictMode strict_mode, bool is_generator, ParserRecorder* log) { 105 StrictMode strict_mode, bool is_generator, ParserRecorder* log) {
106 log_ = log; 106 log_ = log;
107 // Lazy functions always have trivial outer scopes (no with/catch scopes). 107 // Lazy functions always have trivial outer scopes (no with/catch scopes).
108 PreParserScope top_scope(scope_, GLOBAL_SCOPE); 108 PreParserScope top_scope(scope_, SCRIPT_SCOPE);
109 PreParserFactory top_factory(NULL); 109 PreParserFactory top_factory(NULL);
110 FunctionState top_state(&function_state_, &scope_, &top_scope, &top_factory); 110 FunctionState top_state(&function_state_, &scope_, &top_scope, &top_factory);
111 scope_->SetStrictMode(strict_mode); 111 scope_->SetStrictMode(strict_mode);
112 PreParserScope function_scope(scope_, FUNCTION_SCOPE); 112 PreParserScope function_scope(scope_, FUNCTION_SCOPE);
113 PreParserFactory function_factory(NULL); 113 PreParserFactory function_factory(NULL);
114 FunctionState function_state(&function_state_, &scope_, &function_scope, 114 FunctionState function_state(&function_state_, &scope_, &function_scope,
115 &function_factory); 115 &function_factory);
116 function_state.set_is_generator(is_generator); 116 function_state.set_is_generator(is_generator);
117 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); 117 DCHECK_EQ(Token::LBRACE, scanner()->current_token());
118 bool ok = true; 118 bool ok = true;
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 } 856 }
857 857
858 if (arity_restriction == FunctionLiteral::SETTER_ARITY) break; 858 if (arity_restriction == FunctionLiteral::SETTER_ARITY) break;
859 done = (peek() == Token::RPAREN); 859 done = (peek() == Token::RPAREN);
860 if (!done) Expect(Token::COMMA, CHECK_OK); 860 if (!done) Expect(Token::COMMA, CHECK_OK);
861 } 861 }
862 Expect(Token::RPAREN, CHECK_OK); 862 Expect(Token::RPAREN, CHECK_OK);
863 863
864 // See Parser::ParseFunctionLiteral for more information about lazy parsing 864 // See Parser::ParseFunctionLiteral for more information about lazy parsing
865 // and lazy compilation. 865 // and lazy compilation.
866 bool is_lazily_parsed = (outer_scope_type == GLOBAL_SCOPE && allow_lazy() && 866 bool is_lazily_parsed = (outer_scope_type == SCRIPT_SCOPE && allow_lazy() &&
867 !parenthesized_function_); 867 !parenthesized_function_);
868 parenthesized_function_ = false; 868 parenthesized_function_ = false;
869 869
870 Expect(Token::LBRACE, CHECK_OK); 870 Expect(Token::LBRACE, CHECK_OK);
871 if (is_lazily_parsed) { 871 if (is_lazily_parsed) {
872 ParseLazyFunctionLiteralBody(CHECK_OK); 872 ParseLazyFunctionLiteralBody(CHECK_OK);
873 } else { 873 } else {
874 ParseSourceElements(Token::RBRACE, ok); 874 ParseSourceElements(Token::RBRACE, ok);
875 } 875 }
876 Expect(Token::RBRACE, CHECK_OK); 876 Expect(Token::RBRACE, CHECK_OK);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); 940 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK);
941 ParseArguments(ok); 941 ParseArguments(ok);
942 942
943 return Expression::Default(); 943 return Expression::Default();
944 } 944 }
945 945
946 #undef CHECK_OK 946 #undef CHECK_OK
947 947
948 948
949 } } // v8::internal 949 } } // v8::internal
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | src/rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698