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

Side by Side Diff: src/scopes.cc

Issue 10876067: Introduce global contexts to represent lexical global scope(s). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Sven's comments. Created 8 years, 3 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/scopes.h ('k') | src/x64/full-codegen-x64.cc » ('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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 Scope* with_scope = new(zone) Scope(current_scope, 220 Scope* with_scope = new(zone) Scope(current_scope,
221 WITH_SCOPE, 221 WITH_SCOPE,
222 Handle<ScopeInfo>::null(), 222 Handle<ScopeInfo>::null(),
223 zone); 223 zone);
224 current_scope = with_scope; 224 current_scope = with_scope;
225 // All the inner scopes are inside a with. 225 // All the inner scopes are inside a with.
226 contains_with = true; 226 contains_with = true;
227 for (Scope* s = innermost_scope; s != NULL; s = s->outer_scope()) { 227 for (Scope* s = innermost_scope; s != NULL; s = s->outer_scope()) {
228 s->scope_inside_with_ = true; 228 s->scope_inside_with_ = true;
229 } 229 }
230 } else if (context->IsGlobalContext()) {
231 ScopeInfo* scope_info = ScopeInfo::cast(context->extension());
232 current_scope = new(zone) Scope(current_scope,
233 GLOBAL_SCOPE,
234 Handle<ScopeInfo>(scope_info),
235 zone);
230 } else if (context->IsModuleContext()) { 236 } else if (context->IsModuleContext()) {
231 ScopeInfo* scope_info = ScopeInfo::cast(context->module()->scope_info()); 237 ScopeInfo* scope_info = ScopeInfo::cast(context->module()->scope_info());
232 current_scope = new(zone) Scope(current_scope, 238 current_scope = new(zone) Scope(current_scope,
233 MODULE_SCOPE, 239 MODULE_SCOPE,
234 Handle<ScopeInfo>(scope_info), 240 Handle<ScopeInfo>(scope_info),
235 zone); 241 zone);
236 } else if (context->IsFunctionContext()) { 242 } else if (context->IsFunctionContext()) {
237 ScopeInfo* scope_info = context->closure()->shared()->scope_info(); 243 ScopeInfo* scope_info = context->closure()->shared()->scope_info();
238 current_scope = new(zone) Scope(current_scope, 244 current_scope = new(zone) Scope(current_scope,
239 FUNCTION_SCOPE, 245 FUNCTION_SCOPE,
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 ASSERT(mode == VAR || 490 ASSERT(mode == VAR ||
485 mode == CONST || 491 mode == CONST ||
486 mode == CONST_HARMONY || 492 mode == CONST_HARMONY ||
487 mode == LET); 493 mode == LET);
488 ++num_var_or_const_; 494 ++num_var_or_const_;
489 return variables_.Declare( 495 return variables_.Declare(
490 this, name, mode, true, Variable::NORMAL, init_flag, interface); 496 this, name, mode, true, Variable::NORMAL, init_flag, interface);
491 } 497 }
492 498
493 499
494 Variable* Scope::DeclareGlobal(Handle<String> name) { 500 Variable* Scope::DeclareDynamicGlobal(Handle<String> name) {
495 ASSERT(is_global_scope()); 501 ASSERT(is_global_scope());
496 return variables_.Declare(this, 502 return variables_.Declare(this,
497 name, 503 name,
498 DYNAMIC_GLOBAL, 504 DYNAMIC_GLOBAL,
499 true, 505 true,
500 Variable::NORMAL, 506 Variable::NORMAL,
501 kCreatedInitialized); 507 kCreatedInitialized);
502 } 508 }
503 509
504 510
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 } else if (var->is_dynamic()) { 1046 } else if (var->is_dynamic()) {
1041 var = NonLocal(proxy->name(), DYNAMIC); 1047 var = NonLocal(proxy->name(), DYNAMIC);
1042 } else { 1048 } else {
1043 Variable* invalidated = var; 1049 Variable* invalidated = var;
1044 var = NonLocal(proxy->name(), DYNAMIC_LOCAL); 1050 var = NonLocal(proxy->name(), DYNAMIC_LOCAL);
1045 var->set_local_if_not_shadowed(invalidated); 1051 var->set_local_if_not_shadowed(invalidated);
1046 } 1052 }
1047 break; 1053 break;
1048 1054
1049 case UNBOUND: 1055 case UNBOUND:
1050 // No binding has been found. Declare a variable in global scope. 1056 // No binding has been found. Declare a variable on the global object.
1051 var = info->global_scope()->DeclareGlobal(proxy->name()); 1057 var = info->global_scope()->DeclareDynamicGlobal(proxy->name());
1052 break; 1058 break;
1053 1059
1054 case UNBOUND_EVAL_SHADOWED: 1060 case UNBOUND_EVAL_SHADOWED:
1055 // No binding has been found. But some scope makes a 1061 // No binding has been found. But some scope makes a
1056 // non-strict 'eval' call. 1062 // non-strict 'eval' call.
1057 var = NonLocal(proxy->name(), DYNAMIC_GLOBAL); 1063 var = NonLocal(proxy->name(), DYNAMIC_GLOBAL);
1058 break; 1064 break;
1059 1065
1060 case DYNAMIC_LOOKUP: 1066 case DYNAMIC_LOOKUP:
1061 // The variable could not be resolved statically. 1067 // The variable could not be resolved statically.
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 for (int i = 0; i < inner_scopes_.length(); i++) { 1425 for (int i = 0; i < inner_scopes_.length(); i++) {
1420 Scope* inner_scope = inner_scopes_.at(i); 1426 Scope* inner_scope = inner_scopes_.at(i);
1421 if (inner_scope->is_module_scope()) { 1427 if (inner_scope->is_module_scope()) {
1422 inner_scope->LinkModules(info); 1428 inner_scope->LinkModules(info);
1423 } 1429 }
1424 } 1430 }
1425 } 1431 }
1426 1432
1427 1433
1428 } } // namespace v8::internal 1434 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698