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

Side by Side Diff: src/scopeinfo.cc

Issue 1097283003: Resolve references to "this" the same way as normal variables (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Rebase and fix nits Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « src/runtime/runtime-scopes.cc ('k') | src/scopes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/scopeinfo.h" 9 #include "src/scopeinfo.h"
10 #include "src/scopes.h" 10 #include "src/scopes.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } 310 }
311 311
312 312
313 bool ScopeInfo::LocalIsSynthetic(int var) { 313 bool ScopeInfo::LocalIsSynthetic(int var) {
314 DCHECK(0 <= var && var < LocalCount()); 314 DCHECK(0 <= var && var < LocalCount());
315 // There's currently no flag stored on the ScopeInfo to indicate that a 315 // There's currently no flag stored on the ScopeInfo to indicate that a
316 // variable is a compiler-introduced temporary. However, to avoid conflict 316 // variable is a compiler-introduced temporary. However, to avoid conflict
317 // with user declarations, the current temporaries like .generator_object and 317 // with user declarations, the current temporaries like .generator_object and
318 // .result start with a dot, so we can use that as a flag. It's a hack! 318 // .result start with a dot, so we can use that as a flag. It's a hack!
319 Handle<String> name(LocalName(var)); 319 Handle<String> name(LocalName(var));
320 return name->length() > 0 && name->Get(0) == '.'; 320 return (name->length() > 0 && name->Get(0) == '.') ||
321 name->Equals(*GetIsolate()->factory()->this_string());
321 } 322 }
322 323
323 324
324 String* ScopeInfo::StrongModeFreeVariableName(int var) { 325 String* ScopeInfo::StrongModeFreeVariableName(int var) {
325 DCHECK(0 <= var && var < StrongModeFreeVariableCount()); 326 DCHECK(0 <= var && var < StrongModeFreeVariableCount());
326 int info_index = StrongModeFreeVariableNameEntriesIndex() + var; 327 int info_index = StrongModeFreeVariableNameEntriesIndex() + var;
327 return String::cast(get(info_index)); 328 return String::cast(get(info_index));
328 } 329 }
329 330
330 331
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 info->set_name(i, *(it.export_name()->string())); 660 info->set_name(i, *(it.export_name()->string()));
660 info->set_mode(i, var->mode()); 661 info->set_mode(i, var->mode());
661 DCHECK(var->index() >= 0); 662 DCHECK(var->index() >= 0);
662 info->set_index(i, var->index()); 663 info->set_index(i, var->index());
663 } 664 }
664 DCHECK(i == info->length()); 665 DCHECK(i == info->length());
665 return info; 666 return info;
666 } 667 }
667 668
668 } } // namespace v8::internal 669 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime-scopes.cc ('k') | src/scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698