ObjectConstructor.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. using System.Collections.Generic;
  2. using Jint.Collections;
  3. using Jint.Native.Function;
  4. using Jint.Native.Iterator;
  5. using Jint.Runtime;
  6. using Jint.Runtime.Descriptors;
  7. using Jint.Runtime.Interop;
  8. namespace Jint.Native.Object
  9. {
  10. public sealed class ObjectConstructor : FunctionInstance, IConstructor
  11. {
  12. private static readonly JsString _name = new JsString("Object");
  13. internal ObjectConstructor(
  14. Engine engine,
  15. Realm realm)
  16. : base(engine, realm, _name)
  17. {
  18. PrototypeObject = new ObjectPrototype(engine, realm, this);
  19. _length = PropertyDescriptor.AllForbiddenDescriptor.NumberOne;
  20. _prototypeDescriptor = new PropertyDescriptor(PrototypeObject, PropertyFlag.AllForbidden);
  21. }
  22. public ObjectPrototype PrototypeObject { get; }
  23. protected override void Initialize()
  24. {
  25. _prototype = _realm.Intrinsics.Function.PrototypeObject;
  26. const PropertyFlag propertyFlags = PropertyFlag.Configurable | PropertyFlag.Writable;
  27. const PropertyFlag lengthFlags = PropertyFlag.Configurable;
  28. var properties = new PropertyDictionary(15, checkExistingKeys: false)
  29. {
  30. ["assign"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "assign", Assign, 2, lengthFlags), propertyFlags),
  31. ["entries"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "entries", Entries, 1, lengthFlags), propertyFlags),
  32. ["fromEntries"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "fromEntries", FromEntries, 1, lengthFlags), propertyFlags),
  33. ["getPrototypeOf"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "getPrototypeOf", GetPrototypeOf, 1), propertyFlags),
  34. ["getOwnPropertyDescriptor"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "getOwnPropertyDescriptor", GetOwnPropertyDescriptor, 2, lengthFlags), propertyFlags),
  35. ["getOwnPropertyDescriptors"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "getOwnPropertyDescriptors", GetOwnPropertyDescriptors, 1, lengthFlags), propertyFlags),
  36. ["getOwnPropertyNames"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "getOwnPropertyNames", GetOwnPropertyNames, 1), propertyFlags),
  37. ["getOwnPropertySymbols"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "getOwnPropertySymbols", GetOwnPropertySymbols, 1, lengthFlags), propertyFlags),
  38. ["create"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "create", Create, 2), propertyFlags),
  39. ["defineProperty"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "defineProperty", DefineProperty, 3), propertyFlags),
  40. ["defineProperties"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "defineProperties", DefineProperties, 2), propertyFlags),
  41. ["is"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "is", Is, 2, lengthFlags), propertyFlags),
  42. ["seal"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "seal", Seal, 1, lengthFlags), propertyFlags),
  43. ["freeze"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "freeze", Freeze, 1), propertyFlags),
  44. ["preventExtensions"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "preventExtensions", PreventExtensions, 1), propertyFlags),
  45. ["isSealed"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "isSealed", IsSealed, 1), propertyFlags),
  46. ["isFrozen"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "isFrozen", IsFrozen, 1), propertyFlags),
  47. ["isExtensible"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "isExtensible", IsExtensible, 1), propertyFlags),
  48. ["keys"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "keys", Keys, 1, lengthFlags), propertyFlags),
  49. ["values"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "values", Values, 1, lengthFlags), propertyFlags),
  50. ["setPrototypeOf"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "setPrototypeOf", SetPrototypeOf, 2, lengthFlags), propertyFlags),
  51. ["hasOwn"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "hasOwn", HasOwn, 2, lengthFlags), propertyFlags),
  52. };
  53. SetProperties(properties);
  54. }
  55. /// <summary>
  56. /// https://tc39.es/ecma262/#sec-object.assign
  57. /// </summary>
  58. private JsValue Assign(JsValue thisObject, JsValue[] arguments)
  59. {
  60. var to = TypeConverter.ToObject(_realm, arguments.At(0));
  61. if (arguments.Length < 2)
  62. {
  63. return to;
  64. }
  65. for (var i = 1; i < arguments.Length; i++)
  66. {
  67. var nextSource = arguments[i];
  68. if (nextSource.IsNullOrUndefined())
  69. {
  70. continue;
  71. }
  72. var from = TypeConverter.ToObject(_realm, nextSource);
  73. var keys = from.GetOwnPropertyKeys();
  74. foreach (var nextKey in keys)
  75. {
  76. var desc = from.GetOwnProperty(nextKey);
  77. if (desc != PropertyDescriptor.Undefined && desc.Enumerable)
  78. {
  79. var propValue = from.Get(nextKey);
  80. to.Set(nextKey, propValue, throwOnError: true);
  81. }
  82. }
  83. }
  84. return to;
  85. }
  86. /// <summary>
  87. /// https://tc39.es/ecma262/#sec-object.entries
  88. /// </summary>
  89. private JsValue Entries(JsValue thisObject, JsValue[] arguments)
  90. {
  91. var obj = TypeConverter.ToObject(_realm, arguments.At(0));
  92. var nameList = obj.EnumerableOwnPropertyNames(EnumerableOwnPropertyNamesKind.KeyValue);
  93. return nameList;
  94. }
  95. /// <summary>
  96. /// https://tc39.es/ecma262/#sec-object.fromentries
  97. /// </summary>
  98. private JsValue FromEntries(JsValue thisObject, JsValue[] arguments)
  99. {
  100. var iterable = arguments.At(0);
  101. TypeConverter.CheckObjectCoercible(_engine, iterable);
  102. var obj = _realm.Intrinsics.Object.Construct(0);
  103. var adder = CreateDataPropertyOnObject.Instance;
  104. var iterator = arguments.At(0).GetIterator(_realm);
  105. IteratorProtocol.AddEntriesFromIterable(obj, iterator, adder);
  106. return obj;
  107. }
  108. /// <summary>
  109. /// https://tc39.es/ecma262/#sec-object.is
  110. /// </summary>
  111. private static JsValue Is(JsValue thisObject, JsValue[] arguments)
  112. {
  113. return SameValue(arguments.At(0), arguments.At(1));
  114. }
  115. /// <summary>
  116. /// https://tc39.es/ecma262/#sec-object-value
  117. /// </summary>
  118. protected internal override JsValue Call(JsValue thisObject, JsValue[] arguments)
  119. {
  120. if (arguments.Length == 0)
  121. {
  122. return Construct(arguments);
  123. }
  124. if(arguments[0].IsNullOrUndefined())
  125. {
  126. return Construct(arguments);
  127. }
  128. return TypeConverter.ToObject(_realm, arguments[0]);
  129. }
  130. /// <summary>
  131. /// https://tc39.es/ecma262/#sec-object-value
  132. /// </summary>
  133. public ObjectInstance Construct(JsValue[] arguments)
  134. {
  135. return Construct(arguments, this);
  136. }
  137. ObjectInstance IConstructor.Construct(JsValue[] arguments, JsValue newTarget) => Construct(arguments, newTarget);
  138. private ObjectInstance Construct(JsValue[] arguments, JsValue newTarget)
  139. {
  140. if (!ReferenceEquals(this, newTarget) && !newTarget.IsUndefined())
  141. {
  142. return OrdinaryCreateFromConstructor(
  143. newTarget,
  144. static intrinsics => intrinsics.Object.PrototypeObject,
  145. static (Engine engine, Realm _, object _) => new ObjectInstance(engine));
  146. }
  147. if (arguments.Length > 0)
  148. {
  149. var value = arguments[0];
  150. if (value is ObjectInstance oi)
  151. {
  152. return oi;
  153. }
  154. var type = value.Type;
  155. if (type == Types.String || type == Types.Number || type == Types.Boolean)
  156. {
  157. return TypeConverter.ToObject(_realm, value);
  158. }
  159. }
  160. return new ObjectInstance(_engine);
  161. }
  162. internal ObjectInstance Construct(int propertyCount)
  163. {
  164. var obj = new ObjectInstance(_engine);
  165. obj.SetProperties(propertyCount > 0 ? new PropertyDictionary(propertyCount, checkExistingKeys: true) : null);
  166. return obj;
  167. }
  168. /// <summary>
  169. /// https://tc39.es/ecma262/#sec-object.getprototypeof
  170. /// </summary>
  171. public JsValue GetPrototypeOf(JsValue thisObject, JsValue[] arguments)
  172. {
  173. var obj = TypeConverter.ToObject(_realm, arguments.At(0));
  174. return obj.Prototype ?? Null;
  175. }
  176. /// <summary>
  177. /// https://tc39.es/ecma262/#sec-object.setprototypeof
  178. /// </summary>
  179. private JsValue SetPrototypeOf(JsValue thisObject, JsValue[] arguments)
  180. {
  181. var oArg = arguments.At(0);
  182. TypeConverter.CheckObjectCoercible(_engine, oArg);
  183. var prototype = arguments.At(1);
  184. if (!prototype.IsObject() && !prototype.IsNull())
  185. {
  186. ExceptionHelper.ThrowTypeError(_realm, $"Object prototype may only be an Object or null: {prototype}");
  187. }
  188. if (!(oArg is ObjectInstance o))
  189. {
  190. return oArg;
  191. }
  192. if (!o.SetPrototypeOf(prototype))
  193. {
  194. ExceptionHelper.ThrowTypeError(_realm);
  195. }
  196. return o;
  197. }
  198. /// <summary>
  199. /// https://tc39.es/ecma262/#sec-object.hasown
  200. /// </summary>
  201. private JsValue HasOwn(JsValue thisObject, JsValue[] arguments)
  202. {
  203. var o = TypeConverter.ToObject(_realm, arguments.At(0));
  204. var property = TypeConverter.ToPropertyKey(arguments.At(1));
  205. return o.HasOwnProperty(property) ? JsBoolean.True : JsBoolean.False;
  206. }
  207. /// <summary>
  208. /// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  209. /// </summary>
  210. internal JsValue GetOwnPropertyDescriptor(JsValue thisObject, JsValue[] arguments)
  211. {
  212. var o = TypeConverter.ToObject(_realm, arguments.At(0));
  213. var p = arguments.At(1);
  214. var name = TypeConverter.ToPropertyKey(p);
  215. var desc = o.GetOwnProperty(name);
  216. return PropertyDescriptor.FromPropertyDescriptor(Engine, desc);
  217. }
  218. /// <summary>
  219. /// https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
  220. /// </summary>
  221. private JsValue GetOwnPropertyDescriptors(JsValue thisObject, JsValue[] arguments)
  222. {
  223. var o = TypeConverter.ToObject(_realm, arguments.At(0));
  224. var ownKeys = o.GetOwnPropertyKeys();
  225. var descriptors = _realm.Intrinsics.Object.Construct(0);
  226. foreach (var key in ownKeys)
  227. {
  228. var desc = o.GetOwnProperty(key);
  229. var descriptor = PropertyDescriptor.FromPropertyDescriptor(Engine, desc);
  230. if (!ReferenceEquals(descriptor, Undefined))
  231. {
  232. descriptors.CreateDataProperty(key, descriptor);
  233. }
  234. }
  235. return descriptors;
  236. }
  237. /// <summary>
  238. /// https://tc39.es/ecma262/#sec-object.getownpropertynames
  239. /// </summary>
  240. private JsValue GetOwnPropertyNames(JsValue thisObject, JsValue[] arguments)
  241. {
  242. var o = TypeConverter.ToObject(_realm, arguments.At(0));
  243. var names = o.GetOwnPropertyKeys(Types.String);
  244. return _realm.Intrinsics.Array.ConstructFast(names);
  245. }
  246. /// <summary>
  247. /// https://tc39.es/ecma262/#sec-object.getownpropertysymbols
  248. /// </summary>
  249. private JsValue GetOwnPropertySymbols(JsValue thisObject, JsValue[] arguments)
  250. {
  251. var o = TypeConverter.ToObject(_realm, arguments.At(0));
  252. var keys = o.GetOwnPropertyKeys(Types.Symbol);
  253. return _realm.Intrinsics.Array.ConstructFast(keys);
  254. }
  255. /// <summary>
  256. /// https://tc39.es/ecma262/#sec-object.create
  257. /// </summary>
  258. private JsValue Create(JsValue thisObject, JsValue[] arguments)
  259. {
  260. var prototype = arguments.At(0);
  261. if (!prototype.IsObject() && !prototype.IsNull())
  262. {
  263. ExceptionHelper.ThrowTypeError(_realm, "Object prototype may only be an Object or null: " + prototype);
  264. }
  265. var obj = Engine.Realm.Intrinsics.Object.Construct(Arguments.Empty);
  266. obj._prototype = prototype.IsNull() ? null : prototype.AsObject();
  267. var properties = arguments.At(1);
  268. if (!properties.IsUndefined())
  269. {
  270. ObjectDefineProperties(obj, properties);
  271. }
  272. return obj;
  273. }
  274. /// <summary>
  275. /// https://tc39.es/ecma262/#sec-object.defineproperty
  276. /// </summary>
  277. private JsValue DefineProperty(JsValue thisObject, JsValue[] arguments)
  278. {
  279. var o = arguments.At(0) as ObjectInstance;
  280. if (o is null)
  281. {
  282. ExceptionHelper.ThrowTypeError(_realm, "Object.defineProperty called on non-object");
  283. }
  284. var p = arguments.At(1);
  285. var name = TypeConverter.ToPropertyKey(p);
  286. var attributes = arguments.At(2);
  287. var desc = PropertyDescriptor.ToPropertyDescriptor(_realm, attributes);
  288. o.DefinePropertyOrThrow(name, desc);
  289. return arguments.At(0);
  290. }
  291. /// <summary>
  292. /// https://tc39.es/ecma262/#sec-object.defineproperties
  293. /// </summary>
  294. private JsValue DefineProperties(JsValue thisObject, JsValue[] arguments)
  295. {
  296. var o = arguments.At(0) as ObjectInstance;
  297. if (o is null)
  298. {
  299. ExceptionHelper.ThrowTypeError(_realm, "Object.defineProperty called on non-object");
  300. }
  301. var properties = arguments.At(1);
  302. return ObjectDefineProperties(o, properties);
  303. }
  304. /// <summary>
  305. /// https://tc39.es/ecma262/#sec-objectdefineproperties
  306. /// </summary>
  307. private JsValue ObjectDefineProperties(ObjectInstance o, JsValue properties)
  308. {
  309. var props = TypeConverter.ToObject(_realm, properties);
  310. var keys = props.GetOwnPropertyKeys();
  311. var descriptors = new List<KeyValuePair<JsValue, PropertyDescriptor>>();
  312. for (var i = 0; i < keys.Count; i++)
  313. {
  314. var nextKey = keys[i];
  315. var propDesc = props.GetOwnProperty(nextKey);
  316. if (propDesc == PropertyDescriptor.Undefined || !propDesc.Enumerable)
  317. {
  318. continue;
  319. }
  320. var descObj = props.UnwrapJsValue(propDesc);
  321. var desc = PropertyDescriptor.ToPropertyDescriptor(_realm, descObj);
  322. descriptors.Add(new KeyValuePair<JsValue, PropertyDescriptor>(nextKey, desc));
  323. }
  324. foreach (var pair in descriptors)
  325. {
  326. o.DefinePropertyOrThrow(pair.Key, pair.Value);
  327. }
  328. return o;
  329. }
  330. /// <summary>
  331. /// https://tc39.es/ecma262/#sec-object.seal
  332. /// </summary>
  333. private JsValue Seal(JsValue thisObject, JsValue[] arguments)
  334. {
  335. if (arguments.At(0) is not ObjectInstance o)
  336. {
  337. return arguments.At(0);
  338. }
  339. var status = SetIntegrityLevel(o, IntegrityLevel.Sealed);
  340. if (!status)
  341. {
  342. ExceptionHelper.ThrowTypeError(_realm);
  343. }
  344. return o;
  345. }
  346. /// <summary>
  347. /// https://tc39.es/ecma262/#sec-object.freeze
  348. /// </summary>
  349. private JsValue Freeze(JsValue thisObject, JsValue[] arguments)
  350. {
  351. if (arguments.At(0) is not ObjectInstance o)
  352. {
  353. return arguments.At(0);
  354. }
  355. var status = SetIntegrityLevel(o, IntegrityLevel.Frozen);
  356. if (!status)
  357. {
  358. ExceptionHelper.ThrowTypeError(_realm);
  359. }
  360. return o;
  361. }
  362. /// <summary>
  363. /// https://tc39.es/ecma262/#sec-setintegritylevel
  364. /// </summary>
  365. private static bool SetIntegrityLevel(ObjectInstance o, IntegrityLevel level)
  366. {
  367. var status = o.PreventExtensions();
  368. if (!status)
  369. {
  370. return false;
  371. }
  372. var keys = o.GetOwnPropertyKeys();
  373. if (level == IntegrityLevel.Sealed)
  374. {
  375. for (var i = 0; i < keys.Count; i++)
  376. {
  377. var k = keys[i];
  378. o.DefinePropertyOrThrow(k, new PropertyDescriptor { Configurable = false });
  379. }
  380. }
  381. else
  382. {
  383. for (var i = 0; i < keys.Count; i++)
  384. {
  385. var k = keys[i];
  386. var currentDesc = o.GetOwnProperty(k);
  387. if (currentDesc != PropertyDescriptor.Undefined)
  388. {
  389. PropertyDescriptor desc;
  390. if (currentDesc.IsAccessorDescriptor())
  391. {
  392. desc = new PropertyDescriptor { Configurable = false };
  393. }
  394. else
  395. {
  396. desc = new PropertyDescriptor { Configurable = false, Writable = false };
  397. }
  398. o.DefinePropertyOrThrow(k, desc);
  399. }
  400. }
  401. }
  402. return true;
  403. }
  404. private enum IntegrityLevel
  405. {
  406. Sealed,
  407. Frozen
  408. }
  409. /// <summary>
  410. /// https://tc39.es/ecma262/#sec-object.preventextensions
  411. /// </summary>
  412. private JsValue PreventExtensions(JsValue thisObject, JsValue[] arguments)
  413. {
  414. if (!(arguments.At(0) is ObjectInstance o))
  415. {
  416. return arguments.At(0);
  417. }
  418. if (!o.PreventExtensions())
  419. {
  420. ExceptionHelper.ThrowTypeError(_realm);
  421. }
  422. return o;
  423. }
  424. /// <summary>
  425. /// https://tc39.es/ecma262/#sec-object.issealed
  426. /// </summary>
  427. private static JsValue IsSealed(JsValue thisObject, JsValue[] arguments)
  428. {
  429. if (arguments.At(0) is not ObjectInstance o)
  430. {
  431. return arguments.At(0);
  432. }
  433. return TestIntegrityLevel(o, IntegrityLevel.Sealed);
  434. }
  435. /// <summary>
  436. /// https://tc39.es/ecma262/#sec-object.isfrozen
  437. /// </summary>
  438. private static JsValue IsFrozen(JsValue thisObject, JsValue[] arguments)
  439. {
  440. if (arguments.At(0) is not ObjectInstance o)
  441. {
  442. return arguments.At(0);
  443. }
  444. return TestIntegrityLevel(o, IntegrityLevel.Frozen);
  445. }
  446. /// <summary>
  447. /// https://tc39.es/ecma262/#sec-testintegritylevel
  448. /// </summary>
  449. private static JsValue TestIntegrityLevel(ObjectInstance o, IntegrityLevel level)
  450. {
  451. if (o.Extensible)
  452. {
  453. return JsBoolean.False;
  454. }
  455. foreach (var k in o.GetOwnPropertyKeys())
  456. {
  457. var currentDesc = o.GetOwnProperty(k);
  458. if (currentDesc != PropertyDescriptor.Undefined)
  459. {
  460. if (currentDesc.Configurable)
  461. {
  462. return JsBoolean.False;
  463. }
  464. if (level == IntegrityLevel.Frozen && currentDesc.IsDataDescriptor())
  465. {
  466. if (currentDesc.Writable)
  467. {
  468. return JsBoolean.False;
  469. }
  470. }
  471. }
  472. }
  473. return JsBoolean.True;
  474. }
  475. /// <summary>
  476. /// https://tc39.es/ecma262/#sec-object.isextensible
  477. /// </summary>
  478. private static JsValue IsExtensible(JsValue thisObject, JsValue[] arguments)
  479. {
  480. if (arguments.At(0) is not ObjectInstance o)
  481. {
  482. return arguments.At(0);
  483. }
  484. return o.Extensible;
  485. }
  486. /// <summary>
  487. /// https://tc39.es/ecma262/#sec-object.keys
  488. /// </summary>
  489. private JsValue Keys(JsValue thisObject, JsValue[] arguments)
  490. {
  491. var o = TypeConverter.ToObject(_realm, arguments.At(0));
  492. return o.EnumerableOwnPropertyNames(EnumerableOwnPropertyNamesKind.Key);
  493. }
  494. /// <summary>
  495. /// https://tc39.es/ecma262/#sec-object.values
  496. /// </summary>
  497. private JsValue Values(JsValue thisObject, JsValue[] arguments)
  498. {
  499. var o = TypeConverter.ToObject(_realm, arguments.At(0));
  500. return o.EnumerableOwnPropertyNames(EnumerableOwnPropertyNamesKind.Value);
  501. }
  502. private sealed class CreateDataPropertyOnObject : ICallable
  503. {
  504. internal static readonly CreateDataPropertyOnObject Instance = new();
  505. private CreateDataPropertyOnObject()
  506. {
  507. }
  508. public JsValue Call(JsValue thisObject, JsValue[] arguments)
  509. {
  510. var o = (ObjectInstance) thisObject;
  511. var key = arguments.At(0);
  512. var value = arguments.At(1);
  513. var propertyKey = TypeConverter.ToPropertyKey(key);
  514. o.CreateDataPropertyOrThrow(propertyKey, value);
  515. return Undefined;
  516. }
  517. }
  518. }
  519. }