OLD | NEW |
1 // Copyright 2017 the V8 project authors. All rights reserved. | 1 // Copyright 2017 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 "src/ast/ast.h" | 5 #include "src/ast/ast.h" |
6 #include "src/compiler.h" | 6 #include "src/compiler.h" |
7 #include "src/objects-inl.h" | 7 #include "src/objects-inl.h" |
8 #include "src/parsing/parse-info.h" | 8 #include "src/parsing/parse-info.h" |
9 #include "src/parsing/parsing.h" | 9 #include "src/parsing/parsing.h" |
10 | 10 |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 i::SNPrintF(lazy_program + prefix_len + inner_function_len + params_len + | 317 i::SNPrintF(lazy_program + prefix_len + inner_function_len + params_len + |
318 source_len, | 318 source_len, |
319 "%s", suffix); | 319 "%s", suffix); |
320 | 320 |
321 i::Handle<i::String> source = | 321 i::Handle<i::String> source = |
322 factory->InternalizeUtf8String(lazy_program.start()); | 322 factory->InternalizeUtf8String(lazy_program.start()); |
323 source->PrintOn(stdout); | 323 source->PrintOn(stdout); |
324 printf("\n"); | 324 printf("\n"); |
325 | 325 |
326 i::Handle<i::Script> script = factory->NewScript(source); | 326 i::Handle<i::Script> script = factory->NewScript(source); |
327 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 327 i::ParseInfo lazy_info(script); |
328 i::ParseInfo lazy_info(&zone, script); | |
329 | 328 |
330 // No need to run scope analysis; preparser scope data is produced when | 329 // No need to run scope analysis; preparser scope data is produced when |
331 // parsing. | 330 // parsing. |
332 CHECK(i::parsing::ParseProgram(&lazy_info)); | 331 CHECK(i::parsing::ParseProgram(&lazy_info)); |
333 | 332 |
334 // Then parse eagerly and check against the scope data. | 333 // Then parse eagerly and check against the scope data. |
335 inner_function = eager_inner; | 334 inner_function = eager_inner; |
336 inner_function_len = Utf8LengthHelper(inner_function) - 4; | 335 inner_function_len = Utf8LengthHelper(inner_function) - 4; |
337 len = | 336 len = |
338 prefix_len + inner_function_len + params_len + source_len + suffix_len; | 337 prefix_len + inner_function_len + params_len + source_len + suffix_len; |
339 | 338 |
340 i::ScopedVector<char> eager_program(len + 1); | 339 i::ScopedVector<char> eager_program(len + 1); |
341 i::SNPrintF(eager_program, "%s", prefix); | 340 i::SNPrintF(eager_program, "%s", prefix); |
342 i::SNPrintF(eager_program + prefix_len, inner_function, inners[i].params, | 341 i::SNPrintF(eager_program + prefix_len, inner_function, inners[i].params, |
343 inners[i].source); | 342 inners[i].source); |
344 i::SNPrintF(eager_program + prefix_len + inner_function_len + params_len + | 343 i::SNPrintF(eager_program + prefix_len + inner_function_len + params_len + |
345 source_len, | 344 source_len, |
346 "%s", suffix); | 345 "%s", suffix); |
347 | 346 |
348 source = factory->InternalizeUtf8String(eager_program.start()); | 347 source = factory->InternalizeUtf8String(eager_program.start()); |
349 source->PrintOn(stdout); | 348 source->PrintOn(stdout); |
350 printf("\n"); | 349 printf("\n"); |
351 | 350 |
352 script = factory->NewScript(source); | 351 script = factory->NewScript(source); |
353 i::ParseInfo eager_info(&zone, script); | 352 i::ParseInfo eager_info(script); |
354 eager_info.set_allow_lazy_parsing(false); | 353 eager_info.set_allow_lazy_parsing(false); |
355 | 354 |
356 CHECK(i::parsing::ParseProgram(&eager_info)); | 355 CHECK(i::parsing::ParseProgram(&eager_info)); |
357 CHECK(i::Compiler::Analyze(&eager_info)); | 356 CHECK(i::Compiler::Analyze(&eager_info)); |
358 | 357 |
359 i::Scope* scope = | 358 i::Scope* scope = |
360 eager_info.literal()->scope()->inner_scope()->inner_scope(); | 359 eager_info.literal()->scope()->inner_scope()->inner_scope(); |
361 DCHECK_NOT_NULL(scope); | 360 DCHECK_NOT_NULL(scope); |
362 DCHECK_NULL(scope->sibling()); | 361 DCHECK_NULL(scope->sibling()); |
363 DCHECK(scope->is_function_scope()); | 362 DCHECK(scope->is_function_scope()); |
364 | 363 |
365 size_t index = 0; | 364 size_t index = 0; |
366 i::ScopeTestHelper::CompareScopeToData( | 365 i::ScopeTestHelper::CompareScopeToData( |
367 scope, lazy_info.preparsed_scope_data(), index, | 366 scope, lazy_info.preparsed_scope_data(), index, |
368 inners[i].precise_maybe_assigned); | 367 inners[i].precise_maybe_assigned); |
369 } | 368 } |
370 } | 369 } |
OLD | NEW |