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

Unified Diff: src/full-codegen.cc

Issue 722793005: Classes: Implement correct name binding (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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
Index: src/full-codegen.cc
diff --git a/src/full-codegen.cc b/src/full-codegen.cc
index e399a3496c342f536e92fc0d4aee84a5d83270a2..6945e302d84b6dfe56e62fe8e4cb1f0b4eaa80ec 100644
--- a/src/full-codegen.cc
+++ b/src/full-codegen.cc
@@ -1605,6 +1605,25 @@ void FullCodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) {
void FullCodeGenerator::VisitClassLiteral(ClassLiteral* lit) {
Comment cmnt(masm_, "[ ClassLiteral");
+ Scope* saved_scope = scope();
+ if (lit->scope() != NULL) {
+ scope_ = lit->scope();
+ DCHECK(scope_->is_block_scope());
+ {
+ Comment cmnt(masm_, "[ Extend block context");
Dmitry Lomov (no reviews) 2014/11/13 11:17:37 Please share code with VisitBlock here (add an Ent
arv (Not doing code reviews) 2014/11/13 20:47:49 Done.
+ __ Push(scope_->GetScopeInfo());
+ PushFunctionArgumentForContextAllocation();
+ __ CallRuntime(Runtime::kPushBlockContext, 2);
+ StoreToFrameField(StandardFrameConstants::kContextOffset,
+ context_register());
+ }
+ {
+ Comment cmnt(masm_, "[ Declarations");
+ DCHECK_EQ(1, scope_->declarations()->length());
+ VisitDeclarations(scope_->declarations());
+ }
+ }
+
if (lit->raw_name() != NULL) {
__ Push(lit->name());
} else {
@@ -1626,6 +1645,15 @@ void FullCodeGenerator::VisitClassLiteral(ClassLiteral* lit) {
__ CallRuntime(Runtime::kDefineClass, 6);
EmitClassDefineProperties(lit);
+ if (lit->scope() != NULL) {
+ DCHECK_NOT_NULL(lit->proxy());
+ EmitVariableAssignment(lit->proxy()->var(), Token::INIT_CONST);
+ LoadContextField(context_register(), Context::PREVIOUS_INDEX);
Dmitry Lomov (no reviews) 2014/11/13 11:17:37 Please share code with VisitBlock here (add an Exi
arv (Not doing code reviews) 2014/11/13 20:47:49 Done.
+ StoreToFrameField(StandardFrameConstants::kContextOffset,
+ context_register());
+ }
+
+ scope_ = saved_scope;
context()->Plug(result_register());
}

Powered by Google App Engine
This is Rietveld 408576698