支持 tls 关键字,全面准备清退 t, c

This commit is contained in:
TermiNexus committed 2026-10-17 23:40:06 +08:00
1 parent 6e17716a69
commit 3242560d02
74 files changed
+524 -576

No files matched your search

-1
View File
@@ -1,6 +1,5 @@
import lib.core.Gen.GenApi as GenApi
import lib.core.VLogger as VLogger
import t, c
from stdint import *
import ast
import string
-1
View File
@@ -1,7 +1,6 @@
import lib.core.Gen.GenApi as GenApi
import lib.core.Gen.GenTypes as GenTypes
import lib.core.CompilerFactory as CompilerFactory
import t, c
from stdint import *
import ast
import string
+11 -12
View File
@@ -1,5 +1,4 @@
import lib.core.Gen.GenApi as GenApi
import t, c
from stdint import *
import memhub
import string
@@ -197,9 +196,9 @@ def _BuildReachableSha1Set(mb: memhub.MemBuddy*, source_dir: str, temp_dir: str,
# 2b. --traceback: force the traceback runtime module into the reachable set (TPC: used_includes.add('traceback')).
# Its Install() symbol and the @llvm.global_ctors ctor come only from compiling this module, so a missing file is fail-fast.
if BuildPipeline._traceback_mode != 0:
tb_abs: t.CPtr = stdlib.malloc(8)
tb_rel: t.CPtr = stdlib.malloc(8)
tb_inc: t.CPtr = stdlib.malloc(8)
tb_abs: rawptr = stdlib.malloc(8)
tb_rel: rawptr = stdlib.malloc(8)
tb_inc: rawptr = stdlib.malloc(8)
tb_found: int = -1
if tb_abs is not None and tb_rel is not None and tb_inc is not None:
tb_abs_slot: sizet* = (sizet*)(tb_abs)
@@ -230,7 +229,7 @@ def _BuildReachableSha1Set(mb: memhub.MemBuddy*, source_dir: str, temp_dir: str,
processed[0] = '\0'
proc_len: sizet = 0
reachable_count: int = 0
wl_pos: t.CPtr = stdlib.malloc(8)
wl_pos: rawptr = stdlib.malloc(8)
if wl_pos is None:
stdlib.free(worklist)
stdlib.free(processed)
@@ -289,9 +288,9 @@ def _BuildReachableSha1Set(mb: memhub.MemBuddy*, source_dir: str, temp_dir: str,
continue
# includes: resolve on demand via the filesystem (unreferenced includes are never touched)
out_abs: t.CPtr = stdlib.malloc(8)
out_rel: t.CPtr = stdlib.malloc(8)
out_inc: t.CPtr = stdlib.malloc(8)
out_abs: rawptr = stdlib.malloc(8)
out_rel: rawptr = stdlib.malloc(8)
out_inc: rawptr = stdlib.malloc(8)
if out_abs is None or out_rel is None or out_inc is None:
if out_abs is not None: stdlib.free(out_abs)
if out_rel is not None: stdlib.free(out_rel)
@@ -299,10 +298,10 @@ def _BuildReachableSha1Set(mb: memhub.MemBuddy*, source_dir: str, temp_dir: str,
stdlib.free(mod_buf)
continue
# Defensive init of the output slots (the success path always writes all). The slot union must use (sizet*):
# t.CPtr* collapses to t.CPtr and [0] becomes a 1-byte access, truncating the pointer (0x2e crash root cause).
abs_slot: sizet* = (sizet*)(out_abs)
rel_slot: sizet* = (sizet*)(out_rel)
inc_slot: sizet* = (sizet*)(out_inc)
# rawptr* collapses to rawptr and [0] becomes a 1-byte access, truncating the pointer (0x2e crash root cause).
abs_slot: sizet* = sizet*(out_abs)
rel_slot: sizet* = sizet*(out_rel)
inc_slot: sizet* = sizet*(out_inc)
abs_slot[0] = 0
rel_slot[0] = 0
inc_slot[0] = 0
@@ -1,4 +1,3 @@
import t, c
from stdint import *
import memhub
import string
-1
View File
@@ -1,5 +1,4 @@
import lib.core.Gen.GenApi as GenApi
import t, c
from stdint import *
import memhub
import string
@@ -1,4 +1,3 @@
import t, c
from stdint import *
import memhub
import string
+3 -21
View File
@@ -1,29 +1,11 @@
import t, c
from stdint import *
import memhub
import string
import stdlib
import mlirlite
import win32.win32file as win32file
import win32.win32base as win32base
import win32.fileio as fileio
import viperlib
import sys
import ast
import lib.core.VLogger as VLogger
import lib.core.IncludesScanner as IncludesScanner
import lib.core.Gen.Translator as HandlesTranslator
import lib.Phase.BuildPipeline as BuildPipeline
import lib.Stub.StubGen.VpiReader as VpiReader
import lib.Projectrans.Utils as Utils
import lib.Projectrans.Config as Config
import lib.Stub.StubMerger.StubMergerCollect as StubMergerCollect
import lib.Stub.StubMerger.StubMergerStore as StubMergerStore
import lib.Stub.StubMerger.StubMergerIR as StubMergerIR
import lib.Stub.StubMerger.StubMergerBuild as StubMergerBuild
import lib.Stub.StubMerger as StubMerger
# StubMergerTopo - reverse-topological sort of reachable includes (dependencies first).
# Functions live in this module; cross-module globals are accessed via StubMerger._xxx.
@@ -33,9 +15,9 @@ import lib.Stub.StubMerger as StubMerger
def BuildTopoSortedIndices(store_count: int, store_sha1_arr: bytes, store_mod_arr: bytes, reachable_set: bytes, reachable_count: int, sorted_idx: sizet*) -> int:
"""Reverse-topologically sort reachable includes (dependencies first); store indices go to sorted_idx."""
if store_count <= 0 or store_sha1_arr is None or store_mod_arr is None or sorted_idx is None: return 0
indegree: sizet* = (sizet*)(stdlib.malloc(8 * (store_count + 1)))
queue: sizet* = (sizet*)(stdlib.malloc(8 * (store_count + 1)))
rel_idx: sizet* = (sizet*)(stdlib.malloc(8 * (store_count + 1)))
indegree: sizet* = sizet*(stdlib.malloc(8 * (store_count + 1)))
queue: sizet* = sizet*(stdlib.malloc(8 * (store_count + 1)))
rel_idx: sizet* = sizet*(stdlib.malloc(8 * (store_count + 1)))
if indegree is None or queue is None or rel_idx is None:
if indegree is not None: stdlib.free(indegree)
if queue is not None: stdlib.free(queue)
-17
View File
@@ -1,22 +1,5 @@
import t, c
from stdint import *
import memhub
import string
import stdlib
import mlirlite
import win32.win32file as win32file
import win32.win32base as win32base
import win32.fileio as fileio
import viperlib
import sys
import ast
import lib.core.VLogger as VLogger
import lib.core.IncludesScanner as IncludesScanner
import lib.core.Gen.Translator as HandlesTranslator
import lib.Phase.BuildPipeline as BuildPipeline
import lib.Stub.StubGen.VpiReader as VpiReader
import lib.Projectrans.Utils as Utils
import lib.Projectrans.Config as Config
# StubMerger - merges dependency stub declarations into the main IR (Phase2 core):