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_declares_types #
fn c_source_declares_types(source string) bool
c_source_declares_types reports whether a local C input defines a type whose declaration may be required by generated V declarations in another cache unit.
fn c_source_function_identifiers #
fn c_source_function_identifiers(source string) map[string]bool
c_source_function_identifiers returns C functions defined or declared at file scope.
fn c_source_function_identifiers_with_status #
fn c_source_function_identifiers_with_status(source string) (map[string]bool, bool)
c_source_function_identifiers_with_status returns file-scope C function names and whether every function declaration could be classified.
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 c_source_static_variable_identifiers #
fn c_source_static_variable_identifiers(source string) (map[string]bool, bool)
c_source_static_variable_identifiers returns file-scope static variable names and whether every such declaration could be classified.
fn c_source_type_declarations #
fn c_source_type_declarations(source string) string
c_source_type_declarations keeps preprocessor context and C type declarations, while omitting function bodies, function declarations, and storage.
fn c_source_type_declarations_with_status #
fn c_source_type_declarations_with_status(source string) (string, bool)
c_source_type_declarations_with_status also reports whether every declaration-like file-scope macro invocation could be classified.
fn c_source_type_identifiers #
fn c_source_type_identifiers(source string) map[string]bool
c_source_type_identifiers returns C typedef aliases and named aggregate tags.
fn c_source_typedef_identifiers #
fn c_source_typedef_identifiers(source string) map[string]bool
c_source_typedef_identifiers returns file-scope C typedef aliases.
fn c_sources_macro_identifiers_referencing #
fn c_sources_macro_identifiers_referencing(sources []string, identifiers map[string]bool) map[string]bool
c_sources_macro_identifiers_referencing returns macro names whose replacements directly or transitively reference one of the supplied identifiers.
fn cached_source_signature #
fn cached_source_signature(cache_dir string, namespace string, source_files []string) string
cached_source_signature returns a content signature while using precise file metadata to avoid rereading unchanged inputs on subsequent compiler runs.
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_metadata_signature #
fn file_metadata_signature(path string) string
file_metadata_signature returns a precise identity for an unchanged cache input. An empty result makes callers fall back to hashing the file contents.
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 materialize_cached_body_string_definitions #
fn materialize_cached_body_string_definitions(source string) string
materialize_cached_body_string_definitions restores body-only string storage recorded as cache marker comments. Real definitions in source take precedence.
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, version_pseudo_values string) Manager
new_manager creates a configuration-scoped persistent module cache manager.
fn prune_unreferenced_static_string_definitions #
fn prune_unreferenced_static_string_definitions(prefix string) string
prune_unreferenced_static_string_definitions removes generated string storage that is referenced only by the program body. Cached module objects carry their own static copies, while the program translation unit retains the full prefix. Keeping body-only strings out of the shared dylib prefix makes an ordinary program literal edit reuse the same cached dylib.
fn rewrite_cached_runtime_strings #
fn rewrite_cached_runtime_strings(cached_source string, old_values []string, new_values []string) ?string
rewrite_cached_runtime_strings updates cached C literal symbols as one simultaneous rewrite.
fn source_files_use_build_time_pseudo #
fn source_files_use_build_time_pseudo(source_files []string) bool
source_files_use_build_time_pseudo reports whether selected sources depend on build time.
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.
fn static_string_definitions #
fn static_string_definitions(source string) string
static_string_definitions returns generated literal storage needed by the current program body. Cached dependency declarations omit these records.
fn without_duplicate_static_string_definitions #
fn without_duplicate_static_string_definitions(source string, existing_source string) string
without_duplicate_static_string_definitions removes literal storage already supplied by an earlier cached C prefix while retaining new body-only literals.
struct CSplit #
struct CSplit {
pub:
prefix string
modules map[string]string
}
CSplit contains the declaration/runtime prefix and per-module C function bodies.
struct CgenEntry #
struct CgenEntry {
pub:
source string
metadata string
stamp string
prepared_main string
prepared_tcc string
prepared_prefix string
prepared_objects string
prepared_stamp string
}
CgenEntry contains the persistent whole-program C generation artifacts.
struct CgenPreparedEntry #
struct CgenPreparedEntry {
pub:
main string
tcc string
prefix string
}
CgenPreparedEntry contains cache-marked C sources already split for linking.
struct Entry #
struct Entry {
source_bodies bool
source_bodies_known bool
pub:
header string
object string
header_stamp string
object_stamp string
c_source string
}
Entry contains the persistent artifacts for one V module.
struct GenericProgramEntry #
struct GenericProgramEntry {
pub:
specs string
used string
prefix string
declarations string
body string
literals string
metadata string
stamp string
}
GenericProgramEntry contains program-specific dependency specializations that remain valid across edits which do not change the program's generic ABI.
struct IncrementalProgramEntry #
struct IncrementalProgramEntry {
pub:
manifest string
body string
used string
specs string
prefix string
declarations string
tcc_declarations string
objects string
metadata string
stamp string
}
IncrementalProgramEntry contains a complete program body split into stable function sections plus the semantic/link metadata needed to regenerate only functions whose parsed bodies changed.
struct Manager #
struct Manager {
build_pseudo_values string
version_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) cgen_entry #
fn (m &Manager) cgen_entry(source_files []string) CgenEntry
cgen_entry returns the artifact paths for one stable program source 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_entry_with_metadata_cache #
fn (m &Manager) valid_entry_with_metadata_cache(module_name string, source_files []string, mut dependency_metadata map[string]string) ?Entry
valid_entry_with_metadata_cache reports whether both interface and object artifacts match their sources, reusing dependency metadata already observed during this compiler run.
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) valid_cgen #
fn (m &Manager) valid_cgen(source_files []string, generation_signature string, dependency_inputs map[string]string) ?CgenEntry
valid_cgen reports whether a whole-program C plan matches its program sources, imported module headers, and semantic generation signature.
fn (Manager) has_cgen_commit #
fn (m &Manager) has_cgen_commit(source_files []string) bool
has_cgen_commit reports whether an exact whole-program cache entry still has all payloads and its commit stamp, without validating their current inputs.
fn (Manager) cached_cgen_dependency_inputs #
fn (m &Manager) cached_cgen_dependency_inputs(source_files []string, generation_signature string, fixed_dependencies map[string]string, restored_prefixes []string) ?map[string]string
cached_cgen_dependency_inputs restores dependency records whose prefixes are allowed to vary, after validating the program sources, generation signature, and every fixed dependency supplied by the caller.
fn (Manager) cached_incremental_dependency_inputs #
fn (m &Manager) cached_incremental_dependency_inputs(source_files []string, declaration_signature string, generation_signature string, fixed_dependencies map[string]string, restored_prefixes []string) ?map[string]string
cached_incremental_dependency_inputs restores dependency records from a declaration-stable program snapshot after the main source bodies change.
fn (Manager) valid_generic_program #
fn (m &Manager) valid_generic_program(source_files []string, semantic_signature string, generation_signature string, dependency_inputs map[string]string) ?GenericProgramEntry
valid_generic_program reports whether cached dependency specializations match the program's type/call shape and all module cache inputs.
fn (Manager) write_cgen #
fn (m &Manager) write_cgen(source_files []string, generation_signature string, dependency_inputs map[string]string, source string, metadata string) !CgenEntry
write_cgen atomically commits a whole-program C plan and its generation metadata.
fn (Manager) write_generic_program #
fn (m &Manager) write_generic_program(source_files []string, semantic_signature string, generation_signature string, dependency_inputs map[string]string, specs string, used string, prefix string, declarations string, body string, literals string, metadata string) !GenericProgramEntry
write_generic_program atomically publishes dependency specialization metadata. The stamp is written last so readers cannot observe mixed payloads.
fn (Manager) valid_incremental_program #
fn (m &Manager) valid_incremental_program(source_files []string, declaration_signature string, generation_signature string, dependency_inputs map[string]string) ?IncrementalProgramEntry
valid_incremental_program restores function-level artifacts when declarations, compiler configuration, dependencies, and native inputs are unchanged.
fn (Manager) write_incremental_program #
fn (m &Manager) write_incremental_program(source_files []string, declaration_signature string, generation_signature string, dependency_inputs map[string]string, manifest string, body string, used string, specs string, prefix string, declarations string, tcc_declarations string, objects []string, metadata string) !IncrementalProgramEntry
write_incremental_program atomically publishes a function-level program snapshot. The stamp is the commit marker and is written after every payload.
fn (Manager) valid_cgen_prepared #
fn (m &Manager) valid_cgen_prepared(entry CgenEntry) ?CgenPreparedEntry
valid_cgen_prepared reports whether all pre-split C plan sources match entry's generation.
fn (Manager) write_cgen_prepared #
fn (m &Manager) write_cgen_prepared(entry CgenEntry, main_source string, tcc_source string, prefix_source string) !
write_cgen_prepared publishes pre-split C plan sources, committing their stamp last.
fn (Manager) valid_cgen_prepared_objects #
fn (m &Manager) valid_cgen_prepared_objects(entry CgenEntry, compile_signature string) ?[]string
valid_cgen_prepared_objects restores the object set for one effective compile signature.
fn (Manager) write_cgen_prepared_objects #
fn (m &Manager) write_cgen_prepared_objects(entry CgenEntry, compile_signature string, objects []string) !
write_cgen_prepared_objects publishes the object set for one effective compile signature.
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.
- Constants
- fn c_source_declares_types
- fn c_source_function_identifiers
- fn c_source_function_identifiers_with_status
- fn c_source_has_static_storage
- fn c_source_static_variable_identifiers
- fn c_source_type_declarations
- fn c_source_type_declarations_with_status
- fn c_source_type_identifiers
- fn c_source_typedef_identifiers
- fn c_sources_macro_identifiers_referencing
- fn cached_source_signature
- fn declaration_header
- fn file_metadata_signature
- fn file_signature
- fn header_needs_source
- fn header_signature
- fn materialize_cached_body_string_definitions
- fn module_header
- fn new_manager
- fn prune_unreferenced_static_string_definitions
- fn rewrite_cached_runtime_strings
- fn source_files_use_build_time_pseudo
- fn source_signature
- fn split_generated_c
- fn static_string_definitions
- fn without_duplicate_static_string_definitions
- struct CSplit
- struct CgenEntry
- struct CgenPreparedEntry
- struct Entry
- struct GenericProgramEntry
- struct IncrementalProgramEntry
- struct Manager
- fn ensure_dir
- fn entry
- fn object_entry
- fn cgen_entry
- fn valid_entry
- fn valid_entry_with_metadata_cache
- fn valid_header
- fn valid_object
- fn write_entry
- fn write_header
- fn valid_object_for_compile_signature
- fn valid_cgen
- fn has_cgen_commit
- fn cached_cgen_dependency_inputs
- fn cached_incremental_dependency_inputs
- fn valid_generic_program
- fn write_cgen
- fn write_generic_program
- fn valid_incremental_program
- fn write_incremental_program
- fn valid_cgen_prepared
- fn write_cgen_prepared
- fn valid_cgen_prepared_objects
- fn write_cgen_prepared_objects
- fn write_stamp