123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- System.register(["cc"], function (_export, _context) {
- "use strict";
- var _cclegacy, SafeVarNumber, SafeConstNumber, _crd;
- function get_new_safe_number(num) {
- return new SafeVarNumber(num);
- }
- function get_new_safe_const_number(num) {
- return new SafeConstNumber(num);
- }
- _export({
- get_new_safe_number: get_new_safe_number,
- get_new_safe_const_number: get_new_safe_const_number
- });
- return {
- setters: [function (_cc) {
- _cclegacy = _cc.cclegacy;
- }],
- execute: function () {
- _crd = true;
- _cclegacy._RF.push({}, "7e0d8kg6FBL46wNVfNiK7eE", "SafeNumber", undefined);
- /**
- * 防内存调试变量数字类型
- */
- SafeVarNumber = class SafeVarNumber {
- constructor(num) {
- if (num === void 0) {
- num = 0;
- }
- this.cache = 0;
- this.scale = 2;
- this.map = {};
- this.idx = 0;
- this.value = num;
- }
- /**数值 */
- get value() {
- if (Math.abs(this.map[this.idx] * this.scale - this.cache) > 0.000001) {
- this.map[this.idx] = this.cache / this.scale;
- }
- return this.map[this.idx];
- }
- set value(num) {
- delete this.map[this.idx];
- this.idx = Math.floor(Math.random() * 256);
- this.map[this.idx] = num;
- this.scale = Math.floor(Math.random() * 2) + 2;
- this.cache = num * this.scale;
- }
- valueOf() {
- return this.value;
- }
- toString() {
- return this.value.toString();
- }
- clone() {
- return new SafeVarNumber(this.value);
- }
- };
- /**
- * 防内存调试常量数字类型
- */
- SafeConstNumber = class SafeConstNumber {
- constructor(num) {
- if (num === void 0) {
- num = 0;
- }
- this.cache = 0;
- this.scale = 2;
- this.map = {};
- this.idx = 0;
- this.idx = Math.floor(Math.random() * 256);
- this.map[this.idx] = num;
- this.scale = Math.floor(Math.random() * 2) + 2;
- this.cache = num * this.scale;
- }
- /**数值 */
- get value() {
- var num = this.map[this.idx];
- if (Math.abs(num * this.scale - this.cache) > 0.000001) {
- num = this.cache / this.scale;
- }
- delete this.map[this.idx];
- this.idx = Math.floor(Math.random() * 256);
- this.map[this.idx] = num;
- return this.map[this.idx];
- }
- valueOf() {
- return this.value;
- }
- toString() {
- return this.value.toString();
- }
- clone() {
- return new SafeConstNumber(this.value);
- }
- };
- _cclegacy._RF.pop();
- _crd = false;
- }
- };
- });
- //# sourceMappingURL=09150aabc12199b9096239af328644e4d61e7aba.js.map
|