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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 inner_scopes_(4), | 141 inner_scopes_(4), |
142 variables_(), | 142 variables_(), |
143 temps_(4), | 143 temps_(4), |
144 params_(4), | 144 params_(4), |
145 unresolved_(16), | 145 unresolved_(16), |
146 decls_(4), | 146 decls_(4), |
147 already_resolved_(true) { | 147 already_resolved_(true) { |
148 SetDefaults(type, NULL, scope_info); | 148 SetDefaults(type, NULL, scope_info); |
149 if (!scope_info.is_null()) { | 149 if (!scope_info.is_null()) { |
150 num_heap_slots_ = scope_info_->ContextLength(); | 150 num_heap_slots_ = scope_info_->ContextLength(); |
151 if (*scope_info != ScopeInfo::Empty()) { | |
152 language_mode_ = scope_info->language_mode(); | |
153 } | |
154 } else if (is_with_scope()) { | |
155 num_heap_slots_ = Context::MIN_CONTEXT_SLOTS; | |
156 } | 151 } |
| 152 // Ensure at least MIN_CONTEXT_SLOTS to indicate a materialized context. |
| 153 num_heap_slots_ = Max(num_heap_slots_, |
| 154 static_cast<int>(Context::MIN_CONTEXT_SLOTS)); |
157 AddInnerScope(inner_scope); | 155 AddInnerScope(inner_scope); |
158 } | 156 } |
159 | 157 |
160 | 158 |
161 Scope::Scope(Scope* inner_scope, Handle<String> catch_variable_name) | 159 Scope::Scope(Scope* inner_scope, Handle<String> catch_variable_name) |
162 : isolate_(Isolate::Current()), | 160 : isolate_(Isolate::Current()), |
163 inner_scopes_(1), | 161 inner_scopes_(1), |
164 variables_(), | 162 variables_(), |
165 temps_(0), | 163 temps_(0), |
166 params_(0), | 164 params_(0), |
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 } | 1187 } |
1190 | 1188 |
1191 | 1189 |
1192 int Scope::ContextLocalCount() const { | 1190 int Scope::ContextLocalCount() const { |
1193 if (num_heap_slots() == 0) return 0; | 1191 if (num_heap_slots() == 0) return 0; |
1194 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1192 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
1195 (function_ != NULL && function_->var()->IsContextSlot() ? 1 : 0); | 1193 (function_ != NULL && function_->var()->IsContextSlot() ? 1 : 0); |
1196 } | 1194 } |
1197 | 1195 |
1198 } } // namespace v8::internal | 1196 } } // namespace v8::internal |
OLD | NEW |