OLD | NEW |
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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 // allocated during variable allocation. | 324 // allocated during variable allocation. |
325 variables_.Declare(this, | 325 variables_.Declare(this, |
326 isolate_->factory()->arguments_symbol(), | 326 isolate_->factory()->arguments_symbol(), |
327 Variable::VAR, | 327 Variable::VAR, |
328 true, | 328 true, |
329 Variable::ARGUMENTS); | 329 Variable::ARGUMENTS); |
330 } | 330 } |
331 } | 331 } |
332 | 332 |
333 | 333 |
| 334 Scope* Scope::FinalizeBlockScope() { |
| 335 ASSERT(is_block_scope()); |
| 336 ASSERT(decls_.is_empty()); |
| 337 ASSERT(temps_.is_empty()); |
| 338 ASSERT(params_.is_empty()); |
| 339 |
| 340 if (num_var_or_const() > 0) return this; |
| 341 |
| 342 // Remove this scope from outer scope. |
| 343 for (int i = 0; i < outer_scope_->inner_scopes_.length(); i++) { |
| 344 if (outer_scope_->inner_scopes_[i] == this) { |
| 345 outer_scope_->inner_scopes_.Remove(i); |
| 346 break; |
| 347 } |
| 348 } |
| 349 |
| 350 // Reparent inner scopes. |
| 351 for (int i = 0; i < inner_scopes_.length(); i++) { |
| 352 outer_scope()->AddInnerScope(inner_scopes_[i]); |
| 353 } |
| 354 |
| 355 // Move unresolved variables |
| 356 for (int i = 0; i < unresolved_.length(); i++) { |
| 357 outer_scope()->unresolved_.Add(unresolved_[i]); |
| 358 } |
| 359 |
| 360 return NULL; |
| 361 } |
| 362 |
| 363 |
334 Variable* Scope::LocalLookup(Handle<String> name) { | 364 Variable* Scope::LocalLookup(Handle<String> name) { |
335 Variable* result = variables_.Lookup(name); | 365 Variable* result = variables_.Lookup(name); |
336 if (result != NULL || scope_info_.is_null()) { | 366 if (result != NULL || scope_info_.is_null()) { |
337 return result; | 367 return result; |
338 } | 368 } |
339 // If we have a serialized scope info, we might find the variable there. | 369 // If we have a serialized scope info, we might find the variable there. |
340 // | 370 // |
341 // We should never lookup 'arguments' in this scope as it is implicitly | 371 // We should never lookup 'arguments' in this scope as it is implicitly |
342 // present in every scope. | 372 // present in every scope. |
343 ASSERT(*name != *isolate_->factory()->arguments_symbol()); | 373 ASSERT(*name != *isolate_->factory()->arguments_symbol()); |
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && | 1183 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && |
1154 !must_have_local_context) { | 1184 !must_have_local_context) { |
1155 num_heap_slots_ = 0; | 1185 num_heap_slots_ = 0; |
1156 } | 1186 } |
1157 | 1187 |
1158 // Allocation done. | 1188 // Allocation done. |
1159 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); | 1189 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); |
1160 } | 1190 } |
1161 | 1191 |
1162 } } // namespace v8::internal | 1192 } } // namespace v8::internal |
OLD | NEW |