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

Side by Side Diff: src/contexts.cc

Issue 958053003: Removed funky Maybe constructor and made fields private. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months 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 | « src/ast.h ('k') | src/hydrogen.cc » ('j') | 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/debug.h" 8 #include "src/debug.h"
9 #include "src/scopeinfo.h" 9 #include "src/scopeinfo.h"
10 10
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 116
117 /** 117 /**
118 * Lookups a property in an object environment, taking the unscopables into 118 * Lookups a property in an object environment, taking the unscopables into
119 * account. This is used For HasBinding spec algorithms for ObjectEnvironment. 119 * account. This is used For HasBinding spec algorithms for ObjectEnvironment.
120 */ 120 */
121 static Maybe<PropertyAttributes> UnscopableLookup(LookupIterator* it) { 121 static Maybe<PropertyAttributes> UnscopableLookup(LookupIterator* it) {
122 Isolate* isolate = it->isolate(); 122 Isolate* isolate = it->isolate();
123 123
124 Maybe<PropertyAttributes> attrs = JSReceiver::GetPropertyAttributes(it); 124 Maybe<PropertyAttributes> attrs = JSReceiver::GetPropertyAttributes(it);
125 DCHECK(attrs.has_value || isolate->has_pending_exception()); 125 DCHECK(attrs.IsJust() || isolate->has_pending_exception());
126 if (!attrs.has_value || attrs.value == ABSENT) return attrs; 126 if (!attrs.IsJust() || attrs.FromJust() == ABSENT) return attrs;
127 127
128 Handle<Symbol> unscopables_symbol = isolate->factory()->unscopables_symbol(); 128 Handle<Symbol> unscopables_symbol = isolate->factory()->unscopables_symbol();
129 Handle<Object> receiver = it->GetReceiver(); 129 Handle<Object> receiver = it->GetReceiver();
130 Handle<Object> unscopables; 130 Handle<Object> unscopables;
131 MaybeHandle<Object> maybe_unscopables = 131 MaybeHandle<Object> maybe_unscopables =
132 Object::GetProperty(receiver, unscopables_symbol); 132 Object::GetProperty(receiver, unscopables_symbol);
133 if (!maybe_unscopables.ToHandle(&unscopables)) { 133 if (!maybe_unscopables.ToHandle(&unscopables)) {
134 return Nothing<PropertyAttributes>(); 134 return Nothing<PropertyAttributes>();
135 } 135 }
136 if (!unscopables->IsSpecObject()) return attrs; 136 if (!unscopables->IsSpecObject()) return attrs;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 || 257 if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 ||
258 object->IsJSContextExtensionObject()) { 258 object->IsJSContextExtensionObject()) {
259 maybe = JSReceiver::GetOwnPropertyAttributes(object, name); 259 maybe = JSReceiver::GetOwnPropertyAttributes(object, name);
260 } else if (context->IsWithContext()) { 260 } else if (context->IsWithContext()) {
261 LookupIterator it(object, name); 261 LookupIterator it(object, name);
262 maybe = UnscopableLookup(&it); 262 maybe = UnscopableLookup(&it);
263 } else { 263 } else {
264 maybe = JSReceiver::GetPropertyAttributes(object, name); 264 maybe = JSReceiver::GetPropertyAttributes(object, name);
265 } 265 }
266 266
267 if (!maybe.has_value) return Handle<Object>(); 267 if (!maybe.IsJust()) return Handle<Object>();
268 DCHECK(!isolate->has_pending_exception()); 268 DCHECK(!isolate->has_pending_exception());
269 *attributes = maybe.value; 269 *attributes = maybe.FromJust();
270 270
271 if (maybe.value != ABSENT) { 271 if (maybe.FromJust() != ABSENT) {
272 if (FLAG_trace_contexts) { 272 if (FLAG_trace_contexts) {
273 PrintF("=> found property in context object %p\n", 273 PrintF("=> found property in context object %p\n",
274 reinterpret_cast<void*>(*object)); 274 reinterpret_cast<void*>(*object));
275 } 275 }
276 return object; 276 return object;
277 } 277 }
278 } 278 }
279 279
280 // 2. Check the context proper if it has slots. 280 // 2. Check the context proper if it has slots.
281 if (context->IsFunctionContext() || context->IsBlockContext() || 281 if (context->IsFunctionContext() || context->IsBlockContext() ||
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 bool Context::IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object) { 488 bool Context::IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object) {
489 // During bootstrapping we allow all objects to pass as global 489 // During bootstrapping we allow all objects to pass as global
490 // objects. This is necessary to fix circular dependencies. 490 // objects. This is necessary to fix circular dependencies.
491 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || 491 return isolate->heap()->gc_state() != Heap::NOT_IN_GC ||
492 isolate->bootstrapper()->IsActive() || 492 isolate->bootstrapper()->IsActive() ||
493 object->IsGlobalObject(); 493 object->IsGlobalObject();
494 } 494 }
495 #endif 495 #endif
496 496
497 } } // namespace v8::internal 497 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698