| Index: src/parser.cc
|
| diff --git a/src/parser.cc b/src/parser.cc
|
| index 170b1f5a3523f1bc0eab16a81fef3fbc98f46f3c..d2925c0b02e9058f48f5024d7028c5832ccebd4d 100644
|
| --- a/src/parser.cc
|
| +++ b/src/parser.cc
|
| @@ -1442,6 +1442,19 @@ Statement* Parser::ParseExportDeclaration(bool* ok) {
|
| return NULL;
|
| }
|
|
|
| + // Every export of a module may be assigned.
|
| + for (int i = 0; i < names.length(); ++i) {
|
| + Variable* var = scope_->Lookup(names[i]);
|
| + if (var == NULL) {
|
| + // TODO(sigurds) This is an export that has no definition yet,
|
| + // not clear what to do in this case.
|
| + continue;
|
| + }
|
| + if (!IsImmutableVariableMode(var->mode())) {
|
| + var->set_maybe_assigned();
|
| + }
|
| + }
|
| +
|
| // Extract declared names into export declarations and interface.
|
| Interface* interface = scope_->interface();
|
| for (int i = 0; i < names.length(); ++i) {
|
| @@ -1655,8 +1668,9 @@ void Parser::Declare(Declaration* declaration, bool resolve, bool* ok) {
|
| : declaration_scope->LookupLocal(name);
|
| if (var == NULL) {
|
| // Declare the name.
|
| - var = declaration_scope->DeclareLocal(
|
| - name, mode, declaration->initialization(), proxy->interface());
|
| + var = declaration_scope->DeclareLocal(name, mode,
|
| + declaration->initialization(),
|
| + kNotAssigned, proxy->interface());
|
| } else if (IsLexicalVariableMode(mode) || IsLexicalVariableMode(var->mode())
|
| || ((mode == CONST_LEGACY || var->mode() == CONST_LEGACY) &&
|
| !declaration_scope->is_global_scope())) {
|
| @@ -1711,18 +1725,19 @@ void Parser::Declare(Declaration* declaration, bool resolve, bool* ok) {
|
| // For global const variables we bind the proxy to a variable.
|
| ASSERT(resolve); // should be set by all callers
|
| Variable::Kind kind = Variable::NORMAL;
|
| - var = new(zone()) Variable(
|
| - declaration_scope, name, mode, true, kind,
|
| - kNeedsInitialization, proxy->interface());
|
| + var = new (zone())
|
| + Variable(declaration_scope, name, mode, true, kind,
|
| + kNeedsInitialization, kNotAssigned, proxy->interface());
|
| } else if (declaration_scope->is_eval_scope() &&
|
| declaration_scope->strict_mode() == SLOPPY) {
|
| // For variable declarations in a sloppy eval scope the proxy is bound
|
| // to a lookup variable to force a dynamic declaration using the
|
| // DeclareLookupSlot runtime function.
|
| Variable::Kind kind = Variable::NORMAL;
|
| - var = new(zone()) Variable(
|
| - declaration_scope, name, mode, true, kind,
|
| - declaration->initialization(), proxy->interface());
|
| + // TODO(sigurds) figure out if kNotAssigned is OK here
|
| + var = new (zone()) Variable(declaration_scope, name, mode, true, kind,
|
| + declaration->initialization(), kNotAssigned,
|
| + proxy->interface());
|
| var->AllocateTo(Variable::LOOKUP, -1);
|
| resolve = true;
|
| }
|
| @@ -2625,9 +2640,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
|
| Target target(&this->target_stack_, &catch_collector);
|
| VariableMode mode =
|
| allow_harmony_scoping() && strict_mode() == STRICT ? LET : VAR;
|
| - catch_variable =
|
| - catch_scope->DeclareLocal(name, mode, kCreatedInitialized);
|
| -
|
| + catch_variable = catch_scope->DeclareLocal(name, mode, kCreatedInitialized);
|
| BlockState block_state(&scope_, catch_scope);
|
| catch_block = ParseBlock(NULL, CHECK_OK);
|
|
|
| @@ -3454,7 +3467,12 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
|
| dupe_error_loc = scanner()->location();
|
| }
|
|
|
| - scope_->DeclareParameter(param_name, VAR);
|
| + Variable* var = scope_->DeclareParameter(param_name, VAR);
|
| + // TODO(sigurds) Mark every parameter as maybe assigned. This is a
|
| + // conservative approximation necessary to account for parameters
|
| + // that are assigned via the arguments array.
|
| + var->set_maybe_assigned();
|
| +
|
| num_parameters++;
|
| if (num_parameters > Code::kMaxArguments) {
|
| ReportMessage("too_many_parameters");
|
| @@ -3485,9 +3503,10 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
|
| allow_harmony_scoping() && strict_mode() == STRICT
|
| ? CONST : CONST_LEGACY;
|
| ASSERT(function_name != NULL);
|
| - fvar = new(zone()) Variable(scope_,
|
| - function_name, fvar_mode, true /* is valid LHS */,
|
| - Variable::NORMAL, kCreatedInitialized, Interface::NewConst());
|
| + fvar = new (zone())
|
| + Variable(scope_, function_name, fvar_mode, true /* is valid LHS */,
|
| + Variable::NORMAL, kCreatedInitialized, kNotAssigned,
|
| + Interface::NewConst());
|
| VariableProxy* proxy = factory()->NewVariableProxy(fvar);
|
| VariableDeclaration* fvar_declaration = factory()->NewVariableDeclaration(
|
| proxy, fvar_mode, scope_, RelocInfo::kNoPosition);
|
|
|