@awayfl/avm2
Version:
Virtual machine for executing AS3 code
46 lines (45 loc) • 1.93 kB
JavaScript
import { __extends } from "tslib";
import { ASNumber } from './ASNumber';
import { addPrototypeFunctionAlias } from './addPrototypeFunctionAlias';
import { defineNonEnumerableProperty } from '@awayfl/swf-loader';
import { Errors } from '../errors';
var ASUint = /** @class */ (function (_super) {
__extends(ASUint, _super);
function ASUint() {
return _super !== null && _super.apply(this, arguments) || this;
}
ASUint.classInitializer = function () {
var proto = this.dPrototype;
var asProto = ASUint.prototype;
addPrototypeFunctionAlias(proto, '$BgtoString', asProto.toString);
addPrototypeFunctionAlias(proto, '$BgtoLocaleString', asProto.toString);
addPrototypeFunctionAlias(proto, '$BgvalueOf', asProto.valueOf);
defineNonEnumerableProperty(this, '$BgMAX_VALUE', 0xffffffff);
defineNonEnumerableProperty(this, '$BgMIN_VALUE', 0);
};
ASUint.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.AXUint && this.axClass !== this.sec.AXNumber) {
this.sec.throwError('TypeError', Errors.InvokeOnIncompatibleObjectError, 'Number.prototype.toString');
}
return this.value.toString(radix);
};
ASUint.prototype.valueOf = function () {
if (this.axClass !== this.sec.AXUint && this.axClass !== this.sec.AXNumber) {
this.sec.throwError('TypeError', Errors.InvokeOnIncompatibleObjectError, 'Number.prototype.valueOf');
}
return this.value;
};
ASUint.staticNatives = [Math];
ASUint.instanceNatives = [ASNumber.prototype];
return ASUint;
}(ASNumber));
export { ASUint };