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

Side by Side Diff: src/scopes.cc

Issue 22901010: Fix scoping of function declarations in eval inside non-trivial local scope (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/parser.cc ('k') | test/mjsunit/regress/regress-2594.js » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 if (outer_scope_calls_non_strict_eval_) { 900 if (outer_scope_calls_non_strict_eval_) {
901 Indent(n1, "// outer scope calls 'eval' in non-strict context\n"); 901 Indent(n1, "// outer scope calls 'eval' in non-strict context\n");
902 } 902 }
903 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); 903 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n");
904 if (num_stack_slots_ > 0) { Indent(n1, "// "); 904 if (num_stack_slots_ > 0) { Indent(n1, "// ");
905 PrintF("%d stack slots\n", num_stack_slots_); } 905 PrintF("%d stack slots\n", num_stack_slots_); }
906 if (num_heap_slots_ > 0) { Indent(n1, "// "); 906 if (num_heap_slots_ > 0) { Indent(n1, "// ");
907 PrintF("%d heap slots\n", num_heap_slots_); } 907 PrintF("%d heap slots\n", num_heap_slots_); }
908 908
909 // Print locals. 909 // Print locals.
910 Indent(n1, "// function var\n");
911 if (function_ != NULL) { 910 if (function_ != NULL) {
911 Indent(n1, "// function var:\n");
912 PrintVar(n1, function_->proxy()->var()); 912 PrintVar(n1, function_->proxy()->var());
913 } 913 }
914 914
915 Indent(n1, "// temporary vars\n"); 915 if (temps_.length() > 0) {
916 for (int i = 0; i < temps_.length(); i++) { 916 Indent(n1, "// temporary vars:\n");
917 PrintVar(n1, temps_[i]); 917 for (int i = 0; i < temps_.length(); i++) {
918 PrintVar(n1, temps_[i]);
919 }
918 } 920 }
919 921
920 Indent(n1, "// internal vars\n"); 922 if (internals_.length() > 0) {
921 for (int i = 0; i < internals_.length(); i++) { 923 Indent(n1, "// internal vars:\n");
922 PrintVar(n1, internals_[i]); 924 for (int i = 0; i < internals_.length(); i++) {
925 PrintVar(n1, internals_[i]);
926 }
923 } 927 }
924 928
925 Indent(n1, "// local vars\n"); 929 if (variables_.Start() != NULL) {
926 PrintMap(n1, &variables_); 930 Indent(n1, "// local vars:\n");
931 PrintMap(n1, &variables_);
932 }
927 933
928 Indent(n1, "// dynamic vars\n");
929 if (dynamics_ != NULL) { 934 if (dynamics_ != NULL) {
935 Indent(n1, "// dynamic vars:\n");
930 PrintMap(n1, dynamics_->GetMap(DYNAMIC)); 936 PrintMap(n1, dynamics_->GetMap(DYNAMIC));
931 PrintMap(n1, dynamics_->GetMap(DYNAMIC_LOCAL)); 937 PrintMap(n1, dynamics_->GetMap(DYNAMIC_LOCAL));
932 PrintMap(n1, dynamics_->GetMap(DYNAMIC_GLOBAL)); 938 PrintMap(n1, dynamics_->GetMap(DYNAMIC_GLOBAL));
933 } 939 }
934 940
935 // Print inner scopes (disable by providing negative n). 941 // Print inner scopes (disable by providing negative n).
936 if (n >= 0) { 942 if (n >= 0) {
937 for (int i = 0; i < inner_scopes_.length(); i++) { 943 for (int i = 0; i < inner_scopes_.length(); i++) {
938 PrintF("\n"); 944 PrintF("\n");
939 inner_scopes_[i]->Print(n1); 945 inner_scopes_[i]->Print(n1);
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 } 1407 }
1402 1408
1403 1409
1404 int Scope::ContextLocalCount() const { 1410 int Scope::ContextLocalCount() const {
1405 if (num_heap_slots() == 0) return 0; 1411 if (num_heap_slots() == 0) return 0;
1406 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1412 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1407 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1413 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1408 } 1414 }
1409 1415
1410 } } // namespace v8::internal 1416 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | test/mjsunit/regress/regress-2594.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698