UNPKG

@awayfl/avm2

Version:

Virtual machine for executing AS3 code

46 lines (45 loc) 1.93 kB
import { __extends } from "tslib"; import { ASNumber } from './ASNumber'; import { addPrototypeFunctionAlias } from './addPrototypeFunctionAlias'; import { defineNonEnumerableProperty } from '@awayfl/swf-loader'; import { Errors } from '../errors'; var ASInt = /** @class */ (function (_super) { __extends(ASInt, _super); function ASInt() { return _super !== null && _super.apply(this, arguments) || this; } ASInt.classInitializer = function () { var proto = this.dPrototype; var asProto = ASInt.prototype; addPrototypeFunctionAlias(proto, '$BgtoString', asProto.toString); addPrototypeFunctionAlias(proto, '$BgtoLocaleString', asProto.toString); addPrototypeFunctionAlias(proto, '$BgvalueOf', asProto.valueOf); defineNonEnumerableProperty(this, '$BgMAX_VALUE', 0x7fffffff); defineNonEnumerableProperty(this, '$BgMIN_VALUE', -0x80000000); }; ASInt.prototype.toString = function (radix) { if (arguments.length === 0) { radix = 10; } else { radix = radix | 0; if (radix < 2 || radix > 36) { this.sec.throwError('RangeError', Errors.InvalidRadixError, radix); } } if (this.axClass !== this.sec.AXInt && this.axClass !== this.sec.AXNumber) { this.sec.throwError('TypeError', Errors.InvokeOnIncompatibleObjectError, 'Number.prototype.toString'); } return this.value.toString(radix); }; ASInt.prototype.valueOf = function () { if (this.axClass !== this.sec.AXInt && this.axClass !== this.sec.AXNumber) { this.sec.throwError('TypeError', Errors.InvokeOnIncompatibleObjectError, 'Number.prototype.valueOf'); } return this.value; }; ASInt.staticNatives = [Math]; ASInt.instanceNatives = [ASNumber.prototype]; return ASInt; }(ASNumber)); export { ASInt };