OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 26 matching lines...) Expand all Loading... | |
37 | 37 |
38 enum ContextLookupFlags { | 38 enum ContextLookupFlags { |
39 FOLLOW_CONTEXT_CHAIN = 1, | 39 FOLLOW_CONTEXT_CHAIN = 1, |
40 FOLLOW_PROTOTYPE_CHAIN = 2, | 40 FOLLOW_PROTOTYPE_CHAIN = 2, |
41 | 41 |
42 DONT_FOLLOW_CHAINS = 0, | 42 DONT_FOLLOW_CHAINS = 0, |
43 FOLLOW_CHAINS = FOLLOW_CONTEXT_CHAIN | FOLLOW_PROTOTYPE_CHAIN | 43 FOLLOW_CHAINS = FOLLOW_CONTEXT_CHAIN | FOLLOW_PROTOTYPE_CHAIN |
44 }; | 44 }; |
45 | 45 |
46 | 46 |
47 // ES5 10.2 defines lexical environments with mutable and immutable bindings. | |
48 // Immutable bindings have two states, initialized and uninitialized, and | |
49 // their state is changed by the InitializeImmutableBinding method. | |
50 // | |
51 // The harmony proposal for block scoped bindings also introduces the | |
52 // uninitialized state for mutable bindings. A 'let' declared variable | |
53 // is a mutable binding that is created uninitalized upon activation of its | |
54 // lexical environment and it is initialized when evaluating its declaration | |
55 // statement. Var declared variables are mutable bindings that are | |
56 // immediately initialized upon creation. The BindingFlags enum represents | |
57 // information if a binding has definitely been initialized. 'const' declared | |
58 // variables are created as uninitialized immutable bindings. | |
59 | |
60 // In harmony mode accessing an uninitialized binding produces a reference | |
61 // error. | |
62 enum BindingFlags { | |
63 MUTABLE_IS_INITIALIZED, | |
64 MUTABLE_CHECK_INITIALIZED, | |
65 IMMUTABLE_IS_INITIALIZED, | |
66 IMMUTABLE_CHECK_INITIALIZED | |
67 }; | |
68 | |
69 | |
47 // Heap-allocated activation contexts. | 70 // Heap-allocated activation contexts. |
48 // | 71 // |
49 // Contexts are implemented as FixedArray objects; the Context | 72 // Contexts are implemented as FixedArray objects; the Context |
50 // class is a convenience interface casted on a FixedArray object. | 73 // class is a convenience interface casted on a FixedArray object. |
51 // | 74 // |
52 // Note: Context must have no virtual functions and Context objects | 75 // Note: Context must have no virtual functions and Context objects |
53 // must always be allocated via Heap::AllocateContext() or | 76 // must always be allocated via Heap::AllocateContext() or |
54 // Factory::NewContext. | 77 // Factory::NewContext. |
55 | 78 |
56 #define GLOBAL_CONTEXT_FIELDS(V) \ | 79 #define GLOBAL_CONTEXT_FIELDS(V) \ |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 // | 368 // |
346 // 3) index_ < 0 && result->IsJSObject(): | 369 // 3) index_ < 0 && result->IsJSObject(): |
347 // the result is the JSObject extension context or the global object, | 370 // the result is the JSObject extension context or the global object, |
348 // and the name is the property name, and the property exists. | 371 // and the name is the property name, and the property exists. |
349 // attributes != ABSENT. | 372 // attributes != ABSENT. |
350 // | 373 // |
351 // 4) index_ < 0 && result.is_null(): | 374 // 4) index_ < 0 && result.is_null(): |
352 // there was no context found with the corresponding property. | 375 // there was no context found with the corresponding property. |
353 // attributes == ABSENT. | 376 // attributes == ABSENT. |
354 Handle<Object> Lookup(Handle<String> name, ContextLookupFlags flags, | 377 Handle<Object> Lookup(Handle<String> name, ContextLookupFlags flags, |
355 int* index_, PropertyAttributes* attributes); | 378 int* index_, PropertyAttributes* attributes, |
379 BindingFlags* binding_flags); | |
fschneider
2011/08/23 08:36:12
Reformat to make all parameters on a separate line
Steven
2011/08/23 12:35:44
Done.
| |
356 | 380 |
357 // Determine if a local variable with the given name exists in a | 381 // Determine if a local variable with the given name exists in a |
358 // context. Do not consider context extension objects. This is | 382 // context. Do not consider context extension objects. This is |
359 // used for compiling code using eval. If the context surrounding | 383 // used for compiling code using eval. If the context surrounding |
360 // the eval call does not have a local variable with this name and | 384 // the eval call does not have a local variable with this name and |
361 // does not contain a with statement the property is global unless | 385 // does not contain a with statement the property is global unless |
362 // it is shadowed by a property in an extension object introduced by | 386 // it is shadowed by a property in an extension object introduced by |
363 // eval. | 387 // eval. |
364 bool GlobalIfNotShadowedByEval(Handle<String> name); | 388 bool GlobalIfNotShadowedByEval(Handle<String> name); |
365 | 389 |
(...skipping 25 matching lines...) Expand all Loading... | |
391 #ifdef DEBUG | 415 #ifdef DEBUG |
392 // Bootstrapping-aware type checks. | 416 // Bootstrapping-aware type checks. |
393 static bool IsBootstrappingOrContext(Object* object); | 417 static bool IsBootstrappingOrContext(Object* object); |
394 static bool IsBootstrappingOrGlobalObject(Object* object); | 418 static bool IsBootstrappingOrGlobalObject(Object* object); |
395 #endif | 419 #endif |
396 }; | 420 }; |
397 | 421 |
398 } } // namespace v8::internal | 422 } } // namespace v8::internal |
399 | 423 |
400 #endif // V8_CONTEXTS_H_ | 424 #endif // V8_CONTEXTS_H_ |
OLD | NEW |