-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObjectInstancePrototype.cs
40 lines (33 loc) · 1002 Bytes
/
ObjectInstancePrototype.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using Jint;
using Jint.Native;
using Jint.Native.Object;
using Jint.Native.Symbol;
using Jint.Runtime.Descriptors;
namespace JintTest
{
internal sealed class ObjectInstancePrototype : ObjectInstance
{
private readonly AbstractObjectConstructor _constructor;
private ObjectInstance _prototype;
public AbstractObjectConstructor Constructor => _constructor;
public ObjectInstancePrototype(Engine engine, AbstractObjectConstructor constructor, ObjectInstance prototype) : base(engine)
{
_constructor = constructor;
_prototype = prototype;
}
protected override void Initialize()
{
this.FastSetProperty(GlobalSymbolRegistry.ToStringTag, _constructor.Name, PropertyFlag.Configurable);
_constructor.EnsureInitialized();
}
protected override ObjectInstance GetPrototypeOf()
=> _prototype;
public override bool SetPrototypeOf(JsValue value)
{
if (!base.SetPrototypeOf(value))
return false;
_prototype = base.GetPrototypeOf();
return true;
}
}
}