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/parser.cc

Issue 8306024: Make native syntax an early error in the preparser. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Unified enums Created 9 years, 2 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 5103 matching lines...) Expand 10 before | Expand all | Expand 10 after
5114 result = (result << 7) | (input & 0x7f); 5114 result = (result << 7) | (input & 0x7f);
5115 data++; 5115 data++;
5116 } 5116 }
5117 *source = data; 5117 *source = data;
5118 return result; 5118 return result;
5119 } 5119 }
5120 5120
5121 5121
5122 // Create a Scanner for the preparser to use as input, and preparse the source. 5122 // Create a Scanner for the preparser to use as input, and preparse the source.
5123 static ScriptDataImpl* DoPreParse(UC16CharacterStream* source, 5123 static ScriptDataImpl* DoPreParse(UC16CharacterStream* source,
5124 bool allow_lazy, 5124 int flags,
5125 ParserRecorder* recorder, 5125 ParserRecorder* recorder) {
5126 bool harmony_scoping) {
5127 Isolate* isolate = Isolate::Current(); 5126 Isolate* isolate = Isolate::Current();
5128 JavaScriptScanner scanner(isolate->unicode_cache()); 5127 JavaScriptScanner scanner(isolate->unicode_cache());
5129 scanner.SetHarmonyScoping(harmony_scoping); 5128 scanner.SetHarmonyScoping((flags & kHarmonyScoping) != 0);
5130 scanner.Initialize(source); 5129 scanner.Initialize(source);
5131 intptr_t stack_limit = isolate->stack_guard()->real_climit(); 5130 intptr_t stack_limit = isolate->stack_guard()->real_climit();
5132 if (!preparser::PreParser::PreParseProgram(&scanner, 5131 if (!preparser::PreParser::PreParseProgram(&scanner,
5133 recorder, 5132 recorder,
5134 allow_lazy, 5133 flags,
5135 stack_limit)) { 5134 stack_limit)) {
5136 isolate->StackOverflow(); 5135 isolate->StackOverflow();
5137 return NULL; 5136 return NULL;
5138 } 5137 }
5139 5138
5140 // Extract the accumulated data from the recorder as a single 5139 // Extract the accumulated data from the recorder as a single
5141 // contiguous vector that we are responsible for disposing. 5140 // contiguous vector that we are responsible for disposing.
5142 Vector<unsigned> store = recorder->ExtractData(); 5141 Vector<unsigned> store = recorder->ExtractData();
5143 return new ScriptDataImpl(store); 5142 return new ScriptDataImpl(store);
5144 } 5143 }
5145 5144
5146 5145
5147 // Preparse, but only collect data that is immediately useful, 5146 // Preparse, but only collect data that is immediately useful,
5148 // even if the preparser data is only used once. 5147 // even if the preparser data is only used once.
5149 ScriptDataImpl* ParserApi::PartialPreParse(UC16CharacterStream* source, 5148 ScriptDataImpl* ParserApi::PartialPreParse(UC16CharacterStream* source,
5150 v8::Extension* extension, 5149 v8::Extension* extension,
5151 bool harmony_scoping) { 5150 int flags) {
5152 bool allow_lazy = FLAG_lazy && (extension == NULL); 5151 bool allow_lazy = FLAG_lazy && (extension == NULL);
5153 if (!allow_lazy) { 5152 if (!allow_lazy) {
5154 // Partial preparsing is only about lazily compiled functions. 5153 // Partial preparsing is only about lazily compiled functions.
5155 // If we don't allow lazy compilation, the log data will be empty. 5154 // If we don't allow lazy compilation, the log data will be empty.
5156 return NULL; 5155 return NULL;
5157 } 5156 }
5157 flags |= kAllowLazy;
5158 PartialParserRecorder recorder; 5158 PartialParserRecorder recorder;
5159 return DoPreParse(source, allow_lazy, &recorder, harmony_scoping); 5159 return DoPreParse(source, flags, &recorder);
5160 } 5160 }
5161 5161
5162 5162
5163 ScriptDataImpl* ParserApi::PreParse(UC16CharacterStream* source, 5163 ScriptDataImpl* ParserApi::PreParse(UC16CharacterStream* source,
5164 v8::Extension* extension, 5164 v8::Extension* extension,
5165 bool harmony_scoping) { 5165 int flags) {
5166 Handle<Script> no_script; 5166 Handle<Script> no_script;
5167 bool allow_lazy = FLAG_lazy && (extension == NULL); 5167 if (FLAG_lazy && (extension == NULL)) {
5168 flags |= kAllowLazy;
5169 }
5168 CompleteParserRecorder recorder; 5170 CompleteParserRecorder recorder;
5169 return DoPreParse(source, allow_lazy, &recorder, harmony_scoping); 5171 return DoPreParse(source, flags, &recorder);
5170 } 5172 }
5171 5173
5172 5174
5173 bool RegExpParser::ParseRegExp(FlatStringReader* input, 5175 bool RegExpParser::ParseRegExp(FlatStringReader* input,
5174 bool multiline, 5176 bool multiline,
5175 RegExpCompileData* result) { 5177 RegExpCompileData* result) {
5176 ASSERT(result != NULL); 5178 ASSERT(result != NULL);
5177 RegExpParser parser(input, &result->error, multiline); 5179 RegExpParser parser(input, &result->error, multiline);
5178 RegExpTree* tree = parser.ParsePattern(); 5180 RegExpTree* tree = parser.ParsePattern();
5179 if (parser.failed()) { 5181 if (parser.failed()) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
5230 result = parser.ParseProgram(source, 5232 result = parser.ParseProgram(source,
5231 info->is_global(), 5233 info->is_global(),
5232 info->StrictMode()); 5234 info->StrictMode());
5233 } 5235 }
5234 } 5236 }
5235 info->SetFunction(result); 5237 info->SetFunction(result);
5236 return (result != NULL); 5238 return (result != NULL);
5237 } 5239 }
5238 5240
5239 } } // namespace v8::internal 5241 } } // 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