Files
ViperC/App/lib/Stub/StubMerger/__init__.vp
T

43 lines
2.0 KiB
Plaintext

from stdint import *
import memhub
# StubMerger - merges dependency stub declarations into the main IR (Phase2 core):
# collect {sha1}.stub.ll from temp, dedup, then insert after the target triple so cross-module symbols link.
# Global mbuddy pointer
_mbuddy: memhub.MemBuddy*
# Max includes SHA1 entries (for filtering)
define MAX_INCLUDES_SHA1 = 1024
# Stub/text read buffer size. 1MB is too small: text.ll files exceed 1MB, so a single
# truncated read drops trailing data (opt: "end of file in global variable name").
define STUB_READ_BUF_SIZE = 8388608
# Max includes entries
define MAX_INCLUDES = 1024
# Reachability worklist/processed buffer size. 8192 is too small: after scanning
# source_dir it holds all App imports plus BFS expansion, overflowing on append 82.
define REACH_WORKLIST_BUF = 65536
# Global SHA1 map store (in memory, no dependency on _sha1_map.txt).
# Filled after the Phase1 scan and shared by all functions.
_sha1_store_arr: bytes # SHA1 array (17 bytes each, MAX_INCLUDES entries)
_sha1_store_mod: bytes # Module-name array (64 bytes each, MAX_INCLUDES entries)
_sha1_store_rel: bytes # Relative-path array (256 bytes each, MAX_INCLUDES entries)
_sha1_store_incdir: bytes # Owning includes-root array (512 bytes each, MAX_INCLUDES entries, multi-includes)
_sha1_store_count: int # Entry count
# In-memory includes dependency store (no dependency on the deps.txt file).
# Before Phase B+ all includes are translated in declare_only mode; _BuildReachableSha1Set reads deps from here.
_includes_deps_sha1: bytes # SHA1 array (17 bytes each, MAX_INCLUDES entries)
_includes_deps_str: bytes # Dependency-string array (512 bytes each, MAX_INCLUDES entries)
_includes_deps_count: int # Entry count
# Max length of a single dependency string
define MAX_DEPS_STR_LEN = 512
# Max rel_path length
define MAX_REL_PATH_LEN = 256
# Max includes-root path length (absolute path, multi-includes)
define MAX_INC_DIR_LEN = 512