OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/frames-inl.h" | 9 #include "src/frames-inl.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 } | 29 } |
30 | 30 |
31 | 31 |
32 // May throw a RedeclarationError. | 32 // May throw a RedeclarationError. |
33 static Object* DeclareGlobals(Isolate* isolate, Handle<GlobalObject> global, | 33 static Object* DeclareGlobals(Isolate* isolate, Handle<GlobalObject> global, |
34 Handle<String> name, Handle<Object> value, | 34 Handle<String> name, Handle<Object> value, |
35 PropertyAttributes attr, bool is_var, | 35 PropertyAttributes attr, bool is_var, |
36 bool is_const, bool is_function) { | 36 bool is_const, bool is_function) { |
37 Handle<ScriptContextTable> script_contexts( | 37 Handle<ScriptContextTable> script_contexts( |
38 global->native_context()->script_context_table()); | 38 global->native_context()->script_context_table()); |
39 ScriptContextTable::LookupResult lookup; | 39 if (ScriptContextTable::LookupLexical(script_contexts, name)) { |
40 if (ScriptContextTable::Lookup(script_contexts, name, &lookup) && | |
41 IsLexicalVariableMode(lookup.mode)) { | |
42 return ThrowRedeclarationError(isolate, name); | 40 return ThrowRedeclarationError(isolate, name); |
43 } | 41 } |
44 | 42 |
45 // Do the lookup own properties only, see ES5 erratum. | 43 // Do the lookup own properties only, see ES5 erratum. |
46 LookupIterator it(global, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR); | 44 LookupIterator it(global, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR); |
47 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); | 45 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); |
48 if (!maybe.IsJust()) return isolate->heap()->exception(); | 46 if (!maybe.IsJust()) return isolate->heap()->exception(); |
49 | 47 |
50 if (it.IsFound()) { | 48 if (it.IsFound()) { |
51 PropertyAttributes old_attributes = maybe.FromJust(); | 49 PropertyAttributes old_attributes = maybe.FromJust(); |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 pretenure_flag); | 615 pretenure_flag); |
618 } | 616 } |
619 | 617 |
620 static Object* FindNameClash(Handle<ScopeInfo> scope_info, | 618 static Object* FindNameClash(Handle<ScopeInfo> scope_info, |
621 Handle<GlobalObject> global_object, | 619 Handle<GlobalObject> global_object, |
622 Handle<ScriptContextTable> script_context) { | 620 Handle<ScriptContextTable> script_context) { |
623 Isolate* isolate = scope_info->GetIsolate(); | 621 Isolate* isolate = scope_info->GetIsolate(); |
624 for (int var = 0; var < scope_info->ContextLocalCount(); var++) { | 622 for (int var = 0; var < scope_info->ContextLocalCount(); var++) { |
625 Handle<String> name(scope_info->ContextLocalName(var)); | 623 Handle<String> name(scope_info->ContextLocalName(var)); |
626 VariableMode mode = scope_info->ContextLocalMode(var); | 624 VariableMode mode = scope_info->ContextLocalMode(var); |
627 ScriptContextTable::LookupResult lookup; | 625 if (IsLexicalVariableMode(mode)) { |
628 if (ScriptContextTable::Lookup(script_context, name, &lookup)) { | 626 ScriptContextTable::LookupResult lookup; |
629 if (IsLexicalVariableMode(mode) || IsLexicalVariableMode(lookup.mode)) { | 627 if (ScriptContextTable::Lookup(script_context, name, &lookup)) { |
| 628 return ThrowRedeclarationError(isolate, name); |
| 629 } |
| 630 } else { |
| 631 if (ScriptContextTable::LookupLexical(script_context, name)) { |
630 return ThrowRedeclarationError(isolate, name); | 632 return ThrowRedeclarationError(isolate, name); |
631 } | 633 } |
632 } | 634 } |
633 | 635 |
634 if (IsLexicalVariableMode(mode)) { | 636 if (IsLexicalVariableMode(mode)) { |
635 LookupIterator it(global_object, name, | 637 LookupIterator it(global_object, name, |
636 LookupIterator::HIDDEN_SKIP_INTERCEPTOR); | 638 LookupIterator::HIDDEN_SKIP_INTERCEPTOR); |
637 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); | 639 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); |
638 if (!maybe.IsJust()) return isolate->heap()->exception(); | 640 if (!maybe.IsJust()) return isolate->heap()->exception(); |
639 if ((maybe.FromJust() & DONT_DELETE) != 0) { | 641 if ((maybe.FromJust() & DONT_DELETE) != 0) { |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 | 1163 |
1162 // Lookup in the initial Object.prototype object. | 1164 // Lookup in the initial Object.prototype object. |
1163 Handle<Object> result; | 1165 Handle<Object> result; |
1164 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1166 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1165 isolate, result, | 1167 isolate, result, |
1166 Object::GetProperty(isolate->initial_object_prototype(), key)); | 1168 Object::GetProperty(isolate->initial_object_prototype(), key)); |
1167 return *result; | 1169 return *result; |
1168 } | 1170 } |
1169 } // namespace internal | 1171 } // namespace internal |
1170 } // namespace v8 | 1172 } // namespace v8 |
OLD | NEW |