Repository: dotnet/runtime
File: src/native/corehost/browserhost/host/host.ts (TypeScript)

Code before:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import type { CharPtr, VfsAsset, VoidPtr, VoidPtrPtr } from "./types";
import { _ems_ } from "../../../libs/Common/JavaScript/ems-ambient";

const loadedAssemblies: Map<string, { ptr: number, length: number }> = new Map();

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function registerPdbBytes(bytes: Uint8Array, asset: { name: string, virtualPath: string }) {
    throw new Error("Not implemented");
}

export function registerDllBytes(bytes: Uint8Array, asset: { name: string, virtualPath: string }) {
    const sp = _ems_.Module.stackSave();
    try {
        const sizeOfPtr = 4;
        const ptrPtr = _ems_.Module.stackAlloc(sizeOfPtr);
        if (_ems_.Module._posix_memalign(ptrPtr as any, 16, bytes.length)) {
            throw new Error("posix_memalign failed");
        }

        const ptr = _ems_.Module.HEAPU32[ptrPtr as any >>> 2];
        _ems_.Module.HEAPU8.set(bytes, ptr >>> 0);
        loadedAssemblies.set(asset.virtualPath, { ptr, length: bytes.length });
        if (!asset.virtualPath.startsWith("/")) {
            loadedAssemblies.set("/" + asset.virtualPath, { ptr, length: bytes.length });
        }
    } finally {
        _ems_.Module.stackRestore(sp);
    }
}

export function loadIcuData(bytes: Uint8Array) {
    const sp = _ems_.Module.stackSave();
    try {
        const sizeOfPtr = 4;

Review comment (suggestion):
The stub implementation of registerPdbBytes should have a comment explaining why it's not yet implemented and referencing any related tracking issue or TODO. This helps maintainers understand the current state and future plans.

Code after:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import type { CharPtr, VfsAsset, VoidPtr, VoidPtrPtr } from "./types";
import { _ems_ } from "../../../libs/Common/JavaScript/ems-ambient";

const loadedAssemblies: Map<string, { ptr: number, length: number }> = new Map();

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function registerPdbBytes(bytes: Uint8Array, asset: { name: string, virtualPath: string }) {
    // WASM-TODO: https://github.com/dotnet/runtime/issues/122921
}

export function registerDllBytes(bytes: Uint8Array, asset: { name: string, virtualPath: string }) {
    const sp = _ems_.Module.stackSave();
    try {
        const sizeOfPtr = 4;
        const ptrPtr = _ems_.Module.stackAlloc(sizeOfPtr);
        if (_ems_.Module._posix_memalign(ptrPtr as any, 16, bytes.length)) {
            throw new Error("posix_memalign failed");
        }

        const ptr = _ems_.Module.HEAPU32[ptrPtr as any >>> 2];
        _ems_.Module.HEAPU8.set(bytes, ptr >>> 0);
        loadedAssemblies.set(asset.virtualPath, { ptr, length: bytes.length });
        if (!asset.virtualPath.startsWith("/")) {
            loadedAssemblies.set("/" + asset.virtualPath, { ptr, length: bytes.length });
        }
    } finally {
        _ems_.Module.stackRestore(sp);
    }
}

export function loadIcuData(bytes: Uint8Array) {
    const sp = _ems_.Module.stackSave();
    try {
        const sizeOfPtr = 4;