public static LexicalEnvironment NewDeclarativeEnvironment([NotNull] Agent agent, [NotNull] LexicalEnvironment environment) { //https://tc39.github.io/ecma262/#sec-newdeclarativeenvironment return(new LexicalEnvironment(new DeclarativeEnvironment(agent), environment)); }
public static LexicalEnvironment NewObjectEnvironment([NotNull] ScriptObject obj, [NotNull] LexicalEnvironment environment, bool withEnvironment) { //https://tc39.github.io/ecma262/#sec-newobjectenvironment var environmentRecord = new ObjectEnvironment(obj, withEnvironment); return(new LexicalEnvironment(environmentRecord, environment)); }
private LexicalEnvironment([NotNull] BaseEnvironment environment, LexicalEnvironment outerEnvironment) { Environment = environment; OuterEnvironment = outerEnvironment; }
internal ScriptFunctionObject AsyncFunctionCreate(FunctionKind kind, [NotNull] IReadOnlyList <ExpressionNode> parameters, [NotNull] BaseNode body, [NotNull] LexicalEnvironment scope, bool strict) { //https://tc39.github.io/ecma262/#sec-async-functions-abstract-operations-async-function-create var function = FunctionAllocate(Realm.AsyncFunctionPrototype, strict, FunctionKind.Async); return(FunctionInitialise(function, kind, parameters, body, scope)); }
internal ScriptFunctionObject GeneratorFunctionCreate(FunctionKind kind, [NotNull] IReadOnlyList <ExpressionNode> parameters, [NotNull] BaseNode body, [NotNull] LexicalEnvironment scope, bool strict) { //https://tc39.github.io/ecma262/#sec-generatorfunctioncreate var function = FunctionAllocate(Realm.Generator, strict, FunctionKind.Generator); return(FunctionInitialise(function, kind, parameters, body, scope)); }
internal ScriptFunctionObject FunctionCreate(FunctionKind kind, [NotNull] IReadOnlyList <ExpressionNode> parameters, [NotNull] BaseNode body, [NotNull] LexicalEnvironment scope, bool strict, ScriptObject prototype = null) { if (prototype == null) { prototype = RunningExecutionContext.Realm.FunctionPrototype; } var function = FunctionAllocate(prototype, strict, kind == FunctionKind.Normal ? FunctionKind.Normal : FunctionKind.NonConstructor); return(FunctionInitialise(function, kind, parameters, body, scope)); }
internal ScriptFunctionObject FunctionInitialise([NotNull] ScriptFunctionObject function, FunctionKind kind, [NotNull] IReadOnlyList <ExpressionNode> parameters, [NotNull] BaseNode body, [NotNull] LexicalEnvironment scope) { //https://tc39.github.io/ecma262/#sec-functioninitialize Debug.Assert(function.IsExtensible && function.GetOwnProperty("length") == null); var length = ExpectedArgumentCount(parameters); DefinePropertyOrThrow(function, "length", new PropertyDescriptor(length, false, false, true)); var strict = function.Strict; function.Environment = scope; function.FormalParameters = parameters; function.ECMAScriptCode = new FunctionNode(body); function.ScriptOrModule = GetActiveScriptOrModule(); if (kind == FunctionKind.Arrow) { function.ThisMode = ThisMode.Lexical; } else if (strict) { function.ThisMode = ThisMode.Strict; } else { function.ThisMode = ThisMode.Global; } return(function); }