//actual constructor work, but hidden to not be used accidently in a stupid way private SessionState(SessionStateGlobal sessionStateGlobal, SessionState parent) { SessionStateGlobal = sessionStateGlobal; var parentAliasScope = parent == null ? null : parent._aliasScope; var parentFunctionScope = parent == null ? null : parent._functionScope; var parentVariableScope = parent == null ? null : parent._variableScope; var parentDriveScope = parent == null ? null : parent._driveScope; var parentModuleScope = parent == null ? null : parent._moduleScope; var parentCmdletScope = parent == null ? null : parent._cmdletScope; _aliasScope = new SessionStateScope <AliasInfo>(this, parentAliasScope, SessionStateCategory.Alias); _functionScope = new SessionStateScope <FunctionInfo>(this, parentFunctionScope, SessionStateCategory.Function); _variableScope = new SessionStateScope <PSVariable>(this, parentVariableScope, SessionStateCategory.Variable); _driveScope = new SessionStateScope <PSDriveInfo>(this, parentDriveScope, SessionStateCategory.Drive); _moduleScope = new SessionStateScope <PSModuleInfo>(this, parentModuleScope, SessionStateCategory.Module); _cmdletScope = new SessionStateScope <CmdletInfo>(this, parentCmdletScope, SessionStateCategory.Cmdlet); IsScriptScope = false; Function = new FunctionIntrinsics(_functionScope); Alias = new AliasIntrinsics(_aliasScope); Drive = new DriveManagementIntrinsics(_driveScope); Path = new PathIntrinsics(this); PSVariable = new PSVariableIntrinsics(_variableScope); LoadedModules = new ModuleIntrinsics(_moduleScope); Cmdlet = new CmdletIntrinsics(_cmdletScope); }
//actual constructor work, but hidden to not be used accidently in a stupid way private SessionState(SessionStateGlobal sessionStateGlobal, SessionStateScope <FunctionInfo> functions, SessionStateScope <PSVariable> variables, SessionStateScope <PSDriveInfo> drives, SessionStateScope <AliasInfo> aliases) { SessionStateGlobal = sessionStateGlobal; _aliasScope = new SessionStateScope <AliasInfo>(aliases, SessionStateCategory.Alias); _functionScope = new SessionStateScope <FunctionInfo>(functions, SessionStateCategory.Function); _variableScope = new SessionStateScope <PSVariable>(variables, SessionStateCategory.Variable); _driveScope = new SessionStateScope <PSDriveInfo>(drives, SessionStateCategory.Drive); IsScriptScope = false; Function = new FunctionIntrinsics(this, _functionScope); Alias = new AliasIntrinsics(this, _aliasScope); Drive = new DriveManagementIntrinsics(this, _driveScope); Path = new PathIntrinsics(SessionStateGlobal); Provider = new CmdletProviderManagementIntrinsics(SessionStateGlobal); PSVariable = new PSVariableIntrinsics(this, _variableScope); }
internal Realm([NotNull] Agent agent, string name) { this.name = name; Agent = agent; //https://tc39.github.io/ecma262/#sec-createrealm //https://tc39.github.io/ecma262/#sec-createintrinsics ObjectPrototype = Agent.ObjectCreate(this, null); ThrowTypeError = Agent.CreateBuiltinFunction(this, arguments => throw arguments.Agent.CreateTypeError(), null); FunctionPrototype = Agent.CreateBuiltinFunction(this, arguments => ScriptValue.Undefined, ObjectPrototype); ThrowTypeError.SetPrototypeOf(FunctionPrototype); AddRestrictedFunctionProperties(FunctionPrototype); IteratorPrototype = IteratorIntrinsics.Initialise(agent, this, ObjectPrototype, FunctionPrototype); (Array, ArrayPrototype, ArrayIteratorPrototype, ArrayProtoEntries, ArrayProtoForEach, ArrayProtoKeys, ArrayProtoValues) = ArrayIntrinsics.Initialise(agent, this, ObjectPrototype, FunctionPrototype); (ArrayBuffer, ArrayBufferPrototype) = ArrayBufferIntrinsics.Initialise(agent, this); (AsyncFunction, AsyncFunctionPrototype) = AsyncFunctionIntrinsics.Initialise(agent, this); Atomics = AtomicsIntrinsics.Initialise(agent, this); (Boolean, BooleanPrototype) = BooleanIntrinsics.Initialise(agent, this, ObjectPrototype, FunctionPrototype); (DataView, DataViewPrototype) = DataViewIntrinsics.Initialise(agent, this); (Date, DatePrototype) = DateIntrinsics.Initialise(agent, this, ObjectPrototype, FunctionPrototype); DecodeURI = Intrinsics.CreateBuiltinFunction(this, DecodeURIImplementation, FunctionPrototype, 1, "decodeURI"); DecodeURIComponent = Intrinsics.CreateBuiltinFunction(this, DecodeURIComponentImplementation, FunctionPrototype, 1, "decodeURIComponent"); EncodeURI = Intrinsics.CreateBuiltinFunction(this, EncodeURIImplementation, FunctionPrototype, 1, "encodeURI"); EncodeURIComponent = Intrinsics.CreateBuiltinFunction(this, EncodeURIComponentImplementation, FunctionPrototype, 1, "encodeURIComponent"); (Error, ErrorPrototype) = ErrorIntrinsics.Initialise(agent, this, ObjectPrototype, FunctionPrototype); Eval = Intrinsics.CreateBuiltinFunction(this, EvalImplementation, FunctionPrototype, 1, "eval"); (EvalError, EvalErrorPrototype) = ErrorIntrinsics.InitialiseNativeError(agent, "EvalError", this, Error, ErrorPrototype); Function = FunctionIntrinsics.Initialise(this, FunctionPrototype); (Generator, GeneratorPrototype, GeneratorFunction) = GeneratorInstrinsics.Initialise(agent, this, FunctionPrototype); IsFinite = Intrinsics.CreateBuiltinFunction(this, IsFiniteImplementation, FunctionPrototype, 1, "isFinite"); IsNaN = Intrinsics.CreateBuiltinFunction(this, IsNaNImplementation, FunctionPrototype, 1, "isNaN"); (Json, JsonParse) = JsonIntrinsics.Initialise(agent, this); (Map, MapPrototype, MapIteratorPrototype) = MapIntrinsics.Initialise(agent, this); Math = MathsIntrinsics.Initialise(agent, this); (Number, NumberPrototype) = NumberIntrinsics.Initialise(agent, this, ObjectPrototype, FunctionPrototype); (ObjectConstructor, ObjProtoToString, ObjProtoValueOf) = ObjectIntrinsics.Initialise(this, ObjectPrototype, FunctionPrototype); ParseFloat = Intrinsics.CreateBuiltinFunction(this, ParseFloatImplementation, FunctionPrototype, 1, "parseFloat"); ParseInt = Intrinsics.CreateBuiltinFunction(this, ParseIntImplementation, FunctionPrototype, 2, "parseInt"); (Promise, PromisePrototype, PromiseProtoThen, PromiseAll, PromiseReject, PromiseResolve) = PromiseIntrinsics.Initialise(agent, this); Proxy = ProxyIntrinsics.Initialise(this); (RangeError, RangeErrorPrototype) = ErrorIntrinsics.InitialiseNativeError(agent, "RangeError", this, Error, ErrorPrototype); (ReferenceError, ReferenceErrorPrototype) = ErrorIntrinsics.InitialiseNativeError(agent, "ReferenceError", this, Error, ErrorPrototype); Reflect = ReflectIntrinsics.Initialise(agent, this); (RegExp, RegExpPrototype) = RegExpIntrinsics.Initialise(agent, this); (Set, SetPrototype, SetIteratorPrototype) = SetIntrinsics.Initialise(agent, this); (SharedArrayBuffer, SharedArrayBufferPrototype) = SharedArrayBufferIntrinsics.Initialise(agent, this); (StringConstructor, StringIteratorPrototype, StringPrototype) = StringIntrinsics.Initialise(agent, this, ObjectPrototype, FunctionPrototype); (Symbol, SymbolPrototype) = SymbolIntrinsics.Initialise(agent, this, ObjectPrototype, FunctionPrototype); (SyntaxError, SyntaxErrorPrototype) = ErrorIntrinsics.InitialiseNativeError(agent, "SyntaxError", this, Error, ErrorPrototype); (TypeError, TypeErrorPrototype) = ErrorIntrinsics.InitialiseNativeError(agent, "TypeError", this, Error, ErrorPrototype); (TypedArray, TypedArrayPrototype) = TypedArrayIntrinsics.Initialise(agent, this); (UriError, UriErrorPrototype) = ErrorIntrinsics.InitialiseNativeError(agent, "UriError", this, Error, ErrorPrototype); (WeakMap, WeakMapPrototype) = WeakMapIntrinsics.Initialise(agent, this); (WeakSet, WeakSetPrototype) = WeakSetIntrinsics.Initialise(agent, this); (Float32Array, Float32ArrayPrototype) = TypedArrayIntrinsics.InitialiseType <float>(agent, this); (Float64Array, Float64ArrayPrototype) = TypedArrayIntrinsics.InitialiseType <double>(agent, this); (Int8Array, Int8ArrayPrototype) = TypedArrayIntrinsics.InitialiseType <sbyte>(agent, this); (Int16Array, Int16ArrayPrototype) = TypedArrayIntrinsics.InitialiseType <short>(agent, this); (Int32Array, Int32ArrayPrototype) = TypedArrayIntrinsics.InitialiseType <int>(agent, this); (Uint8Array, Uint8ArrayPrototype) = TypedArrayIntrinsics.InitialiseType <byte>(agent, this); (Uint8ClampedArray, Uint8ClampedArrayPrototype) = TypedArrayIntrinsics.InitialiseType <byte>(agent, this, true); (Uint16Array, Uint16ArrayPrototype) = TypedArrayIntrinsics.InitialiseType <ushort>(agent, this); (Uint32Array, Uint32ArrayPrototype) = TypedArrayIntrinsics.InitialiseType <uint>(agent, this); }