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 5230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5241 | 5241 |
5242 static const char kSource[] = | 5242 static const char kSource[] = |
5243 "let x = 5;" | 5243 "let x = 5;" |
5244 "export { x as y };" | 5244 "export { x as y };" |
5245 "import { q as z } from 'm.js';" | 5245 "import { q as z } from 'm.js';" |
5246 "import n from 'n.js'"; | 5246 "import n from 'n.js'"; |
5247 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource); | 5247 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource); |
5248 i::Handle<i::Script> script = factory->NewScript(source); | 5248 i::Handle<i::Script> script = factory->NewScript(source); |
5249 i::Zone zone; | 5249 i::Zone zone; |
5250 i::ParseInfo info(&zone, script); | 5250 i::ParseInfo info(&zone, script); |
5251 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); | |
5252 i::Parser parser(&info); | 5251 i::Parser parser(&info); |
5253 parser.set_allow_harmony_modules(true); | 5252 parser.set_allow_harmony_modules(true); |
5254 info.set_module(); | 5253 info.set_module(); |
5255 CHECK(parser.Parse(&info)); | 5254 CHECK(parser.Parse(&info)); |
5256 CHECK(i::Compiler::Analyze(&info)); | 5255 CHECK(i::Compiler::Analyze(&info)); |
5257 | |
5258 i::FunctionLiteral* func = info.function(); | 5256 i::FunctionLiteral* func = info.function(); |
5259 i::Scope* module_scope = func->scope(); | 5257 i::Scope* module_scope = func->scope(); |
5260 i::Scope* outer_scope = module_scope->outer_scope(); | 5258 i::Scope* outer_scope = module_scope->outer_scope(); |
5261 CHECK(outer_scope->is_script_scope()); | 5259 CHECK(outer_scope->is_script_scope()); |
5262 CHECK_NULL(outer_scope->outer_scope()); | 5260 CHECK_NULL(outer_scope->outer_scope()); |
5263 CHECK_EQ(1, outer_scope->num_modules()); | 5261 CHECK_EQ(1, outer_scope->num_modules()); |
5264 CHECK(module_scope->is_module_scope()); | 5262 CHECK(module_scope->is_module_scope()); |
5265 CHECK_NOT_NULL(module_scope->module_var()); | 5263 CHECK_NOT_NULL(module_scope->module_var()); |
5266 CHECK_EQ(i::INTERNAL, module_scope->module_var()->mode()); | 5264 CHECK_EQ(i::INTERNAL, module_scope->module_var()->mode()); |
5267 | |
5268 i::ModuleDescriptor* descriptor = module_scope->module(); | 5265 i::ModuleDescriptor* descriptor = module_scope->module(); |
5269 CHECK_NOT_NULL(descriptor); | 5266 CHECK_NOT_NULL(descriptor); |
5270 CHECK_EQ(1, descriptor->Length()); | 5267 CHECK_EQ(1, descriptor->Length()); |
5271 const i::AstRawString* export_name = avf.GetOneByteString("y"); | 5268 const i::AstRawString* export_name = |
| 5269 info.ast_value_factory()->GetOneByteString("y"); |
5272 const i::AstRawString* local_name = | 5270 const i::AstRawString* local_name = |
5273 descriptor->LookupLocalExport(export_name, &zone); | 5271 descriptor->LookupLocalExport(export_name, &zone); |
5274 CHECK_NOT_NULL(local_name); | 5272 CHECK_NOT_NULL(local_name); |
5275 CHECK(local_name->IsOneByteEqualTo("x")); | 5273 CHECK(local_name->IsOneByteEqualTo("x")); |
5276 i::ZoneList<i::Declaration*>* declarations = module_scope->declarations(); | 5274 i::ZoneList<i::Declaration*>* declarations = module_scope->declarations(); |
5277 CHECK_EQ(3, declarations->length()); | 5275 CHECK_EQ(3, declarations->length()); |
5278 CHECK(declarations->at(0)->proxy()->raw_name()->IsOneByteEqualTo("x")); | 5276 CHECK(declarations->at(0)->proxy()->raw_name()->IsOneByteEqualTo("x")); |
5279 i::ImportDeclaration* import_decl = | 5277 i::ImportDeclaration* import_decl = |
5280 declarations->at(1)->AsImportDeclaration(); | 5278 declarations->at(1)->AsImportDeclaration(); |
5281 CHECK(import_decl->import_name()->IsOneByteEqualTo("q")); | 5279 CHECK(import_decl->import_name()->IsOneByteEqualTo("q")); |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5797 v8::Script::Compile(v8_str(script3)); | 5795 v8::Script::Compile(v8_str(script3)); |
5798 CHECK(try_catch2.HasCaught()); | 5796 CHECK(try_catch2.HasCaught()); |
5799 v8::String::Utf8Value exception(try_catch2.Exception()); | 5797 v8::String::Utf8Value exception(try_catch2.Exception()); |
5800 CHECK_EQ(0, | 5798 CHECK_EQ(0, |
5801 strcmp( | 5799 strcmp( |
5802 "ReferenceError: In strong mode, using an undeclared global " | 5800 "ReferenceError: In strong mode, using an undeclared global " |
5803 "variable 'not_there3' is not allowed", | 5801 "variable 'not_there3' is not allowed", |
5804 *exception)); | 5802 *exception)); |
5805 } | 5803 } |
5806 } | 5804 } |
OLD | NEW |