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

Unified Diff: src/ast/scopes.cc

Issue 2302783002: [modules] Basic support of exports (Closed)
Patch Set: . Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ast/scopes.h ('k') | src/ast/variables.h » ('j') | src/contexts.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopes.cc
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
index 02b34335265bf72633fe0dc1486141b8d1aeae00..24942cf9dde78c22a8d56d253a85999848ac58f6 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -176,8 +176,8 @@ ModuleScope::ModuleScope(Isolate* isolate, Handle<ScopeInfo> scope_info,
// Deserialize special exports.
Handle<FixedArray> special_exports = handle(module_info->special_exports());
for (int i = 0, n = special_exports->length(); i < n; ++i) {
- Handle<FixedArray> serialized_entry(
- FixedArray::cast(special_exports->get(i)), isolate);
+ Handle<ModuleInfoEntry> serialized_entry(
+ ModuleInfoEntry::cast(special_exports->get(i)), isolate);
module_descriptor_->AddSpecialExport(
ModuleDescriptor::Entry::Deserialize(isolate, avfactory,
serialized_entry),
@@ -187,8 +187,8 @@ ModuleScope::ModuleScope(Isolate* isolate, Handle<ScopeInfo> scope_info,
// Deserialize regular exports.
Handle<FixedArray> regular_exports = handle(module_info->regular_exports());
for (int i = 0, n = regular_exports->length(); i < n; ++i) {
- Handle<FixedArray> serialized_entry(
- FixedArray::cast(regular_exports->get(i)), isolate);
+ Handle<ModuleInfoEntry> serialized_entry(
+ ModuleInfoEntry::cast(regular_exports->get(i)), isolate);
module_descriptor_->AddRegularExport(ModuleDescriptor::Entry::Deserialize(
isolate, avfactory, serialized_entry));
}
@@ -461,12 +461,6 @@ void DeclarationScope::Analyze(ParseInfo* info, AnalyzeMode mode) {
scope->outer_scope()->scope_type() == SCRIPT_SCOPE ||
scope->outer_scope()->already_resolved_);
- // For modules, we want to start variable allocation at the surrounding script
- // scope.
- if (scope->is_module_scope()) {
- scope = scope->outer_scope()->AsDeclarationScope();
- }
-
scope->AllocateVariables(info, mode);
#ifdef DEBUG
@@ -707,7 +701,7 @@ Variable* DeclarationScope::DeclareParameter(
const AstRawString* name, VariableMode mode, bool is_optional, bool is_rest,
bool* is_duplicate, AstValueFactory* ast_value_factory) {
DCHECK(!already_resolved_);
- DCHECK(is_function_scope());
+ DCHECK(is_function_scope() || is_module_scope());
DCHECK(!has_rest_);
DCHECK(!is_optional || !is_rest);
Variable* var;
@@ -1015,6 +1009,16 @@ DeclarationScope* Scope::GetClosureScope() {
return scope->AsDeclarationScope();
}
+ModuleScope* Scope::GetModuleScope() {
+ Scope* scope = this;
+ DCHECK(!scope->is_script_scope());
+ while (!scope->is_module_scope()) {
+ scope = scope->outer_scope();
+ DCHECK_NOT_NULL(scope);
+ }
+ return scope->AsModuleScope();
+}
+
DeclarationScope* Scope::GetReceiverScope() {
Scope* scope = this;
while (!scope->is_script_scope() &&
« no previous file with comments | « src/ast/scopes.h ('k') | src/ast/variables.h » ('j') | src/contexts.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698