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" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 Handle<ScopeInfo> scope_info = factory->NewScopeInfo(length); | 57 Handle<ScopeInfo> scope_info = factory->NewScopeInfo(length); |
58 | 58 |
59 // Encode the flags. | 59 // Encode the flags. |
60 int flags = ScopeTypeField::encode(scope->scope_type()) | | 60 int flags = ScopeTypeField::encode(scope->scope_type()) | |
61 CallsEvalField::encode(scope->calls_eval()) | | 61 CallsEvalField::encode(scope->calls_eval()) | |
62 LanguageModeField::encode(scope->language_mode()) | | 62 LanguageModeField::encode(scope->language_mode()) | |
63 FunctionVariableField::encode(function_name_info) | | 63 FunctionVariableField::encode(function_name_info) | |
64 FunctionVariableMode::encode(function_variable_mode) | | 64 FunctionVariableMode::encode(function_variable_mode) | |
65 AsmModuleField::encode(scope->asm_module()) | | 65 AsmModuleField::encode(scope->asm_module()) | |
66 AsmFunctionField::encode(scope->asm_function()) | | 66 AsmFunctionField::encode(scope->asm_function()) | |
67 IsSimpleParameterListField::encode(simple_parameter_list); | 67 IsSimpleParameterListField::encode(simple_parameter_list) | |
| 68 BlockScopeIsClassScopeField::encode(scope->is_class_scope()) | |
| 69 FunctionKindField::encode(scope->function_kind()); |
68 scope_info->SetFlags(flags); | 70 scope_info->SetFlags(flags); |
69 scope_info->SetParameterCount(parameter_count); | 71 scope_info->SetParameterCount(parameter_count); |
70 scope_info->SetStackLocalCount(stack_local_count); | 72 scope_info->SetStackLocalCount(stack_local_count); |
71 scope_info->SetContextLocalCount(context_local_count); | 73 scope_info->SetContextLocalCount(context_local_count); |
72 | 74 |
73 int index = kVariablePartIndex; | 75 int index = kVariablePartIndex; |
74 // Add parameters. | 76 // Add parameters. |
75 DCHECK(index == scope_info->ParameterEntriesIndex()); | 77 DCHECK(index == scope_info->ParameterEntriesIndex()); |
76 for (int i = 0; i < parameter_count; ++i) { | 78 for (int i = 0; i < parameter_count; ++i) { |
77 scope_info->set(index++, *scope->parameter(i)->name()); | 79 scope_info->set(index++, *scope->parameter(i)->name()); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 if (FunctionVariableField::decode(Flags()) == CONTEXT && | 368 if (FunctionVariableField::decode(Flags()) == CONTEXT && |
367 FunctionName() == name) { | 369 FunctionName() == name) { |
368 *mode = FunctionVariableMode::decode(Flags()); | 370 *mode = FunctionVariableMode::decode(Flags()); |
369 return Smi::cast(get(FunctionNameEntryIndex() + 1))->value(); | 371 return Smi::cast(get(FunctionNameEntryIndex() + 1))->value(); |
370 } | 372 } |
371 } | 373 } |
372 return -1; | 374 return -1; |
373 } | 375 } |
374 | 376 |
375 | 377 |
| 378 bool ScopeInfo::block_scope_is_class_scope() { |
| 379 return BlockScopeIsClassScopeField::decode(Flags()); |
| 380 } |
| 381 |
| 382 |
| 383 FunctionKind ScopeInfo::function_kind() { |
| 384 return FunctionKindField::decode(Flags()); |
| 385 } |
| 386 |
| 387 |
376 bool ScopeInfo::CopyContextLocalsToScopeObject(Handle<ScopeInfo> scope_info, | 388 bool ScopeInfo::CopyContextLocalsToScopeObject(Handle<ScopeInfo> scope_info, |
377 Handle<Context> context, | 389 Handle<Context> context, |
378 Handle<JSObject> scope_object) { | 390 Handle<JSObject> scope_object) { |
379 Isolate* isolate = scope_info->GetIsolate(); | 391 Isolate* isolate = scope_info->GetIsolate(); |
380 int local_count = scope_info->ContextLocalCount(); | 392 int local_count = scope_info->ContextLocalCount(); |
381 if (local_count == 0) return true; | 393 if (local_count == 0) return true; |
382 // Fill all context locals to the context extension. | 394 // Fill all context locals to the context extension. |
383 int first_context_var = scope_info->StackLocalCount(); | 395 int first_context_var = scope_info->StackLocalCount(); |
384 int start = scope_info->ContextLocalNameEntriesIndex(); | 396 int start = scope_info->ContextLocalNameEntriesIndex(); |
385 for (int i = 0; i < local_count; ++i) { | 397 for (int i = 0; i < local_count; ++i) { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 info->set_name(i, *(it.export_name()->string())); | 576 info->set_name(i, *(it.export_name()->string())); |
565 info->set_mode(i, var->mode()); | 577 info->set_mode(i, var->mode()); |
566 DCHECK(var->index() >= 0); | 578 DCHECK(var->index() >= 0); |
567 info->set_index(i, var->index()); | 579 info->set_index(i, var->index()); |
568 } | 580 } |
569 DCHECK(i == info->length()); | 581 DCHECK(i == info->length()); |
570 return info; | 582 return info; |
571 } | 583 } |
572 | 584 |
573 } } // namespace v8::internal | 585 } } // namespace v8::internal |
OLD | NEW |