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