| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdlib.h> | 5 #include <stdlib.h> |
| 6 | 6 |
| 7 #include "src/v8.h" | 7 #include "src/v8.h" |
| 8 | 8 |
| 9 #include "src/scopeinfo.h" | 9 #include "src/scopeinfo.h" |
| 10 #include "src/scopes.h" | 10 #include "src/scopes.h" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 | 14 |
| 15 | 15 |
| 16 Handle<ScopeInfo> ScopeInfo::Create(Scope* scope, Zone* zone) { | 16 Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, |
| 17 Scope* scope) { |
| 17 // Collect stack and context locals. | 18 // Collect stack and context locals. |
| 18 ZoneList<Variable*> stack_locals(scope->StackLocalCount(), zone); | 19 ZoneList<Variable*> stack_locals(scope->StackLocalCount(), zone); |
| 19 ZoneList<Variable*> context_locals(scope->ContextLocalCount(), zone); | 20 ZoneList<Variable*> context_locals(scope->ContextLocalCount(), zone); |
| 20 scope->CollectStackAndContextLocals(&stack_locals, &context_locals); | 21 scope->CollectStackAndContextLocals(&stack_locals, &context_locals); |
| 21 const int stack_local_count = stack_locals.length(); | 22 const int stack_local_count = stack_locals.length(); |
| 22 const int context_local_count = context_locals.length(); | 23 const int context_local_count = context_locals.length(); |
| 23 // Make sure we allocate the correct amount. | 24 // Make sure we allocate the correct amount. |
| 24 DCHECK(scope->StackLocalCount() == stack_local_count); | 25 DCHECK(scope->StackLocalCount() == stack_local_count); |
| 25 DCHECK(scope->ContextLocalCount() == context_local_count); | 26 DCHECK(scope->ContextLocalCount() == context_local_count); |
| 26 | 27 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 42 function_name_info = NONE; | 43 function_name_info = NONE; |
| 43 function_variable_mode = VAR; | 44 function_variable_mode = VAR; |
| 44 } | 45 } |
| 45 | 46 |
| 46 const bool has_function_name = function_name_info != NONE; | 47 const bool has_function_name = function_name_info != NONE; |
| 47 const int parameter_count = scope->num_parameters(); | 48 const int parameter_count = scope->num_parameters(); |
| 48 const int length = kVariablePartIndex | 49 const int length = kVariablePartIndex |
| 49 + parameter_count + stack_local_count + 2 * context_local_count | 50 + parameter_count + stack_local_count + 2 * context_local_count |
| 50 + (has_function_name ? 2 : 0); | 51 + (has_function_name ? 2 : 0); |
| 51 | 52 |
| 52 Factory* factory = zone->isolate()->factory(); | 53 Factory* factory = isolate->factory(); |
| 53 Handle<ScopeInfo> scope_info = factory->NewScopeInfo(length); | 54 Handle<ScopeInfo> scope_info = factory->NewScopeInfo(length); |
| 54 | 55 |
| 55 // Encode the flags. | 56 // Encode the flags. |
| 56 int flags = ScopeTypeField::encode(scope->scope_type()) | | 57 int flags = ScopeTypeField::encode(scope->scope_type()) | |
| 57 CallsEvalField::encode(scope->calls_eval()) | | 58 CallsEvalField::encode(scope->calls_eval()) | |
| 58 StrictModeField::encode(scope->strict_mode()) | | 59 StrictModeField::encode(scope->strict_mode()) | |
| 59 FunctionVariableField::encode(function_name_info) | | 60 FunctionVariableField::encode(function_name_info) | |
| 60 FunctionVariableMode::encode(function_variable_mode) | | 61 FunctionVariableMode::encode(function_variable_mode) | |
| 61 AsmModuleField::encode(scope->asm_module()) | | 62 AsmModuleField::encode(scope->asm_module()) | |
| 62 AsmFunctionField::encode(scope->asm_function()); | 63 AsmFunctionField::encode(scope->asm_function()); |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 } else { | 566 } else { |
| 566 DCHECK(var->index() >= 0); | 567 DCHECK(var->index() >= 0); |
| 567 info->set_index(i, var->index()); | 568 info->set_index(i, var->index()); |
| 568 } | 569 } |
| 569 } | 570 } |
| 570 DCHECK(i == info->length()); | 571 DCHECK(i == info->length()); |
| 571 return info; | 572 return info; |
| 572 } | 573 } |
| 573 | 574 |
| 574 } } // namespace v8::internal | 575 } } // namespace v8::internal |
| OLD | NEW |