UNPKG

@awayfl/avm2

Version:

Virtual machine for executing AS3 code

601 lines (600 loc) 30.3 kB
import { AXApplicationDomain } from './AXApplicationDomain'; import { ClassAliases } from '../amf'; import { IS_AX_CLASS } from './AXClass'; import { XMLParser } from '../natives/xml'; import { Multiname } from '../abc/lazy/Multiname'; import { runtimeWriter } from './writers'; import { formatErrorMessage, Errors } from '../errors'; import { transformJSValueToAS } from '../nat/transformJSValueToAS'; import { tryLinkNativeClass } from '../nat/tryLinkNativeClass'; import { getNativeInitializer } from '../nat/getNativeInitializer'; import { installClassLoaders } from '../nat/installClassLoaders'; import { installNativeFunctions } from '../nat/installNativeFunctions'; import { release, isIndex, IndentingWriter, defineNonEnumerableProperty, defineReadOnlyProperty, flashlog } from '@awayfl/swf-loader'; import { assert } from '@awayjs/graphics'; import { checkValue } from './checkValue'; import { Scope } from './Scope'; import { axInterfaceInitializer } from './axInterfaceInitializer'; import { axIsInstanceOfInterface } from './axIsInstanceOfInterface'; import { axIsTypeInterface } from './axIsTypeInterface'; import { interpret } from '../int'; import { applyTraits } from './applyTraits'; import { axCoerce } from './axCoerce'; import { axIsInstanceOfObject } from './axIsInstanceOfObject'; import { axConstruct, axConstructFast } from './axConstruct'; import { axDefaultApply } from './axDefaultApply'; import { axDefaultInitializer } from './axDefaultInitializer'; import { axGetArgumentsCallee } from './axGetArgumentsCallee'; import { axCoerceBoolean } from './axCoerceBoolean'; import { axIsTypeBoolean } from './axIsTypeBoolean'; import { axConvertString } from './axConvertString'; import { axIsTypeString } from './axIsTypeString'; import { axCoerceString } from './axCoerceString'; import { axCoerceNumber } from './axCoerceNumber'; import { axIsTypeNumber } from './axIsTypeNumber'; import { axCoerceInt } from './axCoerceInt'; import { axFalse } from './axFalse'; import { axIsTypeInt } from './axIsTypeInt'; import { axCoerceUint } from './axCoerceUint'; import { axIsTypeUint } from './axIsTypeUint'; import { isPrimitiveJSValue } from './isPrimitiveJSValue'; import { axBoxIdentity } from './axBoxIdentity'; import { axIsTypeObject } from './axIsTypeObject'; import { axAsType } from './axAsType'; import { axBoxPrimitive } from './axBoxPrimitive'; import { axApplyObject } from './axApplyObject'; import { axConstructObject } from './axConstructObject'; import { axCoerceObject } from './axCoerceObject'; import { initializeAXBasePrototype, AXBasePrototype } from './initializeAXBasePrototype'; import { ByteArrayDataProvider } from '../natives/byteArray'; import { IS_EXTERNAL_CLASS } from '../ext/external'; import { nativeClasses } from '../nat/builtinNativeClasses'; /** * Provides security isolation between application domains. */ var AXSecurityDomain = /** @class */ (function () { // public flash:any; // public player:any; function AXSecurityDomain() { initializeAXBasePrototype(); this.system = new AXApplicationDomain(this, null); this.application = new AXApplicationDomain(this, this.system); this.classAliases = new ClassAliases(); this.nativeClasses = Object.create(null); this.vectorClasses = new Map(); this._catalogs = []; } Object.defineProperty(AXSecurityDomain.prototype, "xmlParser", { // static AXSecurityDomain: any; get: function () { return this._xmlParser || (this._xmlParser = new XMLParser(this)); }, enumerable: false, configurable: true }); Object.defineProperty(AXSecurityDomain.prototype, "AXFunctionUndefinedPrototype", { get: function () { return this._AXFunctionUndefinedPrototype || (this._AXFunctionUndefinedPrototype = this.createObject()); }, enumerable: false, configurable: true }); AXSecurityDomain.prototype.addCatalog = function (abcCatalog) { this._catalogs.push(abcCatalog); }; AXSecurityDomain.prototype.findDefiningABC = function (mn) { runtimeWriter && runtimeWriter.writeLn('findDefiningABC: ' + mn); var abcFile = null; for (var i = 0; i < this._catalogs.length; i++) { var abcCatalog = this._catalogs[i]; abcFile = abcCatalog.getABCByMultiname(mn); if (abcFile) { return abcFile; } } return null; }; AXSecurityDomain.prototype.throwError = function (className, error, replacement1, replacement2, replacement3, replacement4) { throw this.createError(className, error, replacement1, replacement2, replacement3, replacement4); }; AXSecurityDomain.prototype.createError = function (className, error, replacement1, replacement2, replacement3, replacement4) { var message = formatErrorMessage.call(null, error, replacement1, replacement2, replacement3, replacement4); var mn = Multiname.FromFQNString(className, 0 /* NamespaceType.Public */); var axClass = this.system.getProperty(mn, true, true); return axConstructFast(axClass, [message, error.code]); }; AXSecurityDomain.prototype.applyType = function (axClass, types) { var vectorProto = this.ObjectVector.axClass.superClass.dPrototype; if (!vectorProto.isPrototypeOf(axClass.dPrototype)) { this.throwError('TypeError', Errors.TypeAppOfNonParamType); } if (types.length !== 1) { this.throwError('TypeError', Errors.WrongTypeArgCountError, '__AS3__.vec::Vector', 1, types.length); } var type = types[0] || this.AXObject; return this.getVectorClass(type); }; AXSecurityDomain.prototype.getVectorClass = function (type) { var vectorClass = this.vectorClasses.get(type); if (vectorClass) { return vectorClass; } var typeClassName = type && type.classInfo ? type.classInfo.instanceInfo.multiname.getMangledName() : '$BgObject'; switch (typeClassName) { case '$BgNumber': case '$Bgdouble': vectorClass = this.Float64Vector.axClass; break; case '$Bgint': vectorClass = this.Int32Vector.axClass; break; case '$Bguint': vectorClass = this.Uint32Vector.axClass; break; default: vectorClass = this.createVectorClass(type); } this.vectorClasses.set(type, vectorClass); return vectorClass; }; AXSecurityDomain.prototype.createVectorClass = function (type) { var genericVectorClass = this.ObjectVector.axClass; var axClass = Object.create(genericVectorClass); // Put the superClass tPrototype on the prototype chain so we have access // to all factory protocol handlers by default. axClass.tPrototype = Object.create(genericVectorClass.tPrototype); axClass.tPrototype.axClass = axClass; axClass.tPrototype.axClassName = axClass.classInfo.instanceInfo.getClassName(); // We don't need a new dPrototype object. axClass.dPrototype = genericVectorClass.dPrototype; axClass.superClass = genericVectorClass; axClass.type = type; return axClass; }; /** * Constructs a plain vanilla object in this security domain. */ AXSecurityDomain.prototype.createObject = function () { return Object.create(this.AXObject.tPrototype); }; /** * Takes a JS Object and transforms it into an AXObject. */ AXSecurityDomain.prototype.createObjectFromJS = function (value, deep) { if (deep === void 0) { deep = false; } var keys = Object.keys(value); var result = this.createObject(); for (var i = 0; i < keys.length; i++) { var v = value[keys[i]]; if (deep) { v = transformJSValueToAS(this, v, true); } result.axSetPublicProperty(keys[i], v); } return result; }; /** * Constructs an AXArray in this security domain and sets its value to the given array. * Warning: This doesn't handle non-indexed keys. */ AXSecurityDomain.prototype.createArrayUnsafe = function (value) { var array = Object.create(this.AXArray.tPrototype); array.value = value; if (!release) { // Array values must only hold index keys. for (var k in value) { assert(isIndex(k)); checkValue(value[k]); } } return array; }; /** * Constructs an AXArray in this security domain and copies all enumerable properties of * the given array, setting them as public properties on the AXArray. * Warning: this does not use the given Array as the `value`. */ AXSecurityDomain.prototype.createArray = function (value) { var array = this.createArrayUnsafe([]); for (var k in value) { array.axSetPublicProperty(k, value[k]); release || checkValue(value[k]); } array.length = value.length; return array; }; /** * Constructs an AXFunction in this security domain and sets its value to the given function. */ AXSecurityDomain.prototype.boxFunction = function (value) { var fn = Object.create(this.AXFunction.tPrototype); fn.value = value; return fn; }; AXSecurityDomain.prototype.createClass = function (classInfo, superClass, scope) { var instanceInfo = classInfo.instanceInfo; var className = instanceInfo.multiname.toFQNString(false); var axClass = this.nativeClasses[className] || Object.create(this.AXClass.tPrototype); var classScope = new Scope(scope, axClass); if (!this.nativeClasses[className]) { if (instanceInfo.isInterface()) { axClass.dPrototype = Object.create(this.objectPrototype); axClass.tPrototype = Object.create(axClass.dPrototype); axClass.tPrototype.axInitializer = axInterfaceInitializer; axClass.axIsInstanceOf = axIsInstanceOfInterface; axClass.axIsType = axIsTypeInterface; } else { // For direct descendants of Object, we want the dynamic prototype to inherit from // Object's tPrototype because Foo.prototype is always a proper instance of Object. // For all other cases, the dynamic prototype should extend the parent class's // dynamic prototype not the tPrototype. if (superClass === this.AXObject) { axClass.dPrototype = Object.create(this.objectPrototype); } else if (superClass.dPrototype) { axClass.dPrototype = Object.create(superClass.dPrototype); } else { axClass.dPrototype = Object.create(superClass.prototype); // mark that has external prototupe of chain Object.defineProperty(axClass.dPrototype, IS_EXTERNAL_CLASS, { value: true }); } axClass.tPrototype = Object.create(axClass.dPrototype); axClass.tPrototype.axInitializer = this.createInitializerFunction(classInfo, classScope); } } else { axClass.tPrototype.axInitializer = this.createInitializerFunction(classInfo, classScope); // Native classes have their inheritance structure set up during initial SecurityDomain // creation. release || assert(axClass.dPrototype); release || assert(axClass.tPrototype); } axClass.classInfo = axClass.dPrototype.classInfo = classInfo; axClass.dPrototype.axClass = axClass; axClass.dPrototype.axClassName = classInfo.instanceInfo.getClassName(); axClass.superClass = superClass; axClass.scope = scope; var forceNativeMethods = nativeClasses[className] ? nativeClasses[className].forceNativeMethods : false; // Object and Class have their traits initialized earlier to avoid circular dependencies. if (className !== 'Object' && className !== 'Class') { this.initializeRuntimeTraits(axClass, superClass, classScope, forceNativeMethods); } // Add the |constructor| property on the class dynamic prototype so that all instances can // get to their class constructor, and FooClass.prototype.constructor returns FooClass. defineNonEnumerableProperty(axClass.dPrototype, '$Bgconstructor', axClass); // Copy over all TS symbols. tryLinkNativeClass(axClass); // Create the global for for the class var global = this.createAXGlobal(classInfo.abc.applicationDomain, classInfo); classInfo.global = global; // Run the static initializer. var methodInfo = classInfo.methodInfo; var methodBodyCode = methodInfo.getBody().code; // ... except if it's the standard class initializer that doesn't really do anything. //208 = GETLOCAL0, 48 = PUSHSCOPE, 71 = RETURNVOID if (methodBodyCode[0] !== 208 || methodBodyCode[1] !== 48 || methodBodyCode[2] !== 71) { interpret(methodInfo, classScope, null).apply(axClass, [axClass]); } return axClass; }; AXSecurityDomain.prototype.initializeRuntimeTraits = function (axClass, superClass, scope, forceNativeMethods) { if (forceNativeMethods === void 0) { forceNativeMethods = false; } var classInfo = axClass.classInfo; var instanceInfo = classInfo.instanceInfo; // Prepare class traits. var classTraits; if (axClass === this.AXClass) { classTraits = instanceInfo.traits.resolveRuntimeTraits(null, null, scope, forceNativeMethods); } else { var rootClassTraits = this.AXClass.classInfo.instanceInfo.runtimeTraits; release || assert(rootClassTraits); // Class traits don't capture the class' scope. This is relevant because it allows // referring to global names that would be shadowed if the class scope were active. // Haxe's stdlib uses just such constructs, e.g. Std.parseFloat calls the global // parseFloat. classTraits = classInfo.traits .resolveRuntimeTraits(rootClassTraits, null, scope.parent, forceNativeMethods); } classInfo.runtimeTraits = classTraits; applyTraits(axClass, classTraits); // Prepare instance traits. var superInstanceTraits = (superClass && superClass[IS_AX_CLASS]) ? superClass.classInfo.instanceInfo.runtimeTraits : null; var instanceTraits = instanceInfo.traits.resolveRuntimeTraits(superInstanceTraits, instanceInfo.protectedNs, scope, forceNativeMethods); instanceInfo.runtimeTraits = instanceTraits; applyTraits(axClass.tPrototype, instanceTraits); }; AXSecurityDomain.prototype.createFunction = function (methodInfo, scope, hasDynamicScope) { //const traceMsg = !release && flashlog && methodInfo.trait ? methodInfo.toFlashlogString() : null; // eslint-disable-next-line no-var var fun = this.boxFunction(interpret(methodInfo, scope, fun)); //fun.methodInfo = methodInfo; fun.receiver = { scope: scope }; if (!release) { try { Object.defineProperty(fun.value, 'name', { value: methodInfo.name }); } catch (e) { // Ignore errors in browsers that don't allow overriding Function#length; } } return fun; }; AXSecurityDomain.prototype.createInitializerFunction = function (classInfo, scope) { var methodInfo = classInfo.instanceInfo.methodInfo; var traceMsg = !release && flashlog && methodInfo.trait ? methodInfo.toFlashlogString() : null; var fun = getNativeInitializer(classInfo); if (!fun) { release || assert(!methodInfo.isNative(), 'Must provide a native initializer for ' + classInfo.instanceInfo.getClassName()); var name_1 = classInfo.instanceInfo.getClassName(); var binarySymbol_1 = classInfo.abc.applicationDomain.getBinarySymbol(name_1); if (binarySymbol_1) { binarySymbol_1.buffer = binarySymbol_1.data; fun = function () { release || console.log('create instance for binary data:', classInfo.instanceInfo.getClassName()); ByteArrayDataProvider.symbolForConstructor = binarySymbol_1; release || (traceMsg && flashlog.writeAS3Trace(methodInfo.toFlashlogString())); return interpret(methodInfo, scope, null).apply(this, arguments); }; } else { fun = interpret(methodInfo, scope, null); } if (!release) { try { var className = classInfo.instanceInfo.multiname.toFQNString(false); Object.defineProperty(fun, 'name', { value: className }); } catch (e) { // Ignore errors in browsers that don't allow overriding Function#length; } } // REDUX: enable arg count checking on native ctors. Currently impossible because natives // are frozen. fun.methodInfo = methodInfo; } return fun; }; AXSecurityDomain.prototype.createActivation = function (methodInfo, scope) { var body = methodInfo.getBody(); var aPrototype = body.activationPrototype; if (!aPrototype) { aPrototype = body.activationPrototype = Object.create(this.AXActivationPrototype); defineReadOnlyProperty(aPrototype, 'traits', body.traits.resolveRuntimeTraits(null, null, scope)); } return Object.create(aPrototype); }; AXSecurityDomain.prototype.createCatch = function (exceptionInfo, scope) { if (!exceptionInfo.catchPrototype) { var traits = exceptionInfo.getTraits(); exceptionInfo.catchPrototype = Object.create(this.AXCatchPrototype); defineReadOnlyProperty(exceptionInfo.catchPrototype, 'traits', traits.resolveRuntimeTraits(null, null, scope)); } return Object.create(exceptionInfo.catchPrototype); }; AXSecurityDomain.prototype.box = function (v) { if (v == undefined) return v; if (v.constructor === Array) return this.AXArray.axBox(v); var t = typeof v; switch (t) { case 'number': return this.AXNumber.axBox(v); case 'boolean': return this.AXBoolean.axBox(v); case 'string': return this.AXString.axBox(v); } release || assert(AXBasePrototype.isPrototypeOf(v)); return v; }; AXSecurityDomain.prototype.isPrimitive = function (v) { return isPrimitiveJSValue(v) || this.AXPrimitiveBox.dPrototype.isPrototypeOf(v); }; AXSecurityDomain.prototype.createAXGlobal = function (applicationDomain, globalInfo) { var global = Object.create(this.AXGlobalPrototype); global.applicationDomain = applicationDomain; global.globalInfo = globalInfo; var scope = global.scope = new Scope(null, global, false); var objectTraits = this.AXObject.classInfo.instanceInfo.runtimeTraits; var traits = globalInfo.traits.resolveRuntimeTraits(objectTraits, null, scope); applyTraits(global, traits); global[IS_AX_CLASS] = true; return global; }; /** * Prepares the dynamic Class prototype that all Class instances (including Class) have in * their prototype chain. * * This prototype defines the default hooks for all classes. Classes can override some or * all of them. */ AXSecurityDomain.prototype.prepareRootClassPrototype = function () { var dynamicClassPrototype = Object.create(this.objectPrototype); var rootClassPrototype = Object.create(dynamicClassPrototype); rootClassPrototype.$BgtoString = function axClassToString() { return '[class ' + this.classInfo.instanceInfo.multiname.name + ']'; }; var D = defineNonEnumerableProperty; D(rootClassPrototype, 'axBox', axBoxIdentity); D(rootClassPrototype, 'axCoerce', axCoerce); D(rootClassPrototype, 'axIsType', axIsTypeObject); D(rootClassPrototype, 'axAsType', axAsType); D(rootClassPrototype, 'axIsInstanceOf', axIsInstanceOfObject); D(rootClassPrototype, 'axConstruct', axConstruct); D(rootClassPrototype, 'axApply', axDefaultApply); Object.defineProperty(rootClassPrototype, 'name', { get: function () { return this.classInfo.instanceInfo.multiname; } }); rootClassPrototype[IS_AX_CLASS] = true; this.rootClassPrototype = rootClassPrototype; }; AXSecurityDomain.prototype.initializeCoreNatives = function () { // Some facts: // - The Class constructor is itself an instance of Class. // - The Class constructor is an instance of Object. // - The Object constructor is an instance of Class. // - The Object constructor is an instance of Object. this.prepareRootClassPrototype(); var AXClass = this.prepareNativeClass('AXClass', 'Class', false); AXClass.classInfo = this.system.findClassInfo('Class'); AXClass.defaultValue = null; var AXObject = this.prepareNativeClass('AXObject', 'Object', false); AXObject.classInfo = this.system.findClassInfo('Object'); AXObject = this.AXObject; // AXFunction needs to exist for runtime trait resolution. var AXFunction = this.prepareNativeClass('AXFunction', 'Function', false); defineNonEnumerableProperty(AXFunction, 'axBox', axBoxPrimitive); // Initialization of the core classes' traits is a messy multi-step process: // First, create a scope for looking up all the things. var scope = new Scope(null, AXClass, false); // Then, create the runtime traits all Object instances share. var objectCI = this.AXObject.classInfo; var objectII = objectCI.instanceInfo; var objectRTT = objectII.runtimeTraits = objectII.traits.resolveRuntimeTraits(null, null, scope); applyTraits(this.AXObject.tPrototype, objectRTT); // Building on that, create the runtime traits all Class instances share. var classCI = this.AXClass.classInfo; var classII = classCI.instanceInfo; classII.runtimeTraits = classII.traits.resolveRuntimeTraits(objectRTT, null, scope); applyTraits(this.AXClass.tPrototype, classII.runtimeTraits); // As sort of a loose end, also create the one class trait Class itself has. classCI.runtimeTraits = classCI.traits.resolveRuntimeTraits(objectRTT, null, scope); applyTraits(this.AXClass, classCI.runtimeTraits); // Now we can create Object's runtime class traits. objectCI.runtimeTraits = objectCI.traits.resolveRuntimeTraits(classII.runtimeTraits, null, scope); applyTraits(this.AXObject, objectCI.runtimeTraits); AXObject[IS_AX_CLASS] = true; return AXObject; }; AXSecurityDomain.prototype.prepareNativeClass = function (exportName, name, isPrimitiveClass) { var axClass = Object.create(this.rootClassPrototype); // For Object and Class, we've already created the instance prototype to break // circular dependencies. if (name === 'Object') { axClass.dPrototype = Object.getPrototypeOf(this.objectPrototype); axClass.tPrototype = this.objectPrototype; } else if (name === 'Class') { axClass.dPrototype = Object.getPrototypeOf(this.rootClassPrototype); axClass.tPrototype = this.rootClassPrototype; } else { var instancePrototype = isPrimitiveClass ? this.AXPrimitiveBox.dPrototype : exportName === 'AXMethodClosure' ? this.AXFunction.dPrototype : this.objectPrototype; axClass.dPrototype = Object.create(instancePrototype); axClass.tPrototype = Object.create(axClass.dPrototype); } this[exportName] = this.nativeClasses[name] = axClass; axClass[IS_AX_CLASS] = true; return axClass; }; AXSecurityDomain.prototype.preparePrimitiveClass = function (exportName, name, convert, defaultValue, coerce, isType, isInstanceOf) { var axClass = this.prepareNativeClass(exportName, name, true); var D = defineNonEnumerableProperty; D(axClass, 'axBox', axBoxPrimitive); D(axClass, 'axApply', function axApply(_, args) { return convert(args && args.length ? args[0] : defaultValue); }); D(axClass, 'axConstruct', function axConstruct(args) { return convert(args && args.length ? args[0] : defaultValue); }); D(axClass, 'axCoerce', coerce); D(axClass, 'axIsType', isType); D(axClass, 'axIsInstanceOf', isInstanceOf); D(axClass.dPrototype, 'value', defaultValue); axClass[IS_AX_CLASS] = true; return axClass; }; /** * Configures all the builtin Objects. */ AXSecurityDomain.prototype.initialize = function () { var D = defineNonEnumerableProperty; // The basic dynamic prototype that all objects in this security domain have in common. var dynamicObjectPrototype = Object.create(AXBasePrototype); dynamicObjectPrototype.sec = this; // The basic traits prototype that all objects in this security domain have in common. Object.defineProperty(this, 'objectPrototype', { value: Object.create(dynamicObjectPrototype) }); this.initializeCoreNatives(); // Debugging Helper release || (this.objectPrototype['trace'] = function trace() { var self = this; var writer = new IndentingWriter(); this.traits.traits.forEach(function (t) { writer.writeLn(t + ': ' + self[t.getName().getMangledName()]); }); }); this.AXGlobalPrototype = Object.create(this.objectPrototype); this.AXGlobalPrototype.$BgtoString = function () { return '[object global]'; }; this.AXActivationPrototype = Object.create(this.objectPrototype); this.AXActivationPrototype.$BgtoString = function () { return '[Activation]'; }; this.AXCatchPrototype = Object.create(this.objectPrototype); this.AXCatchPrototype.$BgtoString = function () { return '[Catch]'; }; // The core classes' MOP hooks and dynamic prototype methods are defined // here to keep all the hooks initialization in one place. var AXObject = this.AXObject; var AXFunction = this.AXFunction; // Object(null) creates an object, and this behaves differently than: // (function (x: Object) { trace (x); })(null) which prints null. D(AXObject, 'axApply', axApplyObject); D(AXObject, 'axConstruct', axConstructObject); D(AXObject.tPrototype, 'axInitializer', axDefaultInitializer); D(AXObject, 'axCoerce', axCoerceObject); this.prepareNativeClass('AXMethodClosure', 'builtin.as$0.MethodClosure', false); this.prepareNativeClass('AXError', 'Error', false); this.prepareNativeClass('AXMath', 'Math', false); this.prepareNativeClass('AXDate', 'Date', false); this.prepareNativeClass('AXXML', 'XML', false); this.prepareNativeClass('AXXMLList', 'XMLList', false); this.prepareNativeClass('AXQName', 'QName', false); this.prepareNativeClass('AXNamespace', 'Namespace', false); var AXArray = this.prepareNativeClass('AXArray', 'Array', false); //D(AXArray, 'axBox', axBoxPrimitive); AXArray.tPrototype.$BgtoString = AXFunction.axBox(function () { return this.value.toString(); }); // Array.prototype is an Array, and behaves like one. AXArray.dPrototype['value'] = []; this.argumentsPrototype = Object.create(this.AXArray.tPrototype); Object.defineProperty(this.argumentsPrototype, '$Bgcallee', { get: axGetArgumentsCallee }); var AXRegExp = this.prepareNativeClass('AXRegExp', 'RegExp', false); // RegExp.prototype is an (empty string matching) RegExp, and behaves like one. AXRegExp.dPrototype['value'] = /(?:)/; // Boolean, int, Number, String, and uint are primitives in AS3. We create a placeholder // base class to help us with instanceof tests. var AXPrimitiveBox = this.prepareNativeClass('AXPrimitiveBox', 'PrimitiveBox', false); D(AXPrimitiveBox.dPrototype, '$BgtoString', AXFunction.axBox(function () { return this.value.toString(); })); this.preparePrimitiveClass('AXBoolean', 'Boolean', axCoerceBoolean, false, axCoerceBoolean, axIsTypeBoolean, axIsTypeBoolean); this.preparePrimitiveClass('AXString', 'String', axConvertString, '', axCoerceString, axIsTypeString, axIsTypeString); this.preparePrimitiveClass('AXNumber', 'Number', axCoerceNumber, 0, axCoerceNumber, axIsTypeNumber, axIsTypeNumber); this.preparePrimitiveClass('AXInt', 'int', axCoerceInt, 0, axCoerceInt, axIsTypeInt, axFalse); this.preparePrimitiveClass('AXUint', 'uint', axCoerceUint, 0, axCoerceUint, axIsTypeUint, axFalse); // Install class loaders on the security domain. installClassLoaders(this.application, this); installNativeFunctions(this); }; return AXSecurityDomain; }()); export { AXSecurityDomain };