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

Side by Side Diff: test/cctest/test-parsing.cc

Issue 974213002: Extract ParseInfo from CompilationInfo. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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
OLDNEW
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 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 int kProgramByteSize = i::StrLength(surroundings[j].prefix) + 1038 int kProgramByteSize = i::StrLength(surroundings[j].prefix) +
1039 i::StrLength(surroundings[j].suffix) + 1039 i::StrLength(surroundings[j].suffix) +
1040 i::StrLength(source_data[i].body); 1040 i::StrLength(source_data[i].body);
1041 i::ScopedVector<char> program(kProgramByteSize + 1); 1041 i::ScopedVector<char> program(kProgramByteSize + 1);
1042 i::SNPrintF(program, "%s%s%s", surroundings[j].prefix, 1042 i::SNPrintF(program, "%s%s%s", surroundings[j].prefix,
1043 source_data[i].body, surroundings[j].suffix); 1043 source_data[i].body, surroundings[j].suffix);
1044 i::Handle<i::String> source = 1044 i::Handle<i::String> source =
1045 factory->NewStringFromUtf8(i::CStrVector(program.start())) 1045 factory->NewStringFromUtf8(i::CStrVector(program.start()))
1046 .ToHandleChecked(); 1046 .ToHandleChecked();
1047 i::Handle<i::Script> script = factory->NewScript(source); 1047 i::Handle<i::Script> script = factory->NewScript(source);
1048 i::CompilationInfoWithZone info(script); 1048 i::Zone zone;
1049 i::Parser parser(&info, isolate->stack_guard()->real_climit(), 1049 i::ParseInfo info(&zone);
1050 isolate->heap()->HashSeed(), isolate->unicode_cache()); 1050 info.InitializeFromScript(script);
1051 i::Parser parser(&info);
1051 parser.set_allow_harmony_arrow_functions(true); 1052 parser.set_allow_harmony_arrow_functions(true);
1052 parser.set_allow_harmony_classes(true); 1053 parser.set_allow_harmony_classes(true);
1053 parser.set_allow_harmony_object_literals(true); 1054 parser.set_allow_harmony_object_literals(true);
1054 parser.set_allow_harmony_scoping(true); 1055 parser.set_allow_harmony_scoping(true);
1055 parser.set_allow_harmony_sloppy(true); 1056 parser.set_allow_harmony_sloppy(true);
1056 info.MarkAsGlobal(); 1057 info.set_global();
1057 CHECK(parser.Parse(&info)); 1058 CHECK(parser.Parse(&info));
1058 CHECK(i::Rewriter::Rewrite(&info)); 1059 CHECK(i::Rewriter::Rewrite(&info));
1059 CHECK(i::Scope::Analyze(&info)); 1060 CHECK(i::Scope::Analyze(&info));
1060 CHECK(info.function() != NULL); 1061 CHECK(info.function() != NULL);
1061 1062
1062 i::Scope* script_scope = info.function()->scope(); 1063 i::Scope* script_scope = info.function()->scope();
1063 CHECK(script_scope->is_script_scope()); 1064 CHECK(script_scope->is_script_scope());
1064 CHECK_EQ(1, script_scope->inner_scopes()->length()); 1065 CHECK_EQ(1, script_scope->inner_scopes()->length());
1065 1066
1066 i::Scope* scope = script_scope->inner_scopes()->at(0); 1067 i::Scope* scope = script_scope->inner_scopes()->at(0);
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 i::SNPrintF(program, "%s%s%s", 1291 i::SNPrintF(program, "%s%s%s",
1291 source_data[i].outer_prefix, 1292 source_data[i].outer_prefix,
1292 source_data[i].inner_source, 1293 source_data[i].inner_source,
1293 source_data[i].outer_suffix); 1294 source_data[i].outer_suffix);
1294 1295
1295 // Parse program source. 1296 // Parse program source.
1296 i::Handle<i::String> source = factory->NewStringFromUtf8( 1297 i::Handle<i::String> source = factory->NewStringFromUtf8(
1297 i::CStrVector(program.start())).ToHandleChecked(); 1298 i::CStrVector(program.start())).ToHandleChecked();
1298 CHECK_EQ(source->length(), kProgramSize); 1299 CHECK_EQ(source->length(), kProgramSize);
1299 i::Handle<i::Script> script = factory->NewScript(source); 1300 i::Handle<i::Script> script = factory->NewScript(source);
1300 i::CompilationInfoWithZone info(script); 1301 i::Zone zone;
1301 i::Parser parser(&info, isolate->stack_guard()->real_climit(), 1302 i::ParseInfo info(&zone);
1302 isolate->heap()->HashSeed(), isolate->unicode_cache()); 1303 info.InitializeFromScript(script);
1304 i::Parser parser(&info);
1303 parser.set_allow_lazy(true); 1305 parser.set_allow_lazy(true);
1304 parser.set_allow_harmony_scoping(true); 1306 parser.set_allow_harmony_scoping(true);
1305 parser.set_allow_harmony_arrow_functions(true); 1307 parser.set_allow_harmony_arrow_functions(true);
1306 info.MarkAsGlobal(); 1308 info.set_global();
1307 info.SetLanguageMode(source_data[i].language_mode); 1309 info.set_language_mode(source_data[i].language_mode);
1308 parser.Parse(&info); 1310 parser.Parse(&info);
1309 CHECK(info.function() != NULL); 1311 CHECK(info.function() != NULL);
1310 1312
1311 // Check scope types and positions. 1313 // Check scope types and positions.
1312 i::Scope* scope = info.function()->scope(); 1314 i::Scope* scope = info.function()->scope();
1313 CHECK(scope->is_script_scope()); 1315 CHECK(scope->is_script_scope());
1314 CHECK_EQ(scope->start_position(), 0); 1316 CHECK_EQ(scope->start_position(), 0);
1315 CHECK_EQ(scope->end_position(), kProgramSize); 1317 CHECK_EQ(scope->end_position(), kProgramSize);
1316 CHECK_EQ(scope->inner_scopes()->length(), 1); 1318 CHECK_EQ(scope->inner_scopes()->length(), 1);
1317 1319
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 &preparser_materialized_literals); 1451 &preparser_materialized_literals);
1450 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 1452 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
1451 } 1453 }
1452 1454
1453 bool preparse_error = log.HasError(); 1455 bool preparse_error = log.HasError();
1454 1456
1455 // Parse the data 1457 // Parse the data
1456 i::FunctionLiteral* function; 1458 i::FunctionLiteral* function;
1457 { 1459 {
1458 i::Handle<i::Script> script = factory->NewScript(source); 1460 i::Handle<i::Script> script = factory->NewScript(source);
1459 i::CompilationInfoWithZone info(script); 1461 i::Zone zone;
1460 i::Parser parser(&info, isolate->stack_guard()->real_climit(), 1462 i::ParseInfo info(&zone);
1461 isolate->heap()->HashSeed(), isolate->unicode_cache()); 1463 info.InitializeFromScript(script);
1464 i::Parser parser(&info);
1462 SetParserFlags(&parser, flags); 1465 SetParserFlags(&parser, flags);
1463 info.MarkAsGlobal(); 1466 info.set_global();
1464 parser.Parse(&info); 1467 parser.Parse(&info);
1465 function = info.function(); 1468 function = info.function();
1466 if (function) { 1469 if (function) {
1467 parser_materialized_literals = function->materialized_literal_count(); 1470 parser_materialized_literals = function->materialized_literal_count();
1468 } 1471 }
1469 } 1472 }
1470 1473
1471 // Check that preparsing fails iff parsing fails. 1474 // Check that preparsing fails iff parsing fails.
1472 if (function == NULL) { 1475 if (function == NULL) {
1473 // Extract exception from the parser. 1476 // Extract exception from the parser.
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
2537 {"function lazy() { var x = {get foo(){} } }", 1}, 2540 {"function lazy() { var x = {get foo(){} } }", 1},
2538 {NULL, 0} 2541 {NULL, 0}
2539 }; 2542 };
2540 2543
2541 for (int i = 0; test_cases[i].program; i++) { 2544 for (int i = 0; test_cases[i].program; i++) {
2542 const char* program = test_cases[i].program; 2545 const char* program = test_cases[i].program;
2543 i::Factory* factory = CcTest::i_isolate()->factory(); 2546 i::Factory* factory = CcTest::i_isolate()->factory();
2544 i::Handle<i::String> source = 2547 i::Handle<i::String> source =
2545 factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked(); 2548 factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked();
2546 i::Handle<i::Script> script = factory->NewScript(source); 2549 i::Handle<i::Script> script = factory->NewScript(source);
2547 i::CompilationInfoWithZone info(script); 2550 i::Zone zone;
2551 i::ParseInfo info(&zone);
2552 info.InitializeFromScript(script);
2548 i::ScriptData* sd = NULL; 2553 i::ScriptData* sd = NULL;
2549 info.SetCachedData(&sd, v8::ScriptCompiler::kProduceParserCache); 2554 info.set_cached_data(&sd);
2555 info.set_compile_options(v8::ScriptCompiler::kProduceParserCache);
2550 i::Parser::ParseStatic(&info, true); 2556 i::Parser::ParseStatic(&info, true);
2551 i::ParseData* pd = i::ParseData::FromCachedData(sd); 2557 i::ParseData* pd = i::ParseData::FromCachedData(sd);
2552 2558
2553 if (pd->FunctionCount() != test_cases[i].functions) { 2559 if (pd->FunctionCount() != test_cases[i].functions) {
2554 v8::base::OS::Print( 2560 v8::base::OS::Print(
2555 "Expected preparse data for program:\n" 2561 "Expected preparse data for program:\n"
2556 "\t%s\n" 2562 "\t%s\n"
2557 "to contain %d functions, however, received %d functions.\n", 2563 "to contain %d functions, however, received %d functions.\n",
2558 program, test_cases[i].functions, pd->FunctionCount()); 2564 program, test_cases[i].functions, pd->FunctionCount());
2559 CHECK(false); 2565 CHECK(false);
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
3360 i::ScopedVector<char> program(len + 1); 3366 i::ScopedVector<char> program(len + 1);
3361 3367
3362 i::SNPrintF(program, "%s%s%s%s%s%s%s", prefix, outer_comment, outer, 3368 i::SNPrintF(program, "%s%s%s%s%s%s%s", prefix, outer_comment, outer,
3363 midfix, inner_comment, inner, suffix); 3369 midfix, inner_comment, inner, suffix);
3364 i::Handle<i::String> source = 3370 i::Handle<i::String> source =
3365 factory->InternalizeUtf8String(program.start()); 3371 factory->InternalizeUtf8String(program.start());
3366 source->PrintOn(stdout); 3372 source->PrintOn(stdout);
3367 printf("\n"); 3373 printf("\n");
3368 3374
3369 i::Handle<i::Script> script = factory->NewScript(source); 3375 i::Handle<i::Script> script = factory->NewScript(source);
3370 i::CompilationInfoWithZone info(script); 3376 i::Zone zone;
3371 i::Parser parser(&info, isolate->stack_guard()->real_climit(), 3377 i::ParseInfo info(&zone);
3372 isolate->heap()->HashSeed(), 3378 info.InitializeFromScript(script);
3373 isolate->unicode_cache()); 3379 i::Parser parser(&info);
3374 parser.set_allow_harmony_scoping(true); 3380 parser.set_allow_harmony_scoping(true);
3375 CHECK(parser.Parse(&info)); 3381 CHECK(parser.Parse(&info));
3376 CHECK(i::Compiler::Analyze(&info)); 3382 CHECK(i::Compiler::Analyze(&info));
3377 CHECK(info.function() != NULL); 3383 CHECK(info.function() != NULL);
3378 3384
3379 i::Scope* scope = info.function()->scope(); 3385 i::Scope* scope = info.function()->scope();
3380 CHECK_EQ(scope->inner_scopes()->length(), 1); 3386 CHECK_EQ(scope->inner_scopes()->length(), 1);
3381 i::Scope* inner_scope = scope->inner_scopes()->at(0); 3387 i::Scope* inner_scope = scope->inner_scopes()->at(0);
3382 const i::AstRawString* var_name = 3388 const i::AstRawString* var_name =
3383 info.ast_value_factory()->GetOneByteString("x"); 3389 info.ast_value_factory()->GetOneByteString("x");
(...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after
5071 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - 5077 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
5072 128 * 1024); 5078 128 * 1024);
5073 5079
5074 for (unsigned i = 0; i < arraysize(kSources); ++i) { 5080 for (unsigned i = 0; i < arraysize(kSources); ++i) {
5075 i::Handle<i::String> source = 5081 i::Handle<i::String> source =
5076 factory->NewStringFromAsciiChecked(kSources[i]); 5082 factory->NewStringFromAsciiChecked(kSources[i]);
5077 5083
5078 // Show that parsing as a module works 5084 // Show that parsing as a module works
5079 { 5085 {
5080 i::Handle<i::Script> script = factory->NewScript(source); 5086 i::Handle<i::Script> script = factory->NewScript(source);
5081 i::CompilationInfoWithZone info(script); 5087 i::Zone zone;
5082 i::Parser parser(&info, isolate->stack_guard()->real_climit(), 5088 i::ParseInfo info(&zone);
5083 isolate->heap()->HashSeed(), isolate->unicode_cache()); 5089 info.InitializeFromScript(script);
5090 i::Parser parser(&info);
5084 parser.set_allow_harmony_classes(true); 5091 parser.set_allow_harmony_classes(true);
5085 parser.set_allow_harmony_modules(true); 5092 parser.set_allow_harmony_modules(true);
5086 parser.set_allow_harmony_scoping(true); 5093 parser.set_allow_harmony_scoping(true);
5087 info.MarkAsModule(); 5094 info.set_module();
5088 if (!parser.Parse(&info)) { 5095 if (!parser.Parse(&info)) {
5089 i::Handle<i::JSObject> exception_handle( 5096 i::Handle<i::JSObject> exception_handle(
5090 i::JSObject::cast(isolate->pending_exception())); 5097 i::JSObject::cast(isolate->pending_exception()));
5091 i::Handle<i::String> message_string = 5098 i::Handle<i::String> message_string =
5092 i::Handle<i::String>::cast(i::Object::GetProperty( 5099 i::Handle<i::String>::cast(i::Object::GetProperty(
5093 isolate, exception_handle, "message").ToHandleChecked()); 5100 isolate, exception_handle, "message").ToHandleChecked());
5094 5101
5095 v8::base::OS::Print( 5102 v8::base::OS::Print(
5096 "Parser failed on:\n" 5103 "Parser failed on:\n"
5097 "\t%s\n" 5104 "\t%s\n"
5098 "with error:\n" 5105 "with error:\n"
5099 "\t%s\n" 5106 "\t%s\n"
5100 "However, we expected no error.", 5107 "However, we expected no error.",
5101 source->ToCString().get(), message_string->ToCString().get()); 5108 source->ToCString().get(), message_string->ToCString().get());
5102 CHECK(false); 5109 CHECK(false);
5103 } 5110 }
5104 } 5111 }
5105 5112
5106 // And that parsing a script does not. 5113 // And that parsing a script does not.
5107 { 5114 {
5108 i::Handle<i::Script> script = factory->NewScript(source); 5115 i::Handle<i::Script> script = factory->NewScript(source);
5109 i::CompilationInfoWithZone info(script); 5116 i::Zone zone;
5110 i::Parser parser(&info, isolate->stack_guard()->real_climit(), 5117 i::ParseInfo info(&zone);
5111 isolate->heap()->HashSeed(), isolate->unicode_cache()); 5118 info.InitializeFromScript(script);
5119 i::Parser parser(&info);
5112 parser.set_allow_harmony_classes(true); 5120 parser.set_allow_harmony_classes(true);
5113 parser.set_allow_harmony_modules(true); 5121 parser.set_allow_harmony_modules(true);
5114 parser.set_allow_harmony_scoping(true); 5122 parser.set_allow_harmony_scoping(true);
5115 info.MarkAsGlobal(); 5123 info.set_global();
5116 CHECK(!parser.Parse(&info)); 5124 CHECK(!parser.Parse(&info));
5117 } 5125 }
5118 } 5126 }
5119 } 5127 }
5120 5128
5121 5129
5122 TEST(ImportExportParsingErrors) { 5130 TEST(ImportExportParsingErrors) {
5123 const char* kErrorSources[] = { 5131 const char* kErrorSources[] = {
5124 "export {", 5132 "export {",
5125 "var a; export { a", 5133 "var a; export { a",
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
5190 v8::Context::Scope context_scope(context); 5198 v8::Context::Scope context_scope(context);
5191 5199
5192 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - 5200 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
5193 128 * 1024); 5201 128 * 1024);
5194 5202
5195 for (unsigned i = 0; i < arraysize(kErrorSources); ++i) { 5203 for (unsigned i = 0; i < arraysize(kErrorSources); ++i) {
5196 i::Handle<i::String> source = 5204 i::Handle<i::String> source =
5197 factory->NewStringFromAsciiChecked(kErrorSources[i]); 5205 factory->NewStringFromAsciiChecked(kErrorSources[i]);
5198 5206
5199 i::Handle<i::Script> script = factory->NewScript(source); 5207 i::Handle<i::Script> script = factory->NewScript(source);
5200 i::CompilationInfoWithZone info(script); 5208 i::Zone zone;
5201 i::Parser parser(&info, isolate->stack_guard()->real_climit(), 5209 i::ParseInfo info(&zone);
5202 isolate->heap()->HashSeed(), isolate->unicode_cache()); 5210 info.InitializeFromScript(script);
5211 i::Parser parser(&info);
5203 parser.set_allow_harmony_classes(true); 5212 parser.set_allow_harmony_classes(true);
5204 parser.set_allow_harmony_modules(true); 5213 parser.set_allow_harmony_modules(true);
5205 parser.set_allow_harmony_scoping(true); 5214 parser.set_allow_harmony_scoping(true);
5206 info.MarkAsModule(); 5215 info.set_module();
5207 CHECK(!parser.Parse(&info)); 5216 CHECK(!parser.Parse(&info));
5208 } 5217 }
5209 } 5218 }
5210 5219
5211 5220
5212 TEST(ModuleParsingInternals) { 5221 TEST(ModuleParsingInternals) {
5213 i::Isolate* isolate = CcTest::i_isolate(); 5222 i::Isolate* isolate = CcTest::i_isolate();
5214 i::Factory* factory = isolate->factory(); 5223 i::Factory* factory = isolate->factory();
5215 v8::HandleScope handles(CcTest::isolate()); 5224 v8::HandleScope handles(CcTest::isolate());
5216 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); 5225 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate());
5217 v8::Context::Scope context_scope(context); 5226 v8::Context::Scope context_scope(context);
5218 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - 5227 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
5219 128 * 1024); 5228 128 * 1024);
5220 5229
5221 static const char kSource[] = 5230 static const char kSource[] =
5222 "let x = 5;" 5231 "let x = 5;"
5223 "export { x as y };" 5232 "export { x as y };"
5224 "import { q as z } from 'm.js';" 5233 "import { q as z } from 'm.js';"
5225 "import n from 'n.js'"; 5234 "import n from 'n.js'";
5226 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource); 5235 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource);
5227 i::Handle<i::Script> script = factory->NewScript(source); 5236 i::Handle<i::Script> script = factory->NewScript(source);
5228 i::CompilationInfoWithZone info(script); 5237 i::Zone zone;
5229 i::Zone* zone = info.zone(); 5238 i::ParseInfo info(&zone);
5230 i::AstValueFactory avf(zone, isolate->heap()->HashSeed()); 5239 info.InitializeFromScript(script);
5231 i::Parser parser(&info, isolate->stack_guard()->real_climit(), 5240 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed());
5232 isolate->heap()->HashSeed(), isolate->unicode_cache()); 5241 i::Parser parser(&info);
5233 parser.set_allow_harmony_modules(true); 5242 parser.set_allow_harmony_modules(true);
5234 parser.set_allow_harmony_scoping(true); 5243 parser.set_allow_harmony_scoping(true);
5235 info.MarkAsModule(); 5244 info.set_module();
5236 CHECK(parser.Parse(&info)); 5245 CHECK(parser.Parse(&info));
5237 i::FunctionLiteral* func = info.function(); 5246 i::FunctionLiteral* func = info.function();
5238 CHECK_EQ(i::MODULE_SCOPE, func->scope()->scope_type()); 5247 CHECK_EQ(i::MODULE_SCOPE, func->scope()->scope_type());
5239 i::ModuleDescriptor* descriptor = func->scope()->module(); 5248 i::ModuleDescriptor* descriptor = func->scope()->module();
5240 CHECK_NOT_NULL(descriptor); 5249 CHECK_NOT_NULL(descriptor);
5241 CHECK_EQ(1, descriptor->Length()); 5250 CHECK_EQ(1, descriptor->Length());
5242 const i::AstRawString* export_name = avf.GetOneByteString("y"); 5251 const i::AstRawString* export_name = avf.GetOneByteString("y");
5243 const i::AstRawString* local_name = 5252 const i::AstRawString* local_name =
5244 descriptor->LookupLocalExport(export_name, zone); 5253 descriptor->LookupLocalExport(export_name, &zone);
5245 CHECK_NOT_NULL(local_name); 5254 CHECK_NOT_NULL(local_name);
5246 CHECK(local_name->IsOneByteEqualTo("x")); 5255 CHECK(local_name->IsOneByteEqualTo("x"));
5247 i::ZoneList<i::Declaration*>* declarations = func->scope()->declarations(); 5256 i::ZoneList<i::Declaration*>* declarations = func->scope()->declarations();
5248 CHECK_EQ(3, declarations->length()); 5257 CHECK_EQ(3, declarations->length());
5249 CHECK(declarations->at(0)->proxy()->raw_name()->IsOneByteEqualTo("x")); 5258 CHECK(declarations->at(0)->proxy()->raw_name()->IsOneByteEqualTo("x"));
5250 i::ImportDeclaration* import_decl = 5259 i::ImportDeclaration* import_decl =
5251 declarations->at(1)->AsImportDeclaration(); 5260 declarations->at(1)->AsImportDeclaration();
5252 CHECK(import_decl->import_name()->IsOneByteEqualTo("q")); 5261 CHECK(import_decl->import_name()->IsOneByteEqualTo("q"));
5253 CHECK(import_decl->proxy()->raw_name()->IsOneByteEqualTo("z")); 5262 CHECK(import_decl->proxy()->raw_name()->IsOneByteEqualTo("z"));
5254 CHECK(import_decl->module_specifier()->IsOneByteEqualTo("m.js")); 5263 CHECK(import_decl->module_specifier()->IsOneByteEqualTo("m.js"));
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
5334 i::Isolate* isolate = CcTest::i_isolate(); 5343 i::Isolate* isolate = CcTest::i_isolate();
5335 i::Factory* factory = isolate->factory(); 5344 i::Factory* factory = isolate->factory();
5336 v8::HandleScope handles(CcTest::isolate()); 5345 v8::HandleScope handles(CcTest::isolate());
5337 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); 5346 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate());
5338 v8::Context::Scope context_scope(context); 5347 v8::Context::Scope context_scope(context);
5339 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - 5348 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
5340 128 * 1024); 5349 128 * 1024);
5341 5350
5342 i::Handle<i::Script> script = 5351 i::Handle<i::Script> script =
5343 factory->NewScript(factory->NewStringFromAsciiChecked(source)); 5352 factory->NewScript(factory->NewStringFromAsciiChecked(source));
5344 i::CompilationInfoWithZone info(script); 5353 i::Zone zone;
5345 i::Parser parser(&info, isolate->stack_guard()->real_climit(), 5354 i::ParseInfo info(&zone);
5346 isolate->heap()->HashSeed(), isolate->unicode_cache()); 5355 info.InitializeFromScript(script);
5356 i::Parser parser(&info);
5347 parser.set_allow_strong_mode(true); 5357 parser.set_allow_strong_mode(true);
5348 info.MarkAsGlobal(); 5358 info.set_global();
5349 parser.Parse(&info); 5359 parser.Parse(&info);
5350 CHECK(info.function() != NULL); 5360 CHECK(info.function() != NULL);
5351 CHECK_EQ(expected_language_mode, info.function()->language_mode()); 5361 CHECK_EQ(expected_language_mode, info.function()->language_mode());
5352 } 5362 }
5353 5363
5354 5364
5355 TEST(LanguageModeDirectives) { 5365 TEST(LanguageModeDirectives) {
5356 TestLanguageMode("\"use nothing\"", i::SLOPPY); 5366 TestLanguageMode("\"use nothing\"", i::SLOPPY);
5357 TestLanguageMode("\"use strict\"", i::STRICT); 5367 TestLanguageMode("\"use strict\"", i::STRICT);
5358 TestLanguageMode("\"use strong\"", i::STRONG); 5368 TestLanguageMode("\"use strong\"", i::STRONG);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
5546 static const ParserFlag always_flags[] = { 5556 static const ParserFlag always_flags[] = {
5547 kAllowStrongMode, kAllowHarmonyScoping 5557 kAllowStrongMode, kAllowHarmonyScoping
5548 }; 5558 };
5549 RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, always_flags, 5559 RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, always_flags,
5550 arraysize(always_flags)); 5560 arraysize(always_flags));
5551 RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags, 5561 RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags,
5552 arraysize(always_flags)); 5562 arraysize(always_flags));
5553 RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags, 5563 RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags,
5554 arraysize(always_flags)); 5564 arraysize(always_flags));
5555 } 5565 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698