Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(794)

Side by Side Diff: src/contexts.cc

Issue 1510913005: [proxies] Fix "with" statements for proxies (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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/contexts.h" 5 #include "src/contexts.h"
6 6
7 #include "src/ast/scopeinfo.h" 7 #include "src/ast/scopeinfo.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 void Context::set_global_proxy(JSObject* object) { 140 void Context::set_global_proxy(JSObject* object) {
141 native_context()->set_global_proxy_object(object); 141 native_context()->set_global_proxy_object(object);
142 } 142 }
143 143
144 144
145 /** 145 /**
146 * Lookups a property in an object environment, taking the unscopables into 146 * Lookups a property in an object environment, taking the unscopables into
147 * account. This is used For HasBinding spec algorithms for ObjectEnvironment. 147 * account. This is used For HasBinding spec algorithms for ObjectEnvironment.
148 */ 148 */
149 static Maybe<PropertyAttributes> UnscopableLookup(LookupIterator* it) { 149 static Maybe<bool> UnscopableLookup(LookupIterator* it) {
150 Isolate* isolate = it->isolate(); 150 Isolate* isolate = it->isolate();
151 151
152 Maybe<PropertyAttributes> attrs = JSReceiver::GetPropertyAttributes(it); 152 Maybe<bool> found = JSReceiver::HasProperty(it);
153 DCHECK(attrs.IsJust() || isolate->has_pending_exception()); 153 if (!found.IsJust() || !found.FromJust()) return found;
154 if (!attrs.IsJust() || attrs.FromJust() == ABSENT) return attrs;
155 154
156 Handle<Symbol> unscopables_symbol = isolate->factory()->unscopables_symbol();
157 Handle<Object> receiver = it->GetReceiver();
158 Handle<Object> unscopables; 155 Handle<Object> unscopables;
159 MaybeHandle<Object> maybe_unscopables = 156 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
160 Object::GetProperty(receiver, unscopables_symbol); 157 isolate, unscopables,
161 if (!maybe_unscopables.ToHandle(&unscopables)) { 158 Object::GetProperty(it->GetReceiver(),
162 return Nothing<PropertyAttributes>(); 159 isolate->factory()->unscopables_symbol()),
163 } 160 Nothing<bool>());
164 if (!unscopables->IsJSReceiver()) return attrs; 161 if (!unscopables->IsJSReceiver()) return Just(true);
165 Handle<Object> blacklist; 162 Handle<Object> blacklist;
166 MaybeHandle<Object> maybe_blacklist = 163 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, blacklist,
167 Object::GetProperty(unscopables, it->name()); 164 Object::GetProperty(unscopables, it->name()),
168 if (!maybe_blacklist.ToHandle(&blacklist)) { 165 Nothing<bool>());
169 DCHECK(isolate->has_pending_exception()); 166 return Just(!blacklist->BooleanValue());
170 return Nothing<PropertyAttributes>();
171 }
172 return blacklist->BooleanValue() ? Just(ABSENT) : attrs;
173 } 167 }
174 168
175 static void GetAttributesAndBindingFlags(VariableMode mode, 169 static void GetAttributesAndBindingFlags(VariableMode mode,
176 InitializationFlag init_flag, 170 InitializationFlag init_flag,
177 PropertyAttributes* attributes, 171 PropertyAttributes* attributes,
178 BindingFlags* binding_flags) { 172 BindingFlags* binding_flags) {
179 switch (mode) { 173 switch (mode) {
180 case VAR: 174 case VAR:
181 *attributes = NONE; 175 *attributes = NONE;
182 *binding_flags = MUTABLE_IS_INITIALIZED; 176 *binding_flags = MUTABLE_IS_INITIALIZED;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 Maybe<PropertyAttributes> maybe = Nothing<PropertyAttributes>(); 276 Maybe<PropertyAttributes> maybe = Nothing<PropertyAttributes>();
283 if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 || 277 if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 ||
284 object->IsJSContextExtensionObject()) { 278 object->IsJSContextExtensionObject()) {
285 maybe = JSReceiver::GetOwnPropertyAttributes(object, name); 279 maybe = JSReceiver::GetOwnPropertyAttributes(object, name);
286 } else if (context->IsWithContext()) { 280 } else if (context->IsWithContext()) {
287 // A with context will never bind "this". 281 // A with context will never bind "this".
288 if (name->Equals(*isolate->factory()->this_string())) { 282 if (name->Equals(*isolate->factory()->this_string())) {
289 maybe = Just(ABSENT); 283 maybe = Just(ABSENT);
290 } else { 284 } else {
291 LookupIterator it(object, name); 285 LookupIterator it(object, name);
292 maybe = UnscopableLookup(&it); 286 Maybe<bool> found = UnscopableLookup(&it);
287 if (found.IsNothing()) {
288 maybe = Nothing<PropertyAttributes>();
289 } else {
290 // Luckily, consumers of |maybe| only care whether the property
291 // was absent or not, so we can return a dummy |NONE| value
292 // for its attributes when it was present.
293 maybe = Just(found.FromJust() ? NONE : ABSENT);
294 }
293 } 295 }
294 } else { 296 } else {
295 maybe = JSReceiver::GetPropertyAttributes(object, name); 297 maybe = JSReceiver::GetPropertyAttributes(object, name);
296 } 298 }
297 299
298 if (!maybe.IsJust()) return Handle<Object>(); 300 if (!maybe.IsJust()) return Handle<Object>();
299 DCHECK(!isolate->has_pending_exception()); 301 DCHECK(!isolate->has_pending_exception());
300 *attributes = maybe.FromJust(); 302 *attributes = maybe.FromJust();
301 303
302 if (maybe.FromJust() != ABSENT) { 304 if (maybe.FromJust() != ABSENT) {
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 581
580 int previous_value = errors_thrown()->value(); 582 int previous_value = errors_thrown()->value();
581 set_errors_thrown(Smi::FromInt(previous_value + 1)); 583 set_errors_thrown(Smi::FromInt(previous_value + 1));
582 } 584 }
583 585
584 586
585 int Context::GetErrorsThrown() { return errors_thrown()->value(); } 587 int Context::GetErrorsThrown() { return errors_thrown()->value(); }
586 588
587 } // namespace internal 589 } // namespace internal
588 } // namespace v8 590 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698