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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 if (is_var) return isolate->heap()->undefined_value(); | 79 if (is_var) return isolate->heap()->undefined_value(); |
80 | 80 |
81 DCHECK(is_function_declaration); | 81 DCHECK(is_function_declaration); |
82 if ((old_attributes & DONT_DELETE) != 0) { | 82 if ((old_attributes & DONT_DELETE) != 0) { |
83 // Only allow reconfiguring globals to functions in user code (no | 83 // Only allow reconfiguring globals to functions in user code (no |
84 // natives, which are marked as read-only). | 84 // natives, which are marked as read-only). |
85 DCHECK((attr & READ_ONLY) == 0); | 85 DCHECK((attr & READ_ONLY) == 0); |
86 | 86 |
87 // Check whether we can reconfigure the existing property into a | 87 // Check whether we can reconfigure the existing property into a |
88 // function. | 88 // function. |
89 PropertyDetails old_details = it.property_details(); | 89 if (old_attributes & READ_ONLY || old_attributes & DONT_ENUM || |
90 if (old_details.IsReadOnly() || old_details.IsDontEnum() || | |
91 (it.state() == LookupIterator::ACCESSOR)) { | 90 (it.state() == LookupIterator::ACCESSOR)) { |
92 // ECMA-262 section 15.1.11 GlobalDeclarationInstantiation 5.d: | 91 // ECMA-262 section 15.1.11 GlobalDeclarationInstantiation 5.d: |
93 // If hasRestrictedGlobal is true, throw a SyntaxError exception. | 92 // If hasRestrictedGlobal is true, throw a SyntaxError exception. |
94 // ECMA-262 section 18.2.1.3 EvalDeclarationInstantiation 8.a.iv.1.b: | 93 // ECMA-262 section 18.2.1.3 EvalDeclarationInstantiation 8.a.iv.1.b: |
95 // If fnDefinable is false, throw a TypeError exception. | 94 // If fnDefinable is false, throw a TypeError exception. |
96 return ThrowRedeclarationError(isolate, name, redeclaration_type); | 95 return ThrowRedeclarationError(isolate, name, redeclaration_type); |
97 } | 96 } |
98 // If the existing property is not configurable, keep its attributes. Do | 97 // If the existing property is not configurable, keep its attributes. Do |
99 attr = old_attributes; | 98 attr = old_attributes; |
100 } | 99 } |
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) { | 978 RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) { |
980 HandleScope scope(isolate); | 979 HandleScope scope(isolate); |
981 DCHECK_EQ(2, args.length()); | 980 DCHECK_EQ(2, args.length()); |
982 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 981 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
983 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 982 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
984 RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, STRICT)); | 983 RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, STRICT)); |
985 } | 984 } |
986 | 985 |
987 } // namespace internal | 986 } // namespace internal |
988 } // namespace v8 | 987 } // namespace v8 |
OLD | NEW |