chore(comments): Test 仓注释英文化(R11)
把 81 个 .vp 文件的中文 # 注释与三引号文档串改写为简洁英文,每个连续注释块 <=2 行;运行时中文字符串字面量(testcheck.begin/print 等用户可见消息)保持原样。骨架比对 HEAD 与工作区 112 文件漂移 0,全量 77/77 顺序回归通过。
This commit is contained in:
1 parent
aa5a7e7250
commit
ee6461be46
81 files changed
+1231
-1925
No files matched your search
+13
-24
@@ -4,15 +4,8 @@ import stdio
|
||||
import stdlib
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 指针操作符全形态自检(TPC 侧)
|
||||
#
|
||||
# 解析实况(vast_c.c ParseSimpleStmt → ParseExprList + SetStoreContext):
|
||||
# `*p` 由 ParseFactor 产出 UnaryOp(op=Deref),SetStoreContext **不改 UnaryOp**
|
||||
# ⇒ `*p = v` 的赋值目标就是 UnaryOp(Deref)(ctx 仍是 Load),与读侧同形。
|
||||
# 若编译器目标分派没有 UnaryOp 分支,整条语句会被静默丢弃(不落盘、不报错),
|
||||
# 本程序即用于钉死这一点:每个形态都必须真的写进内存。
|
||||
# ============================================================
|
||||
# ===== Pointer operator full-form self-check (TPC side) =====
|
||||
# `*p = v` targets UnaryOp(Deref); without a dispatch branch it is silently dropped.
|
||||
|
||||
def MakePair() -> tuple[int, int]:
|
||||
return 1, 2
|
||||
@@ -25,13 +18,13 @@ def main() -> int:
|
||||
stdio.printf("FAIL: malloc\n")
|
||||
return 9
|
||||
|
||||
# 形态 A:*p = v
|
||||
# Form A: *p = v
|
||||
*buf = 7
|
||||
if buf[0] != 7:
|
||||
stdio.printf("FAIL A *p = v : buf[0]=%llu(期望 7)\n", buf[0])
|
||||
fails += 1
|
||||
|
||||
# 形态 B:*p = *q
|
||||
# Form B: *p = *q
|
||||
q: uint64* = buf + 1
|
||||
*q = 99
|
||||
*buf = *q
|
||||
@@ -39,7 +32,7 @@ def main() -> int:
|
||||
stdio.printf("FAIL B *p = *q : buf[0]=%llu(期望 99)\n", buf[0])
|
||||
fails += 1
|
||||
|
||||
# 形态 C:&x 取址,*px = v
|
||||
# Form C: &x address-of, *px = v
|
||||
x: uint64 = 0
|
||||
y: uint64 = 5
|
||||
px: uint64* = &x
|
||||
@@ -48,25 +41,25 @@ def main() -> int:
|
||||
stdio.printf("FAIL C *px = v : x=%llu(期望 11)\n", x)
|
||||
fails += 1
|
||||
|
||||
# 形态 D:*&x = *&y
|
||||
# Form D: *&x = *&y
|
||||
*&x = *&y
|
||||
if x != 5:
|
||||
stdio.printf("FAIL D *&x = *&y : x=%llu(期望 5)\n", x)
|
||||
fails += 1
|
||||
|
||||
# 形态 E(对照):下标写 p[i] = v
|
||||
# Form E (control): subscript write p[i] = v
|
||||
buf[0] = 123
|
||||
if buf[0] != 123:
|
||||
stdio.printf("FAIL E p[0] = v : buf[0]=%llu(期望 123)\n", buf[0])
|
||||
fails += 1
|
||||
|
||||
# 形态 F:AugAssign 目标 *p += v
|
||||
# Form F: AugAssign target *p += v
|
||||
*buf += 5
|
||||
if buf[0] != 128:
|
||||
stdio.printf("FAIL F *p += v : buf[0]=%llu(期望 128)\n", buf[0])
|
||||
fails += 1
|
||||
|
||||
# 形态 G1(对照):Tuple 目标 a, b = f()
|
||||
# Form G1 (control): tuple target a, b = f()
|
||||
a: int = 0
|
||||
b: int = 0
|
||||
a, b = MakePair()
|
||||
@@ -74,7 +67,7 @@ def main() -> int:
|
||||
stdio.printf("FAIL G1 a, b = f() : a=%d b=%d(期望 1/2)\n", a, b)
|
||||
fails += 1
|
||||
|
||||
# 形态 G2:List 目标 [c, d] = f()
|
||||
# Form G2: list target [c, d] = f()
|
||||
cc: int = 0
|
||||
dd: int = 0
|
||||
[cc, dd] = MakePair()
|
||||
@@ -82,18 +75,14 @@ def main() -> int:
|
||||
stdio.printf("FAIL G2 [c, d] = f() : c=%d d=%d(期望 1/2)\n", cc, dd)
|
||||
fails += 1
|
||||
|
||||
# 形态 H:值位置的 *p(调用实参 f(*p))——Starred(Load)
|
||||
# Form H: *p in value position (call arg f(*p)) -- Starred(Load)
|
||||
got: int = stdio.printf("INFO H f(*p) : %llu(期望 128)\n", *buf)
|
||||
if got < 0:
|
||||
stdio.printf("FAIL H f(*p) : printf 返回 %d\n", got)
|
||||
fails += 1
|
||||
|
||||
# 形态 I:memhub 实际用的「两步式读块头」(关键回归点)
|
||||
# hd1 = *((uint64*)(blk)) —— 直接读
|
||||
# hd2 = uint64(t.CPtr(*((uint64*)(blk)))) —— 两步式;注意 `*((...))` 位于
|
||||
# t.CPtr( ) 的**实参位置** ⇒ 解析为 Starred(Load),旧 TPC 在这一形态落到
|
||||
# 末尾兜底 `return i32 0` ⇒ t.CPtr(0)=NULL ⇒ hd2==0(内存里明明是 0x1234)
|
||||
# 这正是 OOM 报告里 `hdr=0x9 / hdr2=0x0` 的成因。
|
||||
# Form I: the two-step block-header read memhub uses (key regression point).
|
||||
# `*((...))` inside t.CPtr() args parses as Starred(Load); old TPC returned 0.
|
||||
w: uint64 = 0
|
||||
pw: uint64* = &w
|
||||
*pw = 0x1234
|
||||
|
||||
Reference in new issue
Block a user