| 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 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 int kProgramByteSize = i::StrLength(surroundings[j].prefix) + | 797 int kProgramByteSize = i::StrLength(surroundings[j].prefix) + |
| 798 i::StrLength(surroundings[j].suffix) + | 798 i::StrLength(surroundings[j].suffix) + |
| 799 i::StrLength(source_data[i].body); | 799 i::StrLength(source_data[i].body); |
| 800 i::ScopedVector<char> program(kProgramByteSize + 1); | 800 i::ScopedVector<char> program(kProgramByteSize + 1); |
| 801 i::SNPrintF(program, "%s%s%s", surroundings[j].prefix, | 801 i::SNPrintF(program, "%s%s%s", surroundings[j].prefix, |
| 802 source_data[i].body, surroundings[j].suffix); | 802 source_data[i].body, surroundings[j].suffix); |
| 803 i::Handle<i::String> source = | 803 i::Handle<i::String> source = |
| 804 factory->NewStringFromUtf8(i::CStrVector(program.start())) | 804 factory->NewStringFromUtf8(i::CStrVector(program.start())) |
| 805 .ToHandleChecked(); | 805 .ToHandleChecked(); |
| 806 i::Handle<i::Script> script = factory->NewScript(source); | 806 i::Handle<i::Script> script = factory->NewScript(source); |
| 807 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 807 i::ParseInfo info(script); |
| 808 i::ParseInfo info(&zone, script); | |
| 809 // The information we're checking is only produced when eager parsing. | 808 // The information we're checking is only produced when eager parsing. |
| 810 info.set_allow_lazy_parsing(false); | 809 info.set_allow_lazy_parsing(false); |
| 811 CHECK(i::parsing::ParseProgram(&info)); | 810 CHECK(i::parsing::ParseProgram(&info)); |
| 812 CHECK(i::Rewriter::Rewrite(&info)); | 811 CHECK(i::Rewriter::Rewrite(&info)); |
| 813 i::DeclarationScope::Analyze(&info, i::AnalyzeMode::kRegular); | 812 i::DeclarationScope::Analyze(&info, i::AnalyzeMode::kRegular); |
| 814 CHECK(info.literal() != NULL); | 813 CHECK(info.literal() != NULL); |
| 815 | 814 |
| 816 i::DeclarationScope* script_scope = info.literal()->scope(); | 815 i::DeclarationScope* script_scope = info.literal()->scope(); |
| 817 CHECK(script_scope->is_script_scope()); | 816 CHECK(script_scope->is_script_scope()); |
| 818 | 817 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 std::string full_source = "function f() { return "; | 853 std::string full_source = "function f() { return "; |
| 855 full_source += source; | 854 full_source += source; |
| 856 full_source += "; }"; | 855 full_source += "; }"; |
| 857 | 856 |
| 858 i::Handle<i::String> source_code = | 857 i::Handle<i::String> source_code = |
| 859 factory->NewStringFromUtf8(i::CStrVector(full_source.c_str())) | 858 factory->NewStringFromUtf8(i::CStrVector(full_source.c_str())) |
| 860 .ToHandleChecked(); | 859 .ToHandleChecked(); |
| 861 | 860 |
| 862 i::Handle<i::Script> script = factory->NewScript(source_code); | 861 i::Handle<i::Script> script = factory->NewScript(source_code); |
| 863 | 862 |
| 864 i::ParseInfo info(handles.main_zone(), script); | 863 i::ParseInfo info(script); |
| 865 i::Parser parser(&info); | 864 i::Parser parser(&info); |
| 866 info.set_allow_lazy_parsing(false); | 865 info.set_allow_lazy_parsing(false); |
| 867 info.set_toplevel(true); | 866 info.set_toplevel(true); |
| 868 | 867 |
| 869 CHECK(i::Compiler::ParseAndAnalyze(&info)); | 868 CHECK(i::Compiler::ParseAndAnalyze(&info)); |
| 870 | 869 |
| 871 CHECK_EQ(1, info.scope()->declarations()->LengthForTest()); | 870 CHECK_EQ(1, info.scope()->declarations()->LengthForTest()); |
| 872 i::Declaration* decl = info.scope()->declarations()->AtForTest(0); | 871 i::Declaration* decl = info.scope()->declarations()->AtForTest(0); |
| 873 i::FunctionLiteral* fun = decl->AsFunctionDeclaration()->fun(); | 872 i::FunctionLiteral* fun = decl->AsFunctionDeclaration()->fun(); |
| 874 CHECK(fun->body()->length() == 1); | 873 CHECK(fun->body()->length() == 1); |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1152 i::SNPrintF(program, "%s%s%s", | 1151 i::SNPrintF(program, "%s%s%s", |
| 1153 source_data[i].outer_prefix, | 1152 source_data[i].outer_prefix, |
| 1154 source_data[i].inner_source, | 1153 source_data[i].inner_source, |
| 1155 source_data[i].outer_suffix); | 1154 source_data[i].outer_suffix); |
| 1156 | 1155 |
| 1157 // Parse program source. | 1156 // Parse program source. |
| 1158 i::Handle<i::String> source = factory->NewStringFromUtf8( | 1157 i::Handle<i::String> source = factory->NewStringFromUtf8( |
| 1159 i::CStrVector(program.start())).ToHandleChecked(); | 1158 i::CStrVector(program.start())).ToHandleChecked(); |
| 1160 CHECK_EQ(source->length(), kProgramSize); | 1159 CHECK_EQ(source->length(), kProgramSize); |
| 1161 i::Handle<i::Script> script = factory->NewScript(source); | 1160 i::Handle<i::Script> script = factory->NewScript(source); |
| 1162 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 1161 i::ParseInfo info(script); |
| 1163 i::ParseInfo info(&zone, script); | |
| 1164 info.set_language_mode(source_data[i].language_mode); | 1162 info.set_language_mode(source_data[i].language_mode); |
| 1165 i::parsing::ParseProgram(&info); | 1163 i::parsing::ParseProgram(&info); |
| 1166 CHECK_NOT_NULL(info.literal()); | 1164 CHECK_NOT_NULL(info.literal()); |
| 1167 | 1165 |
| 1168 // Check scope types and positions. | 1166 // Check scope types and positions. |
| 1169 i::Scope* scope = info.literal()->scope(); | 1167 i::Scope* scope = info.literal()->scope(); |
| 1170 CHECK(scope->is_script_scope()); | 1168 CHECK(scope->is_script_scope()); |
| 1171 CHECK_EQ(scope->start_position(), 0); | 1169 CHECK_EQ(scope->start_position(), 0); |
| 1172 CHECK_EQ(scope->end_position(), kProgramSize); | 1170 CHECK_EQ(scope->end_position(), kProgramSize); |
| 1173 | 1171 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1199 i::Isolate* isolate = CcTest::i_isolate(); | 1197 i::Isolate* isolate = CcTest::i_isolate(); |
| 1200 i::Factory* factory = isolate->factory(); | 1198 i::Factory* factory = isolate->factory(); |
| 1201 v8::HandleScope handles(CcTest::isolate()); | 1199 v8::HandleScope handles(CcTest::isolate()); |
| 1202 i::FunctionLiteral* function; | 1200 i::FunctionLiteral* function; |
| 1203 | 1201 |
| 1204 for (int i = 0; discard_sources[i]; i++) { | 1202 for (int i = 0; discard_sources[i]; i++) { |
| 1205 const char* source = discard_sources[i]; | 1203 const char* source = discard_sources[i]; |
| 1206 i::Handle<i::String> source_code = | 1204 i::Handle<i::String> source_code = |
| 1207 factory->NewStringFromUtf8(i::CStrVector(source)).ToHandleChecked(); | 1205 factory->NewStringFromUtf8(i::CStrVector(source)).ToHandleChecked(); |
| 1208 i::Handle<i::Script> script = factory->NewScript(source_code); | 1206 i::Handle<i::Script> script = factory->NewScript(source_code); |
| 1209 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 1207 i::ParseInfo info(script); |
| 1210 i::ParseInfo info(&zone, script); | |
| 1211 i::parsing::ParseProgram(&info); | 1208 i::parsing::ParseProgram(&info); |
| 1212 function = info.literal(); | 1209 function = info.literal(); |
| 1213 CHECK_NOT_NULL(function); | 1210 CHECK_NOT_NULL(function); |
| 1214 CHECK_NOT_NULL(function->body()); | 1211 CHECK_NOT_NULL(function->body()); |
| 1215 CHECK_EQ(1, function->body()->length()); | 1212 CHECK_EQ(1, function->body()->length()); |
| 1216 i::FunctionLiteral* inner = | 1213 i::FunctionLiteral* inner = |
| 1217 function->body()->first()->AsExpressionStatement()->expression()-> | 1214 function->body()->first()->AsExpressionStatement()->expression()-> |
| 1218 AsCall()->expression()->AsFunctionLiteral(); | 1215 AsCall()->expression()->AsFunctionLiteral(); |
| 1219 i::Scope* inner_scope = inner->scope(); | 1216 i::Scope* inner_scope = inner->scope(); |
| 1220 i::FunctionLiteral* fun = nullptr; | 1217 i::FunctionLiteral* fun = nullptr; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 scanner.Initialize(stream.get()); | 1327 scanner.Initialize(stream.get()); |
| 1331 i::PreParser::PreParseResult result = | 1328 i::PreParser::PreParseResult result = |
| 1332 preparser.PreParseProgram(&preparser_materialized_literals, is_module); | 1329 preparser.PreParseProgram(&preparser_materialized_literals, is_module); |
| 1333 CHECK_EQ(i::PreParser::kPreParseSuccess, result); | 1330 CHECK_EQ(i::PreParser::kPreParseSuccess, result); |
| 1334 } | 1331 } |
| 1335 | 1332 |
| 1336 // Parse the data | 1333 // Parse the data |
| 1337 i::FunctionLiteral* function; | 1334 i::FunctionLiteral* function; |
| 1338 { | 1335 { |
| 1339 i::Handle<i::Script> script = factory->NewScript(source); | 1336 i::Handle<i::Script> script = factory->NewScript(source); |
| 1340 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 1337 i::ParseInfo info(script); |
| 1341 i::ParseInfo info(&zone, script); | |
| 1342 info.set_allow_lazy_parsing(flags.Contains(kAllowLazy)); | 1338 info.set_allow_lazy_parsing(flags.Contains(kAllowLazy)); |
| 1343 SetGlobalFlags(flags); | 1339 SetGlobalFlags(flags); |
| 1344 if (is_module) info.set_module(); | 1340 if (is_module) info.set_module(); |
| 1345 i::parsing::ParseProgram(&info); | 1341 i::parsing::ParseProgram(&info); |
| 1346 function = info.literal(); | 1342 function = info.literal(); |
| 1347 if (function) { | 1343 if (function) { |
| 1348 parser_materialized_literals = function->materialized_literal_count(); | 1344 parser_materialized_literals = function->materialized_literal_count(); |
| 1349 } | 1345 } |
| 1350 } | 1346 } |
| 1351 | 1347 |
| (...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2458 {"function lazy() { var x = {get foo(){} } }", 1}, | 2454 {"function lazy() { var x = {get foo(){} } }", 1}, |
| 2459 {NULL, 0} | 2455 {NULL, 0} |
| 2460 }; | 2456 }; |
| 2461 | 2457 |
| 2462 for (int i = 0; test_cases[i].program; i++) { | 2458 for (int i = 0; test_cases[i].program; i++) { |
| 2463 const char* program = test_cases[i].program; | 2459 const char* program = test_cases[i].program; |
| 2464 i::Factory* factory = CcTest::i_isolate()->factory(); | 2460 i::Factory* factory = CcTest::i_isolate()->factory(); |
| 2465 i::Handle<i::String> source = | 2461 i::Handle<i::String> source = |
| 2466 factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked(); | 2462 factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked(); |
| 2467 i::Handle<i::Script> script = factory->NewScript(source); | 2463 i::Handle<i::Script> script = factory->NewScript(source); |
| 2468 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 2464 i::ParseInfo info(script); |
| 2469 i::ParseInfo info(&zone, script); | |
| 2470 i::ScriptData* sd = NULL; | 2465 i::ScriptData* sd = NULL; |
| 2471 info.set_cached_data(&sd); | 2466 info.set_cached_data(&sd); |
| 2472 info.set_compile_options(v8::ScriptCompiler::kProduceParserCache); | 2467 info.set_compile_options(v8::ScriptCompiler::kProduceParserCache); |
| 2473 i::parsing::ParseProgram(&info); | 2468 i::parsing::ParseProgram(&info); |
| 2474 i::ParseData* pd = i::ParseData::FromCachedData(sd); | 2469 i::ParseData* pd = i::ParseData::FromCachedData(sd); |
| 2475 | 2470 |
| 2476 if (pd->FunctionCount() != test_cases[i].functions) { | 2471 if (pd->FunctionCount() != test_cases[i].functions) { |
| 2477 v8::base::OS::Print( | 2472 v8::base::OS::Print( |
| 2478 "Expected preparse data for program:\n" | 2473 "Expected preparse data for program:\n" |
| 2479 "\t%s\n" | 2474 "\t%s\n" |
| (...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3346 if (outers[i].strict && inners[j].with) continue; | 3341 if (outers[i].strict && inners[j].with) continue; |
| 3347 const char* inner = inners[j].source; | 3342 const char* inner = inners[j].source; |
| 3348 int inner_len = Utf8LengthHelper(inner); | 3343 int inner_len = Utf8LengthHelper(inner); |
| 3349 | 3344 |
| 3350 int len = prefix_len + outer_len + midfix_len + inner_len + suffix_len; | 3345 int len = prefix_len + outer_len + midfix_len + inner_len + suffix_len; |
| 3351 i::ScopedVector<char> program(len + 1); | 3346 i::ScopedVector<char> program(len + 1); |
| 3352 | 3347 |
| 3353 i::SNPrintF(program, "%s%s%s%s%s", prefix, outer, midfix, inner, | 3348 i::SNPrintF(program, "%s%s%s%s%s", prefix, outer, midfix, inner, |
| 3354 suffix); | 3349 suffix); |
| 3355 | 3350 |
| 3356 i::Zone zone(isolate->allocator(), ZONE_NAME); | |
| 3357 std::unique_ptr<i::ParseInfo> info; | 3351 std::unique_ptr<i::ParseInfo> info; |
| 3358 if (lazy) { | 3352 if (lazy) { |
| 3359 printf("%s\n", program.start()); | 3353 printf("%s\n", program.start()); |
| 3360 v8::Local<v8::Value> v = CompileRun(program.start()); | 3354 v8::Local<v8::Value> v = CompileRun(program.start()); |
| 3361 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); | 3355 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); |
| 3362 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); | 3356 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); |
| 3363 i::Handle<i::SharedFunctionInfo> shared = i::handle(f->shared()); | 3357 i::Handle<i::SharedFunctionInfo> shared = i::handle(f->shared()); |
| 3364 info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(&zone, shared)); | 3358 info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(shared)); |
| 3365 CHECK(i::parsing::ParseFunction(info.get())); | 3359 CHECK(i::parsing::ParseFunction(info.get())); |
| 3366 } else { | 3360 } else { |
| 3367 i::Handle<i::String> source = | 3361 i::Handle<i::String> source = |
| 3368 factory->InternalizeUtf8String(program.start()); | 3362 factory->InternalizeUtf8String(program.start()); |
| 3369 source->PrintOn(stdout); | 3363 source->PrintOn(stdout); |
| 3370 printf("\n"); | 3364 printf("\n"); |
| 3371 i::Handle<i::Script> script = factory->NewScript(source); | 3365 i::Handle<i::Script> script = factory->NewScript(source); |
| 3372 info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(&zone, script)); | 3366 info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(script)); |
| 3373 info->set_allow_lazy_parsing(false); | 3367 info->set_allow_lazy_parsing(false); |
| 3374 CHECK(i::parsing::ParseProgram(info.get())); | 3368 CHECK(i::parsing::ParseProgram(info.get())); |
| 3375 } | 3369 } |
| 3376 CHECK(i::Compiler::Analyze(info.get())); | 3370 CHECK(i::Compiler::Analyze(info.get())); |
| 3377 CHECK(info->literal() != NULL); | 3371 CHECK(info->literal() != NULL); |
| 3378 | 3372 |
| 3379 i::Scope* scope = info->literal()->scope(); | 3373 i::Scope* scope = info->literal()->scope(); |
| 3380 if (!lazy) { | 3374 if (!lazy) { |
| 3381 scope = scope->inner_scope(); | 3375 scope = scope->inner_scope(); |
| 3382 } | 3376 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3461 | 3455 |
| 3462 const char* suffix = "; f"; | 3456 const char* suffix = "; f"; |
| 3463 | 3457 |
| 3464 for (unsigned i = 0; i < arraysize(tests); ++i) { | 3458 for (unsigned i = 0; i < arraysize(tests); ++i) { |
| 3465 bool assigned = tests[i].arg_assigned; | 3459 bool assigned = tests[i].arg_assigned; |
| 3466 const char* source = tests[i].source; | 3460 const char* source = tests[i].source; |
| 3467 for (unsigned allow_lazy = 0; allow_lazy < 2; ++allow_lazy) { | 3461 for (unsigned allow_lazy = 0; allow_lazy < 2; ++allow_lazy) { |
| 3468 i::ScopedVector<char> program(Utf8LengthHelper(source) + | 3462 i::ScopedVector<char> program(Utf8LengthHelper(source) + |
| 3469 Utf8LengthHelper(suffix) + 1); | 3463 Utf8LengthHelper(suffix) + 1); |
| 3470 i::SNPrintF(program, "%s%s", source, suffix); | 3464 i::SNPrintF(program, "%s%s", source, suffix); |
| 3471 i::Zone zone(isolate->allocator(), ZONE_NAME); | |
| 3472 std::unique_ptr<i::ParseInfo> info; | 3465 std::unique_ptr<i::ParseInfo> info; |
| 3473 printf("%s\n", program.start()); | 3466 printf("%s\n", program.start()); |
| 3474 v8::Local<v8::Value> v = CompileRun(program.start()); | 3467 v8::Local<v8::Value> v = CompileRun(program.start()); |
| 3475 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); | 3468 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); |
| 3476 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); | 3469 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); |
| 3477 i::Handle<i::SharedFunctionInfo> shared = i::handle(f->shared()); | 3470 i::Handle<i::SharedFunctionInfo> shared = i::handle(f->shared()); |
| 3478 info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(&zone, shared)); | 3471 info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(shared)); |
| 3479 info->set_allow_lazy_parsing(allow_lazy); | 3472 info->set_allow_lazy_parsing(allow_lazy); |
| 3480 CHECK(i::parsing::ParseFunction(info.get())); | 3473 CHECK(i::parsing::ParseFunction(info.get())); |
| 3481 CHECK(i::Compiler::Analyze(info.get())); | 3474 CHECK(i::Compiler::Analyze(info.get())); |
| 3482 CHECK_NOT_NULL(info->literal()); | 3475 CHECK_NOT_NULL(info->literal()); |
| 3483 | 3476 |
| 3484 i::Scope* scope = info->literal()->scope(); | 3477 i::Scope* scope = info->literal()->scope(); |
| 3485 CHECK(!scope->AsDeclarationScope()->was_lazily_parsed()); | 3478 CHECK(!scope->AsDeclarationScope()->was_lazily_parsed()); |
| 3486 CHECK_NULL(scope->sibling()); | 3479 CHECK_NULL(scope->sibling()); |
| 3487 CHECK(scope->is_function_scope()); | 3480 CHECK(scope->is_function_scope()); |
| 3488 const i::AstRawString* var_name = | 3481 const i::AstRawString* var_name = |
| 3489 info->ast_value_factory()->GetOneByteString("arg"); | 3482 info->ast_value_factory()->GetOneByteString("arg"); |
| 3490 i::Variable* var = scope->Lookup(var_name); | 3483 i::Variable* var = scope->Lookup(var_name); |
| 3491 CHECK(var->is_used() || !assigned); | 3484 CHECK(var->is_used() || !assigned); |
| 3492 bool is_maybe_assigned = var->maybe_assigned() == i::kMaybeAssigned; | 3485 bool is_maybe_assigned = var->maybe_assigned() == i::kMaybeAssigned; |
| 3493 CHECK_EQ(is_maybe_assigned, assigned); | 3486 CHECK_EQ(is_maybe_assigned, assigned); |
| 3494 } | 3487 } |
| 3495 } | 3488 } |
| 3496 } | 3489 } |
| 3497 | 3490 |
| 3498 struct Input { | 3491 struct Input { |
| 3499 bool assigned; | 3492 bool assigned; |
| 3500 std::string source; | 3493 std::string source; |
| 3501 std::vector<unsigned> location; // "Directions" to the relevant scope. | 3494 std::vector<unsigned> location; // "Directions" to the relevant scope. |
| 3502 }; | 3495 }; |
| 3503 | 3496 |
| 3504 static void TestMaybeAssigned(i::Zone* zone, Input input, const char* variable, | 3497 static void TestMaybeAssigned(Input input, const char* variable, bool module, |
| 3505 bool module, bool allow_lazy_parsing) { | 3498 bool allow_lazy_parsing) { |
| 3506 i::Factory* factory = CcTest::i_isolate()->factory(); | 3499 i::Factory* factory = CcTest::i_isolate()->factory(); |
| 3507 i::Handle<i::String> string = | 3500 i::Handle<i::String> string = |
| 3508 factory->InternalizeUtf8String(input.source.c_str()); | 3501 factory->InternalizeUtf8String(input.source.c_str()); |
| 3509 string->PrintOn(stdout); | 3502 string->PrintOn(stdout); |
| 3510 printf("\n"); | 3503 printf("\n"); |
| 3511 i::Handle<i::Script> script = factory->NewScript(string); | 3504 i::Handle<i::Script> script = factory->NewScript(string); |
| 3512 | 3505 |
| 3513 std::unique_ptr<i::ParseInfo> info; | 3506 std::unique_ptr<i::ParseInfo> info; |
| 3514 info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(zone, script)); | 3507 info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(script)); |
| 3515 info->set_module(module); | 3508 info->set_module(module); |
| 3516 info->set_allow_lazy_parsing(allow_lazy_parsing); | 3509 info->set_allow_lazy_parsing(allow_lazy_parsing); |
| 3517 | 3510 |
| 3518 CHECK(i::parsing::ParseProgram(info.get())); | 3511 CHECK(i::parsing::ParseProgram(info.get())); |
| 3519 CHECK(i::Compiler::Analyze(info.get())); | 3512 CHECK(i::Compiler::Analyze(info.get())); |
| 3520 | 3513 |
| 3521 CHECK_NOT_NULL(info->literal()); | 3514 CHECK_NOT_NULL(info->literal()); |
| 3522 i::Scope* scope = info->literal()->scope(); | 3515 i::Scope* scope = info->literal()->scope(); |
| 3523 CHECK(!scope->AsDeclarationScope()->was_lazily_parsed()); | 3516 CHECK(!scope->AsDeclarationScope()->was_lazily_parsed()); |
| 3524 CHECK_NULL(scope->sibling()); | 3517 CHECK_NULL(scope->sibling()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3553 for (auto n : input.location) { | 3546 for (auto n : input.location) { |
| 3554 result.location.push_back(n); | 3547 result.location.push_back(n); |
| 3555 } | 3548 } |
| 3556 return result; | 3549 return result; |
| 3557 } | 3550 } |
| 3558 | 3551 |
| 3559 TEST(MaybeAssignedInsideLoop) { | 3552 TEST(MaybeAssignedInsideLoop) { |
| 3560 i::Isolate* isolate = CcTest::i_isolate(); | 3553 i::Isolate* isolate = CcTest::i_isolate(); |
| 3561 i::HandleScope scope(isolate); | 3554 i::HandleScope scope(isolate); |
| 3562 LocalContext env; | 3555 LocalContext env; |
| 3563 i::Zone zone(isolate->allocator(), ZONE_NAME); | |
| 3564 | 3556 |
| 3565 std::vector<unsigned> top; // Can't use {} in initializers below. | 3557 std::vector<unsigned> top; // Can't use {} in initializers below. |
| 3566 | 3558 |
| 3567 Input module_and_script_tests[] = { | 3559 Input module_and_script_tests[] = { |
| 3568 {1, "for (j=x; j<10; ++j) { foo = j }", top}, | 3560 {1, "for (j=x; j<10; ++j) { foo = j }", top}, |
| 3569 {1, "for (j=x; j<10; ++j) { [foo] = [j] }", top}, | 3561 {1, "for (j=x; j<10; ++j) { [foo] = [j] }", top}, |
| 3570 {1, "for (j=x; j<10; ++j) { var foo = j }", top}, | 3562 {1, "for (j=x; j<10; ++j) { var foo = j }", top}, |
| 3571 {1, "for (j=x; j<10; ++j) { var [foo] = [j] }", top}, | 3563 {1, "for (j=x; j<10; ++j) { var [foo] = [j] }", top}, |
| 3572 {0, "for (j=x; j<10; ++j) { let foo = j }", {0}}, | 3564 {0, "for (j=x; j<10; ++j) { let foo = j }", {0}}, |
| 3573 {0, "for (j=x; j<10; ++j) { let [foo] = [j] }", {0}}, | 3565 {0, "for (j=x; j<10; ++j) { let [foo] = [j] }", {0}}, |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3831 {1, "for (const {j} in x) { function foo() {return j} }", top}, | 3823 {1, "for (const {j} in x) { function foo() {return j} }", top}, |
| 3832 {1, "while (j) { function foo() {return j} }", top}, | 3824 {1, "while (j) { function foo() {return j} }", top}, |
| 3833 {1, "do { function foo() {return j} } while (j)", top}, | 3825 {1, "do { function foo() {return j} } while (j)", top}, |
| 3834 }; | 3826 }; |
| 3835 | 3827 |
| 3836 for (unsigned i = 0; i < arraysize(module_and_script_tests); ++i) { | 3828 for (unsigned i = 0; i < arraysize(module_and_script_tests); ++i) { |
| 3837 Input input = module_and_script_tests[i]; | 3829 Input input = module_and_script_tests[i]; |
| 3838 for (unsigned module = 0; module <= 1; ++module) { | 3830 for (unsigned module = 0; module <= 1; ++module) { |
| 3839 for (unsigned allow_lazy_parsing = 0; allow_lazy_parsing <= 1; | 3831 for (unsigned allow_lazy_parsing = 0; allow_lazy_parsing <= 1; |
| 3840 ++allow_lazy_parsing) { | 3832 ++allow_lazy_parsing) { |
| 3841 TestMaybeAssigned(&zone, input, "foo", module, allow_lazy_parsing); | 3833 TestMaybeAssigned(input, "foo", module, allow_lazy_parsing); |
| 3842 } | 3834 } |
| 3843 TestMaybeAssigned(&zone, wrap(input), "foo", module, false); | 3835 TestMaybeAssigned(wrap(input), "foo", module, false); |
| 3844 } | 3836 } |
| 3845 } | 3837 } |
| 3846 | 3838 |
| 3847 for (unsigned i = 0; i < arraysize(script_only_tests); ++i) { | 3839 for (unsigned i = 0; i < arraysize(script_only_tests); ++i) { |
| 3848 Input input = script_only_tests[i]; | 3840 Input input = script_only_tests[i]; |
| 3849 for (unsigned allow_lazy_parsing = 0; allow_lazy_parsing <= 1; | 3841 for (unsigned allow_lazy_parsing = 0; allow_lazy_parsing <= 1; |
| 3850 ++allow_lazy_parsing) { | 3842 ++allow_lazy_parsing) { |
| 3851 TestMaybeAssigned(&zone, input, "foo", false, allow_lazy_parsing); | 3843 TestMaybeAssigned(input, "foo", false, allow_lazy_parsing); |
| 3852 } | 3844 } |
| 3853 TestMaybeAssigned(&zone, wrap(input), "foo", false, false); | 3845 TestMaybeAssigned(wrap(input), "foo", false, false); |
| 3854 } | 3846 } |
| 3855 } | 3847 } |
| 3856 | 3848 |
| 3857 TEST(MaybeAssignedTopLevel) { | 3849 TEST(MaybeAssignedTopLevel) { |
| 3858 i::Isolate* isolate = CcTest::i_isolate(); | 3850 i::Isolate* isolate = CcTest::i_isolate(); |
| 3859 i::HandleScope scope(isolate); | 3851 i::HandleScope scope(isolate); |
| 3860 LocalContext env; | 3852 LocalContext env; |
| 3861 i::Factory* factory = isolate->factory(); | 3853 i::Factory* factory = isolate->factory(); |
| 3862 | 3854 |
| 3863 const char* prefixes[] = { | 3855 const char* prefixes[] = { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3875 "function* bar() {eval(ext)}; ext(bar); ext(foo)", | 3867 "function* bar() {eval(ext)}; ext(bar); ext(foo)", |
| 3876 }; | 3868 }; |
| 3877 | 3869 |
| 3878 for (unsigned i = 0; i < arraysize(prefixes); ++i) { | 3870 for (unsigned i = 0; i < arraysize(prefixes); ++i) { |
| 3879 const char* prefix = prefixes[i]; | 3871 const char* prefix = prefixes[i]; |
| 3880 for (unsigned j = 0; j < arraysize(sources); ++j) { | 3872 for (unsigned j = 0; j < arraysize(sources); ++j) { |
| 3881 const char* source = sources[j]; | 3873 const char* source = sources[j]; |
| 3882 i::ScopedVector<char> program(Utf8LengthHelper(prefix) + | 3874 i::ScopedVector<char> program(Utf8LengthHelper(prefix) + |
| 3883 Utf8LengthHelper(source) + 1); | 3875 Utf8LengthHelper(source) + 1); |
| 3884 i::SNPrintF(program, "%s%s", prefix, source); | 3876 i::SNPrintF(program, "%s%s", prefix, source); |
| 3885 i::Zone zone(isolate->allocator(), ZONE_NAME); | |
| 3886 | 3877 |
| 3887 i::Handle<i::String> string = | 3878 i::Handle<i::String> string = |
| 3888 factory->InternalizeUtf8String(program.start()); | 3879 factory->InternalizeUtf8String(program.start()); |
| 3889 string->PrintOn(stdout); | 3880 string->PrintOn(stdout); |
| 3890 printf("\n"); | 3881 printf("\n"); |
| 3891 i::Handle<i::Script> script = factory->NewScript(string); | 3882 i::Handle<i::Script> script = factory->NewScript(string); |
| 3892 | 3883 |
| 3893 for (unsigned allow_lazy = 0; allow_lazy < 2; ++allow_lazy) { | 3884 for (unsigned allow_lazy = 0; allow_lazy < 2; ++allow_lazy) { |
| 3894 for (unsigned module = 0; module < 2; ++module) { | 3885 for (unsigned module = 0; module < 2; ++module) { |
| 3895 std::unique_ptr<i::ParseInfo> info; | 3886 std::unique_ptr<i::ParseInfo> info; |
| 3896 info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(&zone, script)); | 3887 info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(script)); |
| 3897 info->set_module(module); | 3888 info->set_module(module); |
| 3898 info->set_allow_lazy_parsing(allow_lazy); | 3889 info->set_allow_lazy_parsing(allow_lazy); |
| 3899 | 3890 |
| 3900 CHECK(i::parsing::ParseProgram(info.get())); | 3891 CHECK(i::parsing::ParseProgram(info.get())); |
| 3901 CHECK(i::Compiler::Analyze(info.get())); | 3892 CHECK(i::Compiler::Analyze(info.get())); |
| 3902 | 3893 |
| 3903 CHECK_NOT_NULL(info->literal()); | 3894 CHECK_NOT_NULL(info->literal()); |
| 3904 i::Scope* scope = info->literal()->scope(); | 3895 i::Scope* scope = info->literal()->scope(); |
| 3905 CHECK(!scope->AsDeclarationScope()->was_lazily_parsed()); | 3896 CHECK(!scope->AsDeclarationScope()->was_lazily_parsed()); |
| 3906 CHECK_NULL(scope->sibling()); | 3897 CHECK_NULL(scope->sibling()); |
| (...skipping 2432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6339 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - | 6330 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - |
| 6340 128 * 1024); | 6331 128 * 1024); |
| 6341 | 6332 |
| 6342 for (unsigned i = 0; i < arraysize(kSources); ++i) { | 6333 for (unsigned i = 0; i < arraysize(kSources); ++i) { |
| 6343 i::Handle<i::String> source = | 6334 i::Handle<i::String> source = |
| 6344 factory->NewStringFromAsciiChecked(kSources[i]); | 6335 factory->NewStringFromAsciiChecked(kSources[i]); |
| 6345 | 6336 |
| 6346 // Show that parsing as a module works | 6337 // Show that parsing as a module works |
| 6347 { | 6338 { |
| 6348 i::Handle<i::Script> script = factory->NewScript(source); | 6339 i::Handle<i::Script> script = factory->NewScript(source); |
| 6349 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 6340 i::ParseInfo info(script); |
| 6350 i::ParseInfo info(&zone, script); | |
| 6351 info.set_module(); | 6341 info.set_module(); |
| 6352 if (!i::parsing::ParseProgram(&info)) { | 6342 if (!i::parsing::ParseProgram(&info)) { |
| 6353 i::Handle<i::JSObject> exception_handle( | 6343 i::Handle<i::JSObject> exception_handle( |
| 6354 i::JSObject::cast(isolate->pending_exception())); | 6344 i::JSObject::cast(isolate->pending_exception())); |
| 6355 i::Handle<i::String> message_string = i::Handle<i::String>::cast( | 6345 i::Handle<i::String> message_string = i::Handle<i::String>::cast( |
| 6356 i::JSReceiver::GetProperty(isolate, exception_handle, "message") | 6346 i::JSReceiver::GetProperty(isolate, exception_handle, "message") |
| 6357 .ToHandleChecked()); | 6347 .ToHandleChecked()); |
| 6358 isolate->clear_pending_exception(); | 6348 isolate->clear_pending_exception(); |
| 6359 | 6349 |
| 6360 v8::base::OS::Print( | 6350 v8::base::OS::Print( |
| 6361 "Parser failed on:\n" | 6351 "Parser failed on:\n" |
| 6362 "\t%s\n" | 6352 "\t%s\n" |
| 6363 "with error:\n" | 6353 "with error:\n" |
| 6364 "\t%s\n" | 6354 "\t%s\n" |
| 6365 "However, we expected no error.", | 6355 "However, we expected no error.", |
| 6366 source->ToCString().get(), message_string->ToCString().get()); | 6356 source->ToCString().get(), message_string->ToCString().get()); |
| 6367 CHECK(false); | 6357 CHECK(false); |
| 6368 } | 6358 } |
| 6369 } | 6359 } |
| 6370 | 6360 |
| 6371 // And that parsing a script does not. | 6361 // And that parsing a script does not. |
| 6372 { | 6362 { |
| 6373 i::Handle<i::Script> script = factory->NewScript(source); | 6363 i::Handle<i::Script> script = factory->NewScript(source); |
| 6374 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 6364 i::ParseInfo info(script); |
| 6375 i::ParseInfo info(&zone, script); | |
| 6376 CHECK(!i::parsing::ParseProgram(&info)); | 6365 CHECK(!i::parsing::ParseProgram(&info)); |
| 6377 isolate->clear_pending_exception(); | 6366 isolate->clear_pending_exception(); |
| 6378 } | 6367 } |
| 6379 } | 6368 } |
| 6380 } | 6369 } |
| 6381 | 6370 |
| 6382 | 6371 |
| 6383 TEST(ImportExportParsingErrors) { | 6372 TEST(ImportExportParsingErrors) { |
| 6384 // clang-format off | 6373 // clang-format off |
| 6385 const char* kErrorSources[] = { | 6374 const char* kErrorSources[] = { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6455 v8::Context::Scope context_scope(context); | 6444 v8::Context::Scope context_scope(context); |
| 6456 | 6445 |
| 6457 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - | 6446 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - |
| 6458 128 * 1024); | 6447 128 * 1024); |
| 6459 | 6448 |
| 6460 for (unsigned i = 0; i < arraysize(kErrorSources); ++i) { | 6449 for (unsigned i = 0; i < arraysize(kErrorSources); ++i) { |
| 6461 i::Handle<i::String> source = | 6450 i::Handle<i::String> source = |
| 6462 factory->NewStringFromAsciiChecked(kErrorSources[i]); | 6451 factory->NewStringFromAsciiChecked(kErrorSources[i]); |
| 6463 | 6452 |
| 6464 i::Handle<i::Script> script = factory->NewScript(source); | 6453 i::Handle<i::Script> script = factory->NewScript(source); |
| 6465 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 6454 i::ParseInfo info(script); |
| 6466 i::ParseInfo info(&zone, script); | |
| 6467 info.set_module(); | 6455 info.set_module(); |
| 6468 CHECK(!i::parsing::ParseProgram(&info)); | 6456 CHECK(!i::parsing::ParseProgram(&info)); |
| 6469 isolate->clear_pending_exception(); | 6457 isolate->clear_pending_exception(); |
| 6470 } | 6458 } |
| 6471 } | 6459 } |
| 6472 | 6460 |
| 6473 TEST(ModuleTopLevelFunctionDecl) { | 6461 TEST(ModuleTopLevelFunctionDecl) { |
| 6474 // clang-format off | 6462 // clang-format off |
| 6475 const char* kErrorSources[] = { | 6463 const char* kErrorSources[] = { |
| 6476 "function f() {} function f() {}", | 6464 "function f() {} function f() {}", |
| (...skipping 15 matching lines...) Expand all Loading... |
| 6492 v8::Context::Scope context_scope(context); | 6480 v8::Context::Scope context_scope(context); |
| 6493 | 6481 |
| 6494 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - | 6482 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - |
| 6495 128 * 1024); | 6483 128 * 1024); |
| 6496 | 6484 |
| 6497 for (unsigned i = 0; i < arraysize(kErrorSources); ++i) { | 6485 for (unsigned i = 0; i < arraysize(kErrorSources); ++i) { |
| 6498 i::Handle<i::String> source = | 6486 i::Handle<i::String> source = |
| 6499 factory->NewStringFromAsciiChecked(kErrorSources[i]); | 6487 factory->NewStringFromAsciiChecked(kErrorSources[i]); |
| 6500 | 6488 |
| 6501 i::Handle<i::Script> script = factory->NewScript(source); | 6489 i::Handle<i::Script> script = factory->NewScript(source); |
| 6502 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 6490 i::ParseInfo info(script); |
| 6503 i::ParseInfo info(&zone, script); | |
| 6504 info.set_module(); | 6491 info.set_module(); |
| 6505 CHECK(!i::parsing::ParseProgram(&info)); | 6492 CHECK(!i::parsing::ParseProgram(&info)); |
| 6506 isolate->clear_pending_exception(); | 6493 isolate->clear_pending_exception(); |
| 6507 } | 6494 } |
| 6508 } | 6495 } |
| 6509 | 6496 |
| 6510 TEST(ModuleAwaitReserved) { | 6497 TEST(ModuleAwaitReserved) { |
| 6511 // clang-format off | 6498 // clang-format off |
| 6512 const char* kErrorSources[] = { | 6499 const char* kErrorSources[] = { |
| 6513 "await;", | 6500 "await;", |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6690 "import 'q.js';" | 6677 "import 'q.js';" |
| 6691 "let nonexport = 42;" | 6678 "let nonexport = 42;" |
| 6692 "import {m as mm} from 'm.js';" | 6679 "import {m as mm} from 'm.js';" |
| 6693 "import {aa} from 'm.js';" | 6680 "import {aa} from 'm.js';" |
| 6694 "export {aa as bb, x};" | 6681 "export {aa as bb, x};" |
| 6695 "import * as loo from 'bar.js';" | 6682 "import * as loo from 'bar.js';" |
| 6696 "import * as foob from 'bar.js';" | 6683 "import * as foob from 'bar.js';" |
| 6697 "export {foob};"; | 6684 "export {foob};"; |
| 6698 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource); | 6685 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource); |
| 6699 i::Handle<i::Script> script = factory->NewScript(source); | 6686 i::Handle<i::Script> script = factory->NewScript(source); |
| 6700 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 6687 i::ParseInfo info(script); |
| 6701 i::ParseInfo info(&zone, script); | |
| 6702 info.set_module(); | 6688 info.set_module(); |
| 6703 CHECK(i::parsing::ParseProgram(&info)); | 6689 CHECK(i::parsing::ParseProgram(&info)); |
| 6704 CHECK(i::Compiler::Analyze(&info)); | 6690 CHECK(i::Compiler::Analyze(&info)); |
| 6705 i::FunctionLiteral* func = info.literal(); | 6691 i::FunctionLiteral* func = info.literal(); |
| 6706 i::ModuleScope* module_scope = func->scope()->AsModuleScope(); | 6692 i::ModuleScope* module_scope = func->scope()->AsModuleScope(); |
| 6707 i::Scope* outer_scope = module_scope->outer_scope(); | 6693 i::Scope* outer_scope = module_scope->outer_scope(); |
| 6708 CHECK(outer_scope->is_script_scope()); | 6694 CHECK(outer_scope->is_script_scope()); |
| 6709 CHECK_NULL(outer_scope->outer_scope()); | 6695 CHECK_NULL(outer_scope->outer_scope()); |
| 6710 CHECK(module_scope->is_module_scope()); | 6696 CHECK(module_scope->is_module_scope()); |
| 6711 const i::ModuleDescriptor::Entry* entry; | 6697 const i::ModuleDescriptor::Entry* entry; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6950 i::Isolate* isolate = CcTest::i_isolate(); | 6936 i::Isolate* isolate = CcTest::i_isolate(); |
| 6951 i::Factory* factory = isolate->factory(); | 6937 i::Factory* factory = isolate->factory(); |
| 6952 v8::HandleScope handles(CcTest::isolate()); | 6938 v8::HandleScope handles(CcTest::isolate()); |
| 6953 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); | 6939 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); |
| 6954 v8::Context::Scope context_scope(context); | 6940 v8::Context::Scope context_scope(context); |
| 6955 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - | 6941 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - |
| 6956 128 * 1024); | 6942 128 * 1024); |
| 6957 | 6943 |
| 6958 i::Handle<i::Script> script = | 6944 i::Handle<i::Script> script = |
| 6959 factory->NewScript(factory->NewStringFromAsciiChecked(source)); | 6945 factory->NewScript(factory->NewStringFromAsciiChecked(source)); |
| 6960 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 6946 i::ParseInfo info(script); |
| 6961 i::ParseInfo info(&zone, script); | |
| 6962 i::parsing::ParseProgram(&info); | 6947 i::parsing::ParseProgram(&info); |
| 6963 CHECK(info.literal() != NULL); | 6948 CHECK(info.literal() != NULL); |
| 6964 CHECK_EQ(expected_language_mode, info.literal()->language_mode()); | 6949 CHECK_EQ(expected_language_mode, info.literal()->language_mode()); |
| 6965 } | 6950 } |
| 6966 | 6951 |
| 6967 | 6952 |
| 6968 TEST(LanguageModeDirectives) { | 6953 TEST(LanguageModeDirectives) { |
| 6969 TestLanguageMode("\"use nothing\"", i::SLOPPY); | 6954 TestLanguageMode("\"use nothing\"", i::SLOPPY); |
| 6970 TestLanguageMode("\"use strict\"", i::STRICT); | 6955 TestLanguageMode("\"use strict\"", i::STRICT); |
| 6971 | 6956 |
| (...skipping 2453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9425 i::SNPrintF( | 9410 i::SNPrintF( |
| 9426 program + prefix_len + inner_function_len + params_len + source_len, | 9411 program + prefix_len + inner_function_len + params_len + source_len, |
| 9427 "%s", suffix); | 9412 "%s", suffix); |
| 9428 | 9413 |
| 9429 i::Handle<i::String> source = | 9414 i::Handle<i::String> source = |
| 9430 factory->InternalizeUtf8String(program.start()); | 9415 factory->InternalizeUtf8String(program.start()); |
| 9431 source->PrintOn(stdout); | 9416 source->PrintOn(stdout); |
| 9432 printf("\n"); | 9417 printf("\n"); |
| 9433 | 9418 |
| 9434 i::Handle<i::Script> script = factory->NewScript(source); | 9419 i::Handle<i::Script> script = factory->NewScript(source); |
| 9435 i::Zone zone(isolate->allocator(), ZONE_NAME); | 9420 i::ParseInfo info(script); |
| 9436 i::ParseInfo info(&zone, script); | |
| 9437 | 9421 |
| 9438 CHECK(i::parsing::ParseProgram(&info)); | 9422 CHECK(i::parsing::ParseProgram(&info)); |
| 9439 CHECK(i::Compiler::Analyze(&info)); | 9423 CHECK(i::Compiler::Analyze(&info)); |
| 9440 CHECK(info.literal() != NULL); | 9424 CHECK(info.literal() != NULL); |
| 9441 | 9425 |
| 9442 i::Scope* scope = info.literal()->scope()->inner_scope(); | 9426 i::Scope* scope = info.literal()->scope()->inner_scope(); |
| 9443 DCHECK_NOT_NULL(scope); | 9427 DCHECK_NOT_NULL(scope); |
| 9444 DCHECK_NULL(scope->sibling()); | 9428 DCHECK_NULL(scope->sibling()); |
| 9445 DCHECK(scope->is_function_scope()); | 9429 DCHECK(scope->is_function_scope()); |
| 9446 const i::AstRawString* var_name = | 9430 const i::AstRawString* var_name = |
| 9447 info.ast_value_factory()->GetOneByteString("my_var"); | 9431 info.ast_value_factory()->GetOneByteString("my_var"); |
| 9448 i::Variable* var = scope->Lookup(var_name); | 9432 i::Variable* var = scope->Lookup(var_name); |
| 9449 CHECK_EQ(inners[i].ctxt_allocate, | 9433 CHECK_EQ(inners[i].ctxt_allocate, |
| 9450 i::ScopeTestHelper::MustAllocateInContext(var)); | 9434 i::ScopeTestHelper::MustAllocateInContext(var)); |
| 9451 } | 9435 } |
| 9452 } | 9436 } |
| 9453 } | 9437 } |
| OLD | NEW |