Skip to content

v3.modulecache

Constants #

const builtin_bundle_imports = ['strconv', 'strings', 'hash', 'math.bits']
const builtin_bundle_modules = ['builtin', 'strconv', 'strings', 'hash', 'bits', 'math.bits']

fn c_source_has_static_storage #

fn c_source_has_static_storage(source string) bool

c_source_has_static_storage reports whether a local C input would give cached translation units separate copies of static storage.

fn declaration_header #

fn declaration_header(prefix string) string

declaration_header converts the generated owner prefix into a C header for cached module translation units. Type definitions and static helpers stay local; owner functions and storage become declarations resolved from main.o.

fn file_signature #

fn file_signature(path string) string

file_signature returns a stable content signature for a cache input file.

fn header_needs_source #

fn header_needs_source(entry Entry) bool

header_needs_source reports whether a declaration header has bodies that must remain available to per-program monomorphization.

fn header_signature #

fn header_signature(header string) string

header_signature returns the stable content signature stored in dependent object stamps for a declaration-only module header.

fn module_header #

fn module_header(a &flat.FlatAst, tc &types.TypeChecker, module_name string, vroot string, import_paths map[string]string) string

module_header serializes the declaration-only interface for one flat-AST module.

fn new_manager #

fn new_manager(vroot string, salt string, enabled bool, build_pseudo_values string) Manager

new_manager creates a configuration-scoped persistent module cache manager.

fn source_signature #

fn source_signature(source_files []string) string

source_signature hashes selected source paths, contents, resolved module roots, build/environment values, and pkg-config probe results in stable order.

fn split_generated_c #

fn split_generated_c(source string) !CSplit

split_generated_c separates a cache-marked monolithic translation unit.

struct CSplit #

struct CSplit {
pub:
	prefix  string
	modules map[string]string
}

CSplit contains the declaration/runtime prefix and per-module C function bodies.

struct Entry #

struct Entry {
pub:
	header       string
	object       string
	header_stamp string
	object_stamp string
	c_source     string
}

Entry contains the persistent artifacts for one V module.

struct Manager #

struct Manager {
	build_pseudo_values string
pub:
	dir     string
	enabled bool
	salt    string
}

Manager owns persistent v3 module cache paths for one compiler configuration.

fn (Manager) ensure_dir #

fn (m &Manager) ensure_dir() bool

ensure_dir creates the manager's private cache directory.

fn (Manager) entry #

fn (m &Manager) entry(module_name string, source_files []string) Entry

entry returns collision-resistant artifact paths for a module and source root.

fn (Manager) object_entry #

fn (m &Manager) object_entry(module_name string, source_files []string, compile_signature string) Entry

object_entry returns the C artifacts for one effective compile-flag set.

fn (Manager) valid_entry #

fn (m &Manager) valid_entry(module_name string, source_files []string) ?Entry

valid_entry reports whether both interface and object artifacts match their sources.

fn (Manager) valid_header #

fn (m &Manager) valid_header(module_name string, source_files []string) ?Entry

valid_header reports whether a declaration header matches its module sources.

fn (Manager) valid_object #

fn (m &Manager) valid_object(cache_name string, source_files []string) ?Entry

valid_object reports whether a cached object matches the supplied sources.

fn (Manager) write_entry #

fn (m &Manager) write_entry(module_name string, source_files []string, header string) !Entry

write_entry commits a module interface and stamp after its object was built.

fn (Manager) write_header #

fn (m &Manager) write_header(module_name string, source_files []string, header string) !Entry

write_header commits one declaration-only module header and its source stamp.

fn (Manager) valid_object_for_compile_signature #

fn (m &Manager) valid_object_for_compile_signature(cache_name string, source_files []string, compile_signature string, dependency_inputs map[string]string) ?Entry

valid_object_for_compile_signature reports whether the flag-specific object matches its sources, dependency headers, and effective C compilation flags.

fn (Manager) write_stamp #

fn (m &Manager) write_stamp(module_name string, source_files []string, dependency_inputs map[string]string, compile_signature string) !

write_stamp refreshes a cache stamp after the object and header are durable. dependency_inputs maps every transitive imported .vh and non-V input path to the content signature that the object was compiled against.