| 4477 | |
| 4478 | |
| 4479 | function tameMathObject(mathTaming= 'safe') { |
| 4480 | if( mathTaming!== 'safe'&& mathTaming!== 'unsafe') { |
| 4481 | throw TypeError( `unrecognized mathTaming ${mathTaming}`); |
| 4482 | } |
| 4483 | const originalMath= Math; |
| 4484 | const initialMath= originalMath; // to follow the naming pattern |
| 4485 | |
| 4486 | const { random: _, ...otherDescriptors}= |
| 4487 | getOwnPropertyDescriptors(originalMath); |
| 4488 | |
| 4489 | // Use concise methods to obtain named functions without constructors. |
| 4490 | const tamedMethods= { |
| 4491 | /** |
| 4492 | * `%SharedMath%.random()` throws a TypeError starting with "secure mode". |
| 4493 | * See https://github.com/endojs/endo/issues/910#issuecomment-1581855420 |
| 4494 | */ |
| 4495 | random() { |
| 4496 | throw TypeError('secure mode %SharedMath%.random() throws'); |
| 4497 | }}; |
| 4498 | |
| 4499 | |
| 4500 | const sharedMath= create(objectPrototype, { |
| 4501 | ...otherDescriptors, |
| 4502 | random: { |
| 4503 | value: tamedMethods.random, |
| 4504 | writable: true, |
| 4505 | enumerable: false, |
| 4506 | configurable: true}}); |
| 4507 | |
| 4508 | |
| 4509 | |
| 4510 | return { |
| 4511 | '%InitialMath%': initialMath, |
| 4512 | '%SharedMath%': sharedMath}; |
| 4513 | |
| 4514 | }$h_once.default( tameMathObject); |
| 4515 | })() |
| 4516 | , |
| 4517 | // === functors[16] === |