OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/ast.h" | 8 #include "src/ast.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 if (stat && !stat->IsEmpty()) { | 1271 if (stat && !stat->IsEmpty()) { |
1272 body->AddStatement(stat, zone()); | 1272 body->AddStatement(stat, zone()); |
1273 } | 1273 } |
1274 } | 1274 } |
1275 } | 1275 } |
1276 | 1276 |
1277 scope->set_end_position(scanner()->location().end_pos); | 1277 scope->set_end_position(scanner()->location().end_pos); |
1278 body->set_scope(scope); | 1278 body->set_scope(scope); |
1279 | 1279 |
1280 // Check that all exports are bound. | 1280 // Check that all exports are bound. |
1281 Interface* interface = scope->interface(); | 1281 ModuleDescriptor* descriptor = scope->module(); |
1282 for (Interface::Iterator it = interface->iterator(); | 1282 for (ModuleDescriptor::Iterator it = descriptor->iterator(); !it.done(); |
1283 !it.done(); it.Advance()) { | 1283 it.Advance()) { |
1284 if (scope->LookupLocal(it.name()) == NULL) { | 1284 if (scope->LookupLocal(it.name()) == NULL) { |
1285 ParserTraits::ReportMessage("module_export_undefined", it.name()); | 1285 ParserTraits::ReportMessage("module_export_undefined", it.name()); |
1286 *ok = false; | 1286 *ok = false; |
1287 return NULL; | 1287 return NULL; |
1288 } | 1288 } |
1289 } | 1289 } |
1290 | 1290 |
1291 scope->interface()->Freeze(); | 1291 scope->module()->Freeze(); |
1292 return body; | 1292 return body; |
1293 } | 1293 } |
1294 | 1294 |
1295 | 1295 |
1296 Literal* Parser::ParseModuleSpecifier(bool* ok) { | 1296 Literal* Parser::ParseModuleSpecifier(bool* ok) { |
1297 // ModuleSpecifier : | 1297 // ModuleSpecifier : |
1298 // StringLiteral | 1298 // StringLiteral |
1299 | 1299 |
1300 int pos = peek_position(); | 1300 int pos = peek_position(); |
1301 Expect(Token::STRING, CHECK_OK); | 1301 Expect(Token::STRING, CHECK_OK); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 | 1493 |
1494 default: { | 1494 default: { |
1495 int pos = peek_position(); | 1495 int pos = peek_position(); |
1496 Expression* expr = ParseAssignmentExpression(true, CHECK_OK); | 1496 Expression* expr = ParseAssignmentExpression(true, CHECK_OK); |
1497 ExpectSemicolon(CHECK_OK); | 1497 ExpectSemicolon(CHECK_OK); |
1498 result = factory()->NewExpressionStatement(expr, pos); | 1498 result = factory()->NewExpressionStatement(expr, pos); |
1499 break; | 1499 break; |
1500 } | 1500 } |
1501 } | 1501 } |
1502 | 1502 |
1503 // TODO(ES6): Add default export to scope_->interface() | 1503 // TODO(ES6): Add default export to scope_->module() |
1504 | 1504 |
1505 return result; | 1505 return result; |
1506 } | 1506 } |
1507 | 1507 |
1508 | 1508 |
1509 Statement* Parser::ParseExportDeclaration(bool* ok) { | 1509 Statement* Parser::ParseExportDeclaration(bool* ok) { |
1510 // ExportDeclaration: | 1510 // ExportDeclaration: |
1511 // 'export' '*' 'from' ModuleSpecifier ';' | 1511 // 'export' '*' 'from' ModuleSpecifier ';' |
1512 // 'export' ExportClause ('from' ModuleSpecifier)? ';' | 1512 // 'export' ExportClause ('from' ModuleSpecifier)? ';' |
1513 // 'export' VariableStatement | 1513 // 'export' VariableStatement |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 continue; | 1598 continue; |
1599 } | 1599 } |
1600 if (!IsImmutableVariableMode(var->mode())) { | 1600 if (!IsImmutableVariableMode(var->mode())) { |
1601 var->set_maybe_assigned(); | 1601 var->set_maybe_assigned(); |
1602 } | 1602 } |
1603 } | 1603 } |
1604 | 1604 |
1605 // TODO(ES6): Handle 'export from' once imports are properly implemented. | 1605 // TODO(ES6): Handle 'export from' once imports are properly implemented. |
1606 // For now we just drop such exports on the floor. | 1606 // For now we just drop such exports on the floor. |
1607 if (!is_export_from) { | 1607 if (!is_export_from) { |
1608 // Extract declared names into export declarations and interface. | 1608 // Extract declared names into export declarations and module descriptor. |
1609 Interface* interface = scope_->interface(); | 1609 ModuleDescriptor* descriptor = scope_->module(); |
1610 for (int i = 0; i < names.length(); ++i) { | 1610 for (int i = 0; i < names.length(); ++i) { |
1611 #ifdef DEBUG | |
1612 if (FLAG_print_interface_details) | |
1613 PrintF("# Export %.*s ", names[i]->length(), names[i]->raw_data()); | |
1614 #endif | |
1615 // TODO(adamk): Make early errors here provide the right error message | 1611 // TODO(adamk): Make early errors here provide the right error message |
1616 // (duplicate exported names). | 1612 // (duplicate exported names). |
1617 interface->Add(names[i], zone(), CHECK_OK); | 1613 descriptor->Add(names[i], zone(), CHECK_OK); |
1618 // TODO(rossberg): Rethink whether we actually need to store export | 1614 // TODO(rossberg): Rethink whether we actually need to store export |
1619 // declarations (for compilation?). | 1615 // declarations (for compilation?). |
1620 // ExportDeclaration* declaration = | 1616 // ExportDeclaration* declaration = |
1621 // factory()->NewExportDeclaration(proxy, scope_, position); | 1617 // factory()->NewExportDeclaration(proxy, scope_, position); |
1622 // scope_->AddDeclaration(declaration); | 1618 // scope_->AddDeclaration(declaration); |
1623 } | 1619 } |
1624 } | 1620 } |
1625 | 1621 |
1626 DCHECK(result != NULL); | 1622 DCHECK(result != NULL); |
1627 return result; | 1623 return result; |
(...skipping 3816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5444 } else { | 5440 } else { |
5445 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); | 5441 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); |
5446 running_hash = StringHasher::ComputeRunningHash(running_hash, data, | 5442 running_hash = StringHasher::ComputeRunningHash(running_hash, data, |
5447 raw_string->length()); | 5443 raw_string->length()); |
5448 } | 5444 } |
5449 } | 5445 } |
5450 | 5446 |
5451 return running_hash; | 5447 return running_hash; |
5452 } | 5448 } |
5453 } } // namespace v8::internal | 5449 } } // namespace v8::internal |
OLD | NEW |