OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 const char* error_source = "var x = y z;"; | 206 const char* error_source = "var x = y z;"; |
207 int error_source_length = i::StrLength(error_source); | 207 int error_source_length = i::StrLength(error_source); |
208 | 208 |
209 v8::ScriptData* preparse = v8::ScriptData::PreCompile(v8::String::NewFromUtf8( | 209 v8::ScriptData* preparse = v8::ScriptData::PreCompile(v8::String::NewFromUtf8( |
210 isolate, source, v8::String::kNormalString, source_length)); | 210 isolate, source, v8::String::kNormalString, source_length)); |
211 CHECK(!preparse->HasError()); | 211 CHECK(!preparse->HasError()); |
212 bool lazy_flag = i::FLAG_lazy; | 212 bool lazy_flag = i::FLAG_lazy; |
213 { | 213 { |
214 i::FLAG_lazy = true; | 214 i::FLAG_lazy = true; |
215 ScriptResource* resource = new ScriptResource(source, source_length); | 215 ScriptResource* resource = new ScriptResource(source, source_length); |
216 v8::ScriptCompiler::Source script_source( | 216 v8::Local<v8::String> script_source = |
217 v8::String::NewExternal(isolate, resource), | 217 v8::String::NewExternal(isolate, resource); |
218 v8::ScriptCompiler::CachedData( | 218 v8::Script::Compile(script_source, NULL, preparse); |
219 reinterpret_cast<const uint8_t*>(preparse->Data()), | |
220 preparse->Length())); | |
221 v8::ScriptCompiler::Compile(isolate, | |
222 v8::ScriptCompiler::Source(script_source)); | |
223 } | 219 } |
224 | 220 |
225 { | 221 { |
226 i::FLAG_lazy = false; | 222 i::FLAG_lazy = false; |
227 | 223 |
228 ScriptResource* resource = new ScriptResource(source, source_length); | 224 ScriptResource* resource = new ScriptResource(source, source_length); |
229 v8::ScriptCompiler::Source script_source( | 225 v8::Local<v8::String> script_source = |
230 v8::String::NewExternal(isolate, resource), | 226 v8::String::NewExternal(isolate, resource); |
231 v8::ScriptCompiler::CachedData( | 227 v8::Script::New(script_source, NULL, preparse); |
232 reinterpret_cast<const uint8_t*>(preparse->Data()), | |
233 preparse->Length())); | |
234 v8::ScriptCompiler::CompileUnbound(isolate, script_source); | |
235 } | 228 } |
236 delete preparse; | 229 delete preparse; |
237 i::FLAG_lazy = lazy_flag; | 230 i::FLAG_lazy = lazy_flag; |
238 | 231 |
239 // Syntax error. | 232 // Syntax error. |
240 v8::ScriptData* error_preparse = v8::ScriptData::PreCompile( | 233 v8::ScriptData* error_preparse = v8::ScriptData::PreCompile( |
241 v8::String::NewFromUtf8(isolate, | 234 v8::String::NewFromUtf8(isolate, |
242 error_source, | 235 error_source, |
243 v8::String::kNormalString, | 236 v8::String::kNormalString, |
244 error_source_length)); | 237 error_source_length)); |
(...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2356 | 2349 |
2357 const char* statement_data[] = { | 2350 const char* statement_data[] = { |
2358 statement, | 2351 statement, |
2359 NULL | 2352 NULL |
2360 }; | 2353 }; |
2361 | 2354 |
2362 // The test is quite slow, so run it with a reduced set of flags. | 2355 // The test is quite slow, so run it with a reduced set of flags. |
2363 static const ParserFlag empty_flags[] = {kAllowLazy}; | 2356 static const ParserFlag empty_flags[] = {kAllowLazy}; |
2364 RunParserSyncTest(context_data, statement_data, kError, empty_flags, 1); | 2357 RunParserSyncTest(context_data, statement_data, kError, empty_flags, 1); |
2365 } | 2358 } |
OLD | NEW |