sun::moon_bundling::MoonReader

sun::moon_bundling::MoonReader

class · Source (opens in a new tab)

class sun::moon_bundling::MoonReader

Reads .moon bundle files and extracts individual modules.

Public Functions

getBitcodeId

public · function · Source (opens in a new tab)

std::string sun::moon_bundling::MoonReader::getBitcodeId(const std::string &moduleKey) const

Identity of the bitcode region backing a module.

Modules that share a code image share this string, so a caller can scan the image once instead of once per module. Empty if the module is unknown.

getError

public · function · Source (opens in a new tab)

const std::string & sun::moon_bundling::MoonReader::getError() const

Get error message if an operation failed.

getMetadata

public · function · Source (opens in a new tab)

const moon::ModuleMetadata * sun::moon_bundling::MoonReader::getMetadata(const std::string &moduleKey)

Get metadata for a module without loading bitcode.

param

  • moduleKey: The module key (source hash)

return: Protobuf metadata, or nullptr if not found

getNativeArchives

public · function · Source (opens in a new tab)

const std::vector< NativeArchiveEntry > & sun::moon_bundling::MoonReader::getNativeArchives() const

Native static libraries carried by this bundle, in link order.

Related: NativeArchiveEntry

getPath

public · function · Source (opens in a new tab)

const std::filesystem::path & sun::moon_bundling::MoonReader::getPath() const

Get the path to this bundle file.

getTargetTriple

public · function · Source (opens in a new tab)

std::string sun::moon_bundling::MoonReader::getTargetTriple()

The target the bundle's bitcode was compiled for (LLVM triple), taken from the first module's metadata.

Empty for pre-V4 legacy bundles.

hasModule

public · function · Source (opens in a new tab)

bool sun::moon_bundling::MoonReader::hasModule(const std::string &moduleKey) const

Check if a module exists in this bundle.

param

  • moduleKey: The module key (source hash)

listModules

public · function · Source (opens in a new tab)

std::vector< std::string > sun::moon_bundling::MoonReader::listModules() const

List all modules in the bundle.

loadModule

public · function · Source (opens in a new tab)

std::unique_ptr< llvm::Module > sun::moon_bundling::MoonReader::loadModule(const std::string &moduleKey, llvm::LLVMContext &context)

Load a module's LLVM bitcode.

param

  • moduleKey: The module key (source hash)

  • context: LLVM context to create module in

return: LLVM module, or nullptr on failure

open

public · function · static · Source (opens in a new tab)

std::unique_ptr< MoonReader > sun::moon_bundling::MoonReader::open(const std::filesystem::path &path)

Open a .moon bundle file.

param

  • path: Path to the .moon file

return: Reader instance, or nullptr on failure

Related: MoonReader

readNativeArchive

public · function · Source (opens in a new tab)

bool sun::moon_bundling::MoonReader::readNativeArchive(const NativeArchiveEntry &entry, std::vector< char > &out)

Read one carried archive's bytes.

Entries come from getNativeArchives(); two versions of a library share a file name, so the entry rather than the name identifies one. return: false if the read failed

Related: NativeArchiveEntry, getNativeArchives()

writeDebugJson

public · function · Source (opens in a new tab)

bool sun::moon_bundling::MoonReader::writeDebugJson(const std::filesystem::path &outputPath)

Write indented inspection JSON containing module metadata and payload locations, without embedding bitcode or archive bytes.

Returns false and sets getError() if metadata conversion or file output fails.

Related: getError()

Private Functions

MoonReader

private · function · Source (opens in a new tab)

sun::moon_bundling::MoonReader::MoonReader()=default

Creates an instance with its default state.

readBytes

private · function · Source (opens in a new tab)

bool sun::moon_bundling::MoonReader::readBytes(uint64_t offset, uint64_t size, std::vector< char > &buffer)

Read raw bytes from the bundle file.

Private Fields

error_

private · variable · Source (opens in a new tab)

std::string sun::moon_bundling::MoonReader::error_

No documentation comment.

indexMap_

private · variable · Source (opens in a new tab)

std::unordered_map<std::string, size_t> sun::moon_bundling::MoonReader::indexMap_

No documentation comment.

index_

private · variable · Source (opens in a new tab)

std::vector<ModuleIndexEntry> sun::moon_bundling::MoonReader::index_

No documentation comment.

Related: ModuleIndexEntry

metadataCache_

private · variable · Source (opens in a new tab)

std::unordered_map<std::string, moon::ModuleMetadata> sun::moon_bundling::MoonReader::metadataCache_

No documentation comment.

nativeArchives_

private · variable · Source (opens in a new tab)

std::vector<NativeArchiveEntry> sun::moon_bundling::MoonReader::nativeArchives_

No documentation comment.

Related: NativeArchiveEntry

path_

private · variable · Source (opens in a new tab)

std::filesystem::path sun::moon_bundling::MoonReader::path_

No documentation comment.