| 1673 | } |
| 1674 | |
| 1675 | void fxMapModuleDescriptor(txMachine* the, txSlot* realm, txID moduleID, txSlot* module, txSlot* queue, txSlot* result, txSlot* descriptor) |
| 1676 | { |
| 1677 | txSlot* property; |
| 1678 | if (!mxIsReference(descriptor)) |
| 1679 | mxTypeError("descriptor: not an object"); |
| 1680 | |
| 1681 | mxPushSlot(descriptor); |
| 1682 | mxGetID(fxID(the, "namespace")); |
| 1683 | property = the->stack; |
| 1684 | if (!mxIsUndefined(property)) { |
| 1685 | if ((property->kind == XS_STRING_KIND) || (property->kind == XS_STRING_X_KIND)) { |
| 1686 | txSlot* aliasRealm; |
| 1687 | txSlot* aliasOwn; |
| 1688 | txID aliasModuleID; |
| 1689 | txSlot* aliasModule; |
| 1690 | mxPushSlot(descriptor); |
| 1691 | mxGetID(fxID(the, "compartment")); |
| 1692 | if (!mxIsUndefined(the->stack)) { |
| 1693 | txSlot* program = fxCheckCompartmentInstance(the, the->stack); |
| 1694 | aliasRealm = mxModuleInstanceInternal(program)->value.module.realm; |
| 1695 | } |
| 1696 | else { |
| 1697 | aliasRealm = mxRealmParent(realm)->value.reference; |
| 1698 | } |
| 1699 | aliasOwn = mxOwnModules(aliasRealm)->value.reference; |
| 1700 | mxPop(); |
| 1701 | aliasModuleID = fxResolveSpecifier(the, aliasRealm, XS_NO_ID, property); |
| 1702 | // if ((aliasRealm == realm) && (aliasModuleID == moduleID)) |
| 1703 | // mxTypeError("descriptor.specifier is circular"); |
| 1704 | |
| 1705 | aliasModule = mxBehaviorGetProperty(the, aliasOwn, aliasModuleID, 0, XS_ANY); |
| 1706 | if (aliasModule) { |
| 1707 | property = aliasModule; |
| 1708 | } |
| 1709 | else { |
| 1710 | property = mxBehaviorSetProperty(the, aliasOwn, aliasModuleID, 0, XS_OWN); |
| 1711 | fxNewModule(the, aliasRealm, aliasModuleID, XS_NO_FLAG, property); |
| 1712 | } |
| 1713 | goto namespace; |
| 1714 | } |
| 1715 | else { |
| 1716 | txSlot* instance = module->value.reference; |
| 1717 | if (!mxIsReference(property)) |
| 1718 | mxTypeError("descriptor.namespace: not an object"); |
| 1719 | if (mxIsModule(property->value.reference)) |
| 1720 | goto namespace; |
| 1721 | fxLoadVirtualModuleNamespace(the, property->value.reference, instance); |
| 1722 | txID status = mxModuleInstanceStatus(instance); |
| 1723 | if ((status == XS_MODULE_STATUS_NEW) || (status == XS_MODULE_STATUS_LOADING)) { |
| 1724 | mxModuleInstanceStatus(instance) = XS_MODULE_STATUS_EXECUTED; |
| 1725 | if (result) { |
| 1726 | |
| 1727 | } |
| 1728 | else { |
| 1729 | fxCompleteModule(the, instance, C_NULL); |
| 1730 | fxRunImportFulfilled(the, instance, instance); |
| 1731 | } |
| 1732 | } |
no test coverage detected