09150aabc12199b9096239af328644e4d61e7aba.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. System.register(["cc"], function (_export, _context) {
  2. "use strict";
  3. var _cclegacy, SafeVarNumber, SafeConstNumber, _crd;
  4. function get_new_safe_number(num) {
  5. return new SafeVarNumber(num);
  6. }
  7. function get_new_safe_const_number(num) {
  8. return new SafeConstNumber(num);
  9. }
  10. _export({
  11. get_new_safe_number: get_new_safe_number,
  12. get_new_safe_const_number: get_new_safe_const_number
  13. });
  14. return {
  15. setters: [function (_cc) {
  16. _cclegacy = _cc.cclegacy;
  17. }],
  18. execute: function () {
  19. _crd = true;
  20. _cclegacy._RF.push({}, "7e0d8kg6FBL46wNVfNiK7eE", "SafeNumber", undefined);
  21. /**
  22. * 防内存调试变量数字类型
  23. */
  24. SafeVarNumber = class SafeVarNumber {
  25. constructor(num) {
  26. if (num === void 0) {
  27. num = 0;
  28. }
  29. this.cache = 0;
  30. this.scale = 2;
  31. this.map = {};
  32. this.idx = 0;
  33. this.value = num;
  34. }
  35. /**数值 */
  36. get value() {
  37. if (Math.abs(this.map[this.idx] * this.scale - this.cache) > 0.000001) {
  38. this.map[this.idx] = this.cache / this.scale;
  39. }
  40. return this.map[this.idx];
  41. }
  42. set value(num) {
  43. delete this.map[this.idx];
  44. this.idx = Math.floor(Math.random() * 256);
  45. this.map[this.idx] = num;
  46. this.scale = Math.floor(Math.random() * 2) + 2;
  47. this.cache = num * this.scale;
  48. }
  49. valueOf() {
  50. return this.value;
  51. }
  52. toString() {
  53. return this.value.toString();
  54. }
  55. clone() {
  56. return new SafeVarNumber(this.value);
  57. }
  58. };
  59. /**
  60. * 防内存调试常量数字类型
  61. */
  62. SafeConstNumber = class SafeConstNumber {
  63. constructor(num) {
  64. if (num === void 0) {
  65. num = 0;
  66. }
  67. this.cache = 0;
  68. this.scale = 2;
  69. this.map = {};
  70. this.idx = 0;
  71. this.idx = Math.floor(Math.random() * 256);
  72. this.map[this.idx] = num;
  73. this.scale = Math.floor(Math.random() * 2) + 2;
  74. this.cache = num * this.scale;
  75. }
  76. /**数值 */
  77. get value() {
  78. var num = this.map[this.idx];
  79. if (Math.abs(num * this.scale - this.cache) > 0.000001) {
  80. num = this.cache / this.scale;
  81. }
  82. delete this.map[this.idx];
  83. this.idx = Math.floor(Math.random() * 256);
  84. this.map[this.idx] = num;
  85. return this.map[this.idx];
  86. }
  87. valueOf() {
  88. return this.value;
  89. }
  90. toString() {
  91. return this.value.toString();
  92. }
  93. clone() {
  94. return new SafeConstNumber(this.value);
  95. }
  96. };
  97. _cclegacy._RF.pop();
  98. _crd = false;
  99. }
  100. };
  101. });
  102. //# sourceMappingURL=09150aabc12199b9096239af328644e4d61e7aba.js.map