10.2.2.1 GetIdentifierReference

2010-05-06

Reference|undefined GetIdentifierReference(lex:LexicalEnvironment|Null, name:String, strict:Boolean)

Get a new Reference which contains the Environment Record that contains the IdentifierName name you're looking for. Starts searching in the given Lexical Environment lex and will traverse the scope chain up to global scope.

Code: (Meta Ecma)
function GetIdentifierReference(lex, name, strict){
if (lex === null) return new Reference(name, null, strict);
var envRec = lex.EnvironmentRecord;
var exists = envRec.HasBinding(N);
if (exists) return new Reference(name, envRec, strict);
var outer = lex.outerEnvironmentRecord;
// recursive call
return GetIdentifierReference(outer, name, strict);
}