sun::moon_bundling

sun::moon_bundling

namespace · Source (opens in a new tab)

Builds and loads compiled Moon libraries and their declaration metadata.

Classes

Structs

Functions

archiveHoldsMachO

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

bool sun::moon_bundling::archiveHoldsMachO(const Archive &archive)

Whether the members are Mach-O objects, decided from the first one.

The archive format alone does not say: the BSD layout holds either kind.

bindMetadataModules

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

void sun::moon_bundling::bindMetadataModules(google::protobuf::Message &message, sun::semantic_analysis::SemanticContext &context)

Bind module expressions and using targets before exporting generic bodies.

Resolves serialized module references in the active semantic context.

Related: sun::semantic_analysis::SemanticContext

bindMetadataTypes

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

void sun::moon_bundling::bindMetadataTypes(google::protobuf::Message &message, sun::semantic_analysis::SemanticContext &context)

Bind serialized declarations in their definition context without specializing templates.

Resolves serialized type references in the active semantic context.

Related: sun::semantic_analysis::SemanticContext

computeArchiveSetHash

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

std::string sun::moon_bundling::computeArchiveSetHash(const std::vector< std::pair< std::string, std::string > > &namesAndDigests)

The hash a bundle's own archives have their symbols renamed under: over every archive's file name and the SHA-256 of its bytes as shipped by the vendor, independent of manifest order.

Computes a stable content identity for a set of native archives.

Longer than a bundle hash because a collision here would merge two libraries' symbols.

computeSha256Hex

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

std::string sun::moon_bundling::computeSha256Hex(llvm::StringRef data)

Return the full lowercase SHA-256 digest of exact source or artifact bytes.

Returns the hexadecimal SHA-256 digest of the supplied contents.

exportType

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

pbc::TypeAnnotation sun::moon_bundling::exportType(const sun::types::TypePtr &type, const sun::semantic_analysis::DeclarationTable &declarations)

Convert a resolved type to an exportable annotation with exact nominal identities.

Serializes a semantic type with its portable declaration identity.

Related: sun::types::TypePtr, sun::semantic_analysis::DeclarationTable

extractAnalyzedMetadata

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

std::vector< moon::ModuleMetadata > sun::moon_bundling::extractAnalyzedMetadata(const sun::ast::BlockExprAST &program, sun::semantic_analysis::SemanticAnalyzer &analyzer, const std::string &bundleHash)

Export the bundle's own declarations from the successfully analyzed program.

Exports library declaration metadata from an analyzed program.

Related: sun::ast::BlockExprAST, sun::semantic_analysis::SemanticAnalyzer

getSymbolPrefix

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

std::string sun::moon_bundling::getSymbolPrefix(const moon::ModuleMetadata &metadata)

Get symbol prefix for protobuf metadata.

listArchiveDefinitions

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

std::map< std::string, std::string > sun::moon_bundling::listArchiveDefinitions(llvm::MemoryBufferRef archive)

The symbols an archive's index says it defines, keyed by the name with any $hash$_ prefix removed, mapped to the name as recorded.

Maps defined symbols to the archive members that supply them.

Used to tell when a plain extern names something a bundle carries only in prefixed form.

listArchiveIndex

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

std::vector< std::string > sun::moon_bundling::listArchiveIndex(llvm::MemoryBufferRef archive)

The names in an archive's symbol index as C code spells them (Mach-O's leading underscore removed).

Lists the symbols advertised by the archive index.

Cheap: the index and one member header.

parseMoonImportSpec

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

std::optional< MoonImport > sun::moon_bundling::parseMoonImportSpec(const std::string &spec)

Parse a moon import specification from CLI argument Format: "path.moon" or "path.moon:from=to" or "path.moon:from1=to1,from2=to2" Returns nullopt if parsing fails.

Related: MoonImport

renameArchiveSymbols

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

llvm::Expected< std::string > sun::moon_bundling::renameArchiveSymbols(llvm::MemoryBufferRef archive, const std::map< std::string, std::string > &renames)

Rewrite archive so that every symbol named in renames (bare old name to bare new name) is renamed in every member, definitions and references alike, and return the new archive bytes with a fresh symbol index.

Rewrites native archive symbols using the supplied name mapping.

sameOsFamily

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

bool sun::moon_bundling::sameOsFamily(const llvm::Triple &rawA, const llvm::Triple &rawB)

Whether two triples name the same operating system for bundle-matching purposes.

Struct layouts and ABI decisions are baked into a bundle's bitcode per OS as well as per architecture, so an aarch64-linux bundle must never stand in for an arm64 macOS target. Apple triples spell the same system several ways (darwin, macosx), which is why this is not a plain getOS() comparison; both sides are normalized first because the common three-part spelling "aarch64-linux-gnu" would otherwise parse with an unknown OS. Environment (gnu vs musl) is deliberately not compared: those layouts are compatible.

scanArchiveSymbols

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

llvm::Expected< ArchiveSymbolScan > sun::moon_bundling::scanArchiveSymbols(llvm::MemoryBufferRef archive)

Read every member of archive and classify its global symbols.

Reads archive symbols and reports definitions requiring library isolation.

Fails when a member is not a native object (an LLVM bitcode member from an LTO build cannot be renamed) or when members mix object formats.

Related: ArchiveSymbolScan

Type Aliases

ScopeSwitchGuard

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

using sun::moon_bundling::ScopeSwitchGuard = 
    sun::semantic_analysis::SemanticContext::ScopeSwitchGuard

Names the guard that restores semantic scope after metadata lookup.

Related: sun::semantic_analysis::SemanticContext::ScopeSwitchGuard