P. 1
JavaScript Language Specification(ECMA-262)

JavaScript Language Specification(ECMA-262)

|Views: 59|Likes:
Publicado porrayaspnet
http://rayaspnet.blogspot.com/

http://rayaspnet.blogspot.com/

More info:

Published by: rayaspnet on Jun 06, 2011
Direitos Autorais:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

04/06/2012

pdf

text

original

The Reference type is used to explain the behaviour of such operators as delete, typeof, and the
assignment operators. For example, the left-hand operand of an assignment is expected to produce a

34

© Ecma International 2009

reference. The behaviour of assignment could, instead, be explained entirely in terms of a case analysis on
the syntactic form of the left-hand operand of an assignment operator, but for one difficulty: function calls are
permitted to return references. This possibility is admitted purely for the sake of host objects. No built-in
ECMAScript function defined by this specification returns a reference and there is no provision for a user-
defined function to return a reference. (Another reason not to use a syntactic case analysis is that it would be
lengthy and awkward, affecting many parts of the specification.)

A Reference is a resolved name binding. A Reference consists of three components, the base value, the
referenced name and the Boolean valued strict reference flag. The base value is either undefined, an Object, a
Boolean, a String, a Number, or an environment record (10.2.1). A base value of undefined indicates that the
reference could not be resolved to a binding. The referenced name is a String.

The following abstract operations are used in this specification to access the components of references:

• GetBase(V). Returns the base value component of the reference V.
• GetReferencedName(V). Returns the referenced name component of the reference V.
• IsStrictReference(V). Returns the strict reference component of the reference V.
• HasPrimitiveBase(V). Returns true if the base value is a Boolean, String, or Number.
• IsPropertyReference(V). Returns true if either the base value is an object or HasPrimitiveBase(V) is true;
otherwise returns false.
• IsUnresolvableReference(V). Returns true if the base value is undefined and false otherwise.

The following abstract operations are used in this specification to operate on references:

8.7.1 GetValue (V)

1. If Type(V) is not Reference, return V.
2. Let base be the result of calling GetBase(V).
3. If IsUnresolvableReference(V), throw a ReferenceError exception.
4. If IsPropertyReference(V), then

a. If HasPrimitiveBase(V) is false, then let get be the [[Get]] internal method of base, otherwise let get
be the special [[Get]] internal method defined below.
b. Return the result of calling the get internal method using base as its this value, and passing
GetReferencedName(V) for the argument.
5. Else, base must be an environment record.
a. Return the result of calling the GetBindingValue (see 10.2.1) concrete method of base passing
GetReferencedName(V) and IsStrictReference(V) as arguments.
The following [[Get]] internal method is used by GetValue when V is a property reference with a primitive base
value. It is called using base as its this value and with property P as its argument. The following steps are
taken:

1. Let O be ToObject(base).
2. Let desc be the result of calling the [[GetProperty]] internal method of O with property name P.
3. If desc is undefined, return undefined.
4. If IsDataDescriptor(desc) is true, return desc.[[Value]].
5. Otherwise, IsAccessorDescriptor(desc) must be true so, let getter be desc.[[Get]].
6. If getter is undefined, return undefined.
7. Return the result calling the [[Call]] internal method of getter providing base as the this value and providing

no arguments.

NOTE

The object that may be created in step 1 is not accessible outside of the above method. An implementation
might choose to avoid the actual creation of the object. The only situation where such an actual property access that uses
this internal method can have visible effect is when it invokes an accessor function.

You're Reading a Free Preview

Descarregar
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->