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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 const bool has_function_name = function_name_info != NONE; | 71 const bool has_function_name = function_name_info != NONE; |
72 const int parameter_count = scope->num_parameters(); | 72 const int parameter_count = scope->num_parameters(); |
73 const int length = kVariablePartIndex | 73 const int length = kVariablePartIndex |
74 + parameter_count + stack_local_count + 2 * context_local_count | 74 + parameter_count + stack_local_count + 2 * context_local_count |
75 + (has_function_name ? 2 : 0); | 75 + (has_function_name ? 2 : 0); |
76 | 76 |
77 Factory* factory = Isolate::Current()->factory(); | 77 Factory* factory = Isolate::Current()->factory(); |
78 Handle<ScopeInfo> scope_info = factory->NewScopeInfo(length); | 78 Handle<ScopeInfo> scope_info = factory->NewScopeInfo(length); |
79 | 79 |
80 // Encode the flags. | 80 // Encode the flags. |
81 int flags = TypeField::encode(scope->type()) | | 81 int flags = ScopeTypeField::encode(scope->scope_type()) | |
82 CallsEvalField::encode(scope->calls_eval()) | | 82 CallsEvalField::encode(scope->calls_eval()) | |
83 LanguageModeField::encode(scope->language_mode()) | | 83 LanguageModeField::encode(scope->language_mode()) | |
84 FunctionVariableField::encode(function_name_info) | | 84 FunctionVariableField::encode(function_name_info) | |
85 FunctionVariableMode::encode(function_variable_mode); | 85 FunctionVariableMode::encode(function_variable_mode); |
86 scope_info->SetFlags(flags); | 86 scope_info->SetFlags(flags); |
87 scope_info->SetParameterCount(parameter_count); | 87 scope_info->SetParameterCount(parameter_count); |
88 scope_info->SetStackLocalCount(stack_local_count); | 88 scope_info->SetStackLocalCount(stack_local_count); |
89 scope_info->SetContextLocalCount(context_local_count); | 89 scope_info->SetContextLocalCount(context_local_count); |
90 | 90 |
91 int index = kVariablePartIndex; | 91 int index = kVariablePartIndex; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 scope_info->ContextLength() == 0)); | 148 scope_info->ContextLength() == 0)); |
149 return scope_info; | 149 return scope_info; |
150 } | 150 } |
151 | 151 |
152 | 152 |
153 ScopeInfo* ScopeInfo::Empty(Isolate* isolate) { | 153 ScopeInfo* ScopeInfo::Empty(Isolate* isolate) { |
154 return reinterpret_cast<ScopeInfo*>(isolate->heap()->empty_fixed_array()); | 154 return reinterpret_cast<ScopeInfo*>(isolate->heap()->empty_fixed_array()); |
155 } | 155 } |
156 | 156 |
157 | 157 |
158 ScopeType ScopeInfo::Type() { | 158 ScopeType ScopeInfo::scope_type() { |
159 ASSERT(length() > 0); | 159 ASSERT(length() > 0); |
160 return TypeField::decode(Flags()); | 160 return ScopeTypeField::decode(Flags()); |
161 } | 161 } |
162 | 162 |
163 | 163 |
164 bool ScopeInfo::CallsEval() { | 164 bool ScopeInfo::CallsEval() { |
165 return length() > 0 && CallsEvalField::decode(Flags()); | 165 return length() > 0 && CallsEvalField::decode(Flags()); |
166 } | 166 } |
167 | 167 |
168 | 168 |
169 LanguageMode ScopeInfo::language_mode() { | 169 LanguageMode ScopeInfo::language_mode() { |
170 return length() > 0 ? LanguageModeField::decode(Flags()) : CLASSIC_MODE; | 170 return length() > 0 ? LanguageModeField::decode(Flags()) : CLASSIC_MODE; |
(...skipping 15 matching lines...) Expand all Loading... |
186 } | 186 } |
187 | 187 |
188 | 188 |
189 int ScopeInfo::ContextLength() { | 189 int ScopeInfo::ContextLength() { |
190 if (length() > 0) { | 190 if (length() > 0) { |
191 int context_locals = ContextLocalCount(); | 191 int context_locals = ContextLocalCount(); |
192 bool function_name_context_slot = | 192 bool function_name_context_slot = |
193 FunctionVariableField::decode(Flags()) == CONTEXT; | 193 FunctionVariableField::decode(Flags()) == CONTEXT; |
194 bool has_context = context_locals > 0 || | 194 bool has_context = context_locals > 0 || |
195 function_name_context_slot || | 195 function_name_context_slot || |
196 Type() == WITH_SCOPE || | 196 scope_type() == WITH_SCOPE || |
197 (Type() == FUNCTION_SCOPE && CallsEval()) || | 197 (scope_type() == FUNCTION_SCOPE && CallsEval()) || |
198 Type() == MODULE_SCOPE; | 198 scope_type() == MODULE_SCOPE; |
199 if (has_context) { | 199 if (has_context) { |
200 return Context::MIN_CONTEXT_SLOTS + context_locals + | 200 return Context::MIN_CONTEXT_SLOTS + context_locals + |
201 (function_name_context_slot ? 1 : 0); | 201 (function_name_context_slot ? 1 : 0); |
202 } | 202 } |
203 } | 203 } |
204 return 0; | 204 return 0; |
205 } | 205 } |
206 | 206 |
207 | 207 |
208 bool ScopeInfo::HasFunctionName() { | 208 bool ScopeInfo::HasFunctionName() { |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 } else { | 553 } else { |
554 ASSERT(var->index() >= 0); | 554 ASSERT(var->index() >= 0); |
555 info->set_index(i, var->index()); | 555 info->set_index(i, var->index()); |
556 } | 556 } |
557 } | 557 } |
558 ASSERT(i == info->length()); | 558 ASSERT(i == info->length()); |
559 return info; | 559 return info; |
560 } | 560 } |
561 | 561 |
562 } } // namespace v8::internal | 562 } } // namespace v8::internal |
OLD | NEW |