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

Side by Side Diff: src/parser.cc

Issue 6883200: Strict mode eval declares its locals in its own environment. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 // 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 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 // If we are inside a function, a declaration of a variable 1296 // If we are inside a function, a declaration of a variable
1297 // is a truly local variable, and the scope of the variable 1297 // is a truly local variable, and the scope of the variable
1298 // is always the function scope. 1298 // is always the function scope.
1299 1299
1300 // If a function scope exists, then we can statically declare this 1300 // If a function scope exists, then we can statically declare this
1301 // variable and also set its mode. In any case, a Declaration node 1301 // variable and also set its mode. In any case, a Declaration node
1302 // will be added to the scope so that the declaration can be added 1302 // will be added to the scope so that the declaration can be added
1303 // to the corresponding activation frame at runtime if necessary. 1303 // to the corresponding activation frame at runtime if necessary.
1304 // For instance declarations inside an eval scope need to be added 1304 // For instance declarations inside an eval scope need to be added
1305 // to the calling function context. 1305 // to the calling function context.
1306 if (top_scope_->is_function_scope()) { 1306 // Similarly, strict mode eval scope does not leak variable declarations to
1307 // the caller's scope so we declare all locals, too.
1308 if (top_scope_->is_function_scope() ||
1309 top_scope_->is_strict_mode_eval_scope()) {
1307 // Declare the variable in the function scope. 1310 // Declare the variable in the function scope.
1308 var = top_scope_->LocalLookup(name); 1311 var = top_scope_->LocalLookup(name);
1309 if (var == NULL) { 1312 if (var == NULL) {
1310 // Declare the name. 1313 // Declare the name.
1311 var = top_scope_->DeclareLocal(name, mode); 1314 var = top_scope_->DeclareLocal(name, mode);
1312 } else { 1315 } else {
1313 // The name was declared before; check for conflicting 1316 // The name was declared before; check for conflicting
1314 // re-declarations. If the previous declaration was a const or the 1317 // re-declarations. If the previous declaration was a const or the
1315 // current declaration is a const then we have a conflict. There is 1318 // current declaration is a const then we have a conflict. There is
1316 // similar code in runtime.cc in the Declare functions. 1319 // similar code in runtime.cc in the Declare functions.
(...skipping 3834 matching lines...) Expand 10 before | Expand all | Expand 10 after
5151 info->is_global(), 5154 info->is_global(),
5152 info->StrictMode()); 5155 info->StrictMode());
5153 } 5156 }
5154 } 5157 }
5155 5158
5156 info->SetFunction(result); 5159 info->SetFunction(result);
5157 return (result != NULL); 5160 return (result != NULL);
5158 } 5161 }
5159 5162
5160 } } // namespace v8::internal 5163 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698