1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
* License, v. 2.0. If a copy of the MPL was not distributed with this
4
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9
ECMA Section: 10.1.4 Scope Chain and Identifier Resolution
11
Every execution context has associated with it a scope chain. This is
12
logically a list of objects that are searched when binding an Identifier.
13
When control enters an execution context, the scope chain is created and
14
is populated with an initial set of objects, depending on the type of
15
code. When control leaves the execution context, the scope chain is
18
During execution, the scope chain of the execution context is affected
19
only by WithStatement. When execution enters a with block, the object
20
specified in the with statement is added to the front of the scope chain.
21
When execution leaves a with block, whether normally or via a break or
22
continue statement, the object is removed from the scope chain. The object
23
being removed will always be the first object in the scope chain.
25
During execution, the syntactic production PrimaryExpression : Identifier
26
is evaluated using the following algorithm:
28
1. Get the next object in the scope chain. If there isn't one, go to step 5.
29
2. Call the [[HasProperty]] method of Result(l), passing the Identifier as
31
3. If Result(2) is true, return a value of type Reference whose base object
32
is Result(l) and whose property name is the Identifier.
34
5. Return a value of type Reference whose base object is null and whose
35
property name is the Identifier.
36
The result of binding an identifier is always a value of type Reference with
37
its member name component equal to the identifier string.
38
Author: christine@netscape.com
39
Date: 12 november 1997
41
var SECTION = "10.1.4-6";
42
var VERSION = "ECMA_1";
45
writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution");
48
var testcase = new TestCase( "SECTION",
49
"with MyObject, eval should be [object Global].eval " );
51
var MYOBJECT = new MyObject();
53
testcase.description += ( INPUT +"" );
58
testcase.actual = eval( INPUT );
59
testcase.expect = INPUT;
65
this.eval = new Function( "x", "return(Math.pow(Number(x),2))" );