OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 // The outermost scope must be a global scope. | 122 // The outermost scope must be a global scope. |
123 ASSERT(scope_type == GLOBAL_SCOPE || outer_scope != NULL); | 123 ASSERT(scope_type == GLOBAL_SCOPE || outer_scope != NULL); |
124 ASSERT(!HasIllegalRedeclaration()); | 124 ASSERT(!HasIllegalRedeclaration()); |
125 } | 125 } |
126 | 126 |
127 | 127 |
128 Scope::Scope(Scope* inner_scope, | 128 Scope::Scope(Scope* inner_scope, |
129 ScopeType scope_type, | 129 ScopeType scope_type, |
130 Handle<ScopeInfo> scope_info, | 130 Handle<ScopeInfo> scope_info, |
131 Zone* zone) | 131 Zone* zone) |
132 : isolate_(Isolate::Current()), | 132 : isolate_(zone->isolate()), |
133 inner_scopes_(4, zone), | 133 inner_scopes_(4, zone), |
134 variables_(zone), | 134 variables_(zone), |
135 internals_(4, zone), | 135 internals_(4, zone), |
136 temps_(4, zone), | 136 temps_(4, zone), |
137 params_(4, zone), | 137 params_(4, zone), |
138 unresolved_(16, zone), | 138 unresolved_(16, zone), |
139 decls_(4, zone), | 139 decls_(4, zone), |
140 interface_(NULL), | 140 interface_(NULL), |
141 already_resolved_(true), | 141 already_resolved_(true), |
142 zone_(zone) { | 142 zone_(zone) { |
143 SetDefaults(scope_type, NULL, scope_info); | 143 SetDefaults(scope_type, NULL, scope_info); |
144 if (!scope_info.is_null()) { | 144 if (!scope_info.is_null()) { |
145 num_heap_slots_ = scope_info_->ContextLength(); | 145 num_heap_slots_ = scope_info_->ContextLength(); |
146 } | 146 } |
147 // Ensure at least MIN_CONTEXT_SLOTS to indicate a materialized context. | 147 // Ensure at least MIN_CONTEXT_SLOTS to indicate a materialized context. |
148 num_heap_slots_ = Max(num_heap_slots_, | 148 num_heap_slots_ = Max(num_heap_slots_, |
149 static_cast<int>(Context::MIN_CONTEXT_SLOTS)); | 149 static_cast<int>(Context::MIN_CONTEXT_SLOTS)); |
150 AddInnerScope(inner_scope); | 150 AddInnerScope(inner_scope); |
151 } | 151 } |
152 | 152 |
153 | 153 |
154 Scope::Scope(Scope* inner_scope, Handle<String> catch_variable_name, Zone* zone) | 154 Scope::Scope(Scope* inner_scope, Handle<String> catch_variable_name, Zone* zone) |
155 : isolate_(Isolate::Current()), | 155 : isolate_(zone->isolate()), |
156 inner_scopes_(1, zone), | 156 inner_scopes_(1, zone), |
157 variables_(zone), | 157 variables_(zone), |
158 internals_(0, zone), | 158 internals_(0, zone), |
159 temps_(0, zone), | 159 temps_(0, zone), |
160 params_(0, zone), | 160 params_(0, zone), |
161 unresolved_(0, zone), | 161 unresolved_(0, zone), |
162 decls_(0, zone), | 162 decls_(0, zone), |
163 interface_(NULL), | 163 interface_(NULL), |
164 already_resolved_(true), | 164 already_resolved_(true), |
165 zone_(zone) { | 165 zone_(zone) { |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 break; | 1085 break; |
1086 } | 1086 } |
1087 | 1087 |
1088 ASSERT(var != NULL); | 1088 ASSERT(var != NULL); |
1089 | 1089 |
1090 if (FLAG_harmony_scoping && is_extended_mode() && | 1090 if (FLAG_harmony_scoping && is_extended_mode() && |
1091 var->is_const_mode() && proxy->IsLValue()) { | 1091 var->is_const_mode() && proxy->IsLValue()) { |
1092 // Assignment to const. Throw a syntax error. | 1092 // Assignment to const. Throw a syntax error. |
1093 MessageLocation location( | 1093 MessageLocation location( |
1094 info->script(), proxy->position(), proxy->position()); | 1094 info->script(), proxy->position(), proxy->position()); |
1095 Isolate* isolate = Isolate::Current(); | 1095 Isolate* isolate = info->isolate(); |
1096 Factory* factory = isolate->factory(); | 1096 Factory* factory = isolate->factory(); |
1097 Handle<JSArray> array = factory->NewJSArray(0); | 1097 Handle<JSArray> array = factory->NewJSArray(0); |
1098 Handle<Object> result = | 1098 Handle<Object> result = |
1099 factory->NewSyntaxError("harmony_const_assign", array); | 1099 factory->NewSyntaxError("harmony_const_assign", array); |
1100 isolate->Throw(*result, &location); | 1100 isolate->Throw(*result, &location); |
1101 return false; | 1101 return false; |
1102 } | 1102 } |
1103 | 1103 |
1104 if (FLAG_harmony_modules) { | 1104 if (FLAG_harmony_modules) { |
1105 bool ok; | 1105 bool ok; |
(...skipping 10 matching lines...) Expand all Loading... |
1116 proxy->interface()->Print(); | 1116 proxy->interface()->Print(); |
1117 PrintF("var: "); | 1117 PrintF("var: "); |
1118 var->interface()->Print(); | 1118 var->interface()->Print(); |
1119 } | 1119 } |
1120 #endif | 1120 #endif |
1121 | 1121 |
1122 // Inconsistent use of module. Throw a syntax error. | 1122 // Inconsistent use of module. Throw a syntax error. |
1123 // TODO(rossberg): generate more helpful error message. | 1123 // TODO(rossberg): generate more helpful error message. |
1124 MessageLocation location( | 1124 MessageLocation location( |
1125 info->script(), proxy->position(), proxy->position()); | 1125 info->script(), proxy->position(), proxy->position()); |
1126 Isolate* isolate = Isolate::Current(); | 1126 Isolate* isolate = info->isolate(); |
1127 Factory* factory = isolate->factory(); | 1127 Factory* factory = isolate->factory(); |
1128 Handle<JSArray> array = factory->NewJSArray(1); | 1128 Handle<JSArray> array = factory->NewJSArray(1); |
1129 USE(JSObject::SetElement(array, 0, var->name(), NONE, kStrictMode)); | 1129 USE(JSObject::SetElement(array, 0, var->name(), NONE, kStrictMode)); |
1130 Handle<Object> result = | 1130 Handle<Object> result = |
1131 factory->NewSyntaxError("module_type_error", array); | 1131 factory->NewSyntaxError("module_type_error", array); |
1132 isolate->Throw(*result, &location); | 1132 isolate->Throw(*result, &location); |
1133 return false; | 1133 return false; |
1134 } | 1134 } |
1135 } | 1135 } |
1136 | 1136 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 } | 1407 } |
1408 | 1408 |
1409 | 1409 |
1410 int Scope::ContextLocalCount() const { | 1410 int Scope::ContextLocalCount() const { |
1411 if (num_heap_slots() == 0) return 0; | 1411 if (num_heap_slots() == 0) return 0; |
1412 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1412 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
1413 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); | 1413 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); |
1414 } | 1414 } |
1415 | 1415 |
1416 } } // namespace v8::internal | 1416 } } // namespace v8::internal |
OLD | NEW |