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

Unified Diff: src/scopes.cc

Issue 1053773006: [es6] implement default/optional parameters (WIP / comments) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Experimental not-quite-TDZ support Created 5 years, 8 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/scopes.h ('k') | src/variables.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopes.cc
diff --git a/src/scopes.cc b/src/scopes.cc
index 93268ad31905015d78f014430124f70e6e7d1807..f4cf85144a4df19d6142fbccdd0637dbd2cca699 100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -136,11 +136,21 @@ Scope::Scope(Zone* zone, Scope* inner_scope,
}
+void Scope::SetParameterExpressionsScopeFor(Scope* function_scope) {
+ DCHECK(function_scope->outer_scope() == outer_scope());
+ DCHECK(function_scope->is_function_scope());
+ DCHECK_NULL(parameter_scope_);
+ SetScopeName(ast_value_factory_->GetOneByteString("parameter expressions"));
+ parameter_scope_ = function_scope;
+}
+
+
void Scope::SetDefaults(ScopeType scope_type, Scope* outer_scope,
Handle<ScopeInfo> scope_info,
FunctionKind function_kind) {
outer_scope_ = outer_scope;
scope_type_ = scope_type;
+ parameter_scope_ = nullptr;
function_kind_ = function_kind;
block_scope_is_class_scope_ = false;
scope_name_ = ast_value_factory_->empty_string();
@@ -377,6 +387,13 @@ Scope* Scope::FinalizeBlockScope() {
Variable* Scope::LookupLocal(const AstRawString* name) {
+ if (parameter_scope_) {
+ Variable* result = parameter_scope_->variables_.Lookup(name);
+ if (result != nullptr && parameter_scope_->params_.Contains(result)) {
+ return result;
+ }
+ }
+
Variable* result = variables_.Lookup(name);
if (result != NULL || scope_info_.is_null()) {
return result;
@@ -452,12 +469,13 @@ Variable* Scope::Lookup(const AstRawString* name) {
Variable* Scope::DeclareParameter(const AstRawString* name, VariableMode mode,
- bool is_rest) {
+ ParameterKind kind) {
DCHECK(!already_resolved());
DCHECK(is_function_scope());
Variable* var = variables_.Declare(this, name, mode, Variable::NORMAL,
kCreatedInitialized);
- if (is_rest) {
+ var->set_parameter_kind(kind);
+ if (kind == RestParameter) {
DCHECK_NULL(rest_parameter_);
rest_parameter_ = var;
rest_index_ = num_parameters();
« no previous file with comments | « src/scopes.h ('k') | src/variables.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698