OLD | NEW |
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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 | 478 |
479 | 479 |
480 Variable* Scope::DeclareLocal(Handle<String> name, | 480 Variable* Scope::DeclareLocal(Handle<String> name, |
481 VariableMode mode, | 481 VariableMode mode, |
482 InitializationFlag init_flag, | 482 InitializationFlag init_flag, |
483 Interface* interface) { | 483 Interface* interface) { |
484 ASSERT(!already_resolved()); | 484 ASSERT(!already_resolved()); |
485 // This function handles VAR and CONST modes. DYNAMIC variables are | 485 // This function handles VAR and CONST modes. DYNAMIC variables are |
486 // introduces during variable allocation, INTERNAL variables are allocated | 486 // introduces during variable allocation, INTERNAL variables are allocated |
487 // explicitly, and TEMPORARY variables are allocated via NewTemporary(). | 487 // explicitly, and TEMPORARY variables are allocated via NewTemporary(). |
488 ASSERT(mode == VAR || | 488 ASSERT(IsDeclaredVariableMode(mode)); |
489 mode == CONST || | |
490 mode == CONST_HARMONY || | |
491 mode == LET); | |
492 ++num_var_or_const_; | 489 ++num_var_or_const_; |
493 return variables_.Declare( | 490 return variables_.Declare( |
494 this, name, mode, true, Variable::NORMAL, init_flag, interface); | 491 this, name, mode, true, Variable::NORMAL, init_flag, interface); |
495 } | 492 } |
496 | 493 |
497 | 494 |
498 Variable* Scope::DeclareDynamicGlobal(Handle<String> name) { | 495 Variable* Scope::DeclareDynamicGlobal(Handle<String> name) { |
499 ASSERT(is_global_scope()); | 496 ASSERT(is_global_scope()); |
500 return variables_.Declare(this, | 497 return variables_.Declare(this, |
501 name, | 498 name, |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 bool Scope::MustAllocateInContext(Variable* var) { | 1169 bool Scope::MustAllocateInContext(Variable* var) { |
1173 // If var is accessed from an inner scope, or if there is a possibility | 1170 // If var is accessed from an inner scope, or if there is a possibility |
1174 // that it might be accessed from the current or an inner scope (through | 1171 // that it might be accessed from the current or an inner scope (through |
1175 // an eval() call or a runtime with lookup), it must be allocated in the | 1172 // an eval() call or a runtime with lookup), it must be allocated in the |
1176 // context. | 1173 // context. |
1177 // | 1174 // |
1178 // Exceptions: temporary variables are never allocated in a context; | 1175 // Exceptions: temporary variables are never allocated in a context; |
1179 // catch-bound variables are always allocated in a context. | 1176 // catch-bound variables are always allocated in a context. |
1180 if (var->mode() == TEMPORARY) return false; | 1177 if (var->mode() == TEMPORARY) return false; |
1181 if (is_catch_scope() || is_block_scope() || is_module_scope()) return true; | 1178 if (is_catch_scope() || is_block_scope() || is_module_scope()) return true; |
1182 if (is_global_scope() && (var->mode() == LET || var->mode() == CONST_HARMONY)) | 1179 if (is_global_scope() && IsLexicalVariableMode(var->mode())) return true; |
1183 return true; | |
1184 return var->has_forced_context_allocation() || | 1180 return var->has_forced_context_allocation() || |
1185 scope_calls_eval_ || | 1181 scope_calls_eval_ || |
1186 inner_scope_calls_eval_ || | 1182 inner_scope_calls_eval_ || |
1187 scope_contains_with_; | 1183 scope_contains_with_; |
1188 } | 1184 } |
1189 | 1185 |
1190 | 1186 |
1191 bool Scope::HasArgumentsParameter() { | 1187 bool Scope::HasArgumentsParameter() { |
1192 for (int i = 0; i < params_.length(); i++) { | 1188 for (int i = 0; i < params_.length(); i++) { |
1193 if (params_[i]->name().is_identical_to( | 1189 if (params_[i]->name().is_identical_to( |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 for (int i = 0; i < inner_scopes_.length(); i++) { | 1421 for (int i = 0; i < inner_scopes_.length(); i++) { |
1426 Scope* inner_scope = inner_scopes_.at(i); | 1422 Scope* inner_scope = inner_scopes_.at(i); |
1427 if (inner_scope->is_module_scope()) { | 1423 if (inner_scope->is_module_scope()) { |
1428 inner_scope->LinkModules(info); | 1424 inner_scope->LinkModules(info); |
1429 } | 1425 } |
1430 } | 1426 } |
1431 } | 1427 } |
1432 | 1428 |
1433 | 1429 |
1434 } } // namespace v8::internal | 1430 } } // namespace v8::internal |
OLD | NEW |