chore(gen): c.CIf 家族移除报错覆盖 CElif/CElse/CEndif,注释口径统一为 cif
ExprGenName / CallGenDispatch 的「已删除拼写」守卫原本只认 CIf/CIfdef/CIfndef,现补齐 CElif/CElse/CEndif 六个(与 TPC 侧一致),报文同步;StmtGenCifMixin 的头注释、docstring 与状态注释把语句统一称作 cif,内部标记仍写作 c.@CIf 族。
This commit is contained in:
1 parent
2fb648d68a
commit
5c1b882169
3 files changed
+15
-15
No files matched your search
@@ -232,9 +232,9 @@ novirtual class CallGenDispatch(CallGenBase.CallGenBase):
|
||||
# it is evaluated there and never lowered as a runtime call.
|
||||
self.Gen.TypeGenErr.fatal_error(cl, "defined(NAME) is only valid inside a cif/celif condition; it cannot be used in a normal expression", "NameError")
|
||||
return None
|
||||
if bare_nm.id is not None and (string.strcmp(bare_nm.id, "CIf") == 0 or string.strcmp(bare_nm.id, "CIfdef") == 0 or string.strcmp(bare_nm.id, "CIfndef") == 0):
|
||||
# removed spellings (also covered for the bare-name form of c.CIf/c.CIfdef/c.CIfndef)
|
||||
self.Gen.TypeGenErr.fatal_error(cl, "c.CIf/c.CIfdef/c.CIfndef were removed; use the cif/celif/celse statements and the defined(NAME) predicate instead (e.g. `cif defined(NAME):` ... `celse:` ...)", "NameError")
|
||||
if bare_nm.id is not None and (string.strcmp(bare_nm.id, "CIf") == 0 or string.strcmp(bare_nm.id, "CIfdef") == 0 or string.strcmp(bare_nm.id, "CIfndef") == 0 or string.strcmp(bare_nm.id, "CElif") == 0 or string.strcmp(bare_nm.id, "CElse") == 0 or string.strcmp(bare_nm.id, "CEndif") == 0):
|
||||
# removed spellings (also covered for the bare-name form of the c.CIf family)
|
||||
self.Gen.TypeGenErr.fatal_error(cl, "c.CIf/c.CIfdef/c.CIfndef/c.CElif/c.CElse/c.CEndif were removed; use the cif/celif/celse statements and the defined(NAME) predicate instead (e.g. `cif defined(NAME):` ... `celse:` ...)", "NameError")
|
||||
return None
|
||||
if bare_nm.id is not None and string.strcmp(bare_nm.id, "__asm__") == 0:
|
||||
# translate_c_asm returns None for void output: set the hit flag so translate_call
|
||||
@@ -278,10 +278,10 @@ novirtual class CallGenDispatch(CallGenBase.CallGenBase):
|
||||
elif string.strcmp(func_name, "LInp") == 0 or string.strcmp(func_name, "LOut") == 0:
|
||||
# c.LInp/c.LOut standalone calls return 0 (only meaningful in c.LLVMIR f-strings)
|
||||
return mlirlite.ConstInt(pool, mlirlite.Int32(pool), 0, "0")
|
||||
elif string.strcmp(func_name, "CIf") == 0 or string.strcmp(func_name, "CIfdef") == 0 or string.strcmp(func_name, "CIfndef") == 0:
|
||||
# c.CIf/c.CIfdef/c.CIfndef were removed: report the replacement spelling.
|
||||
elif string.strcmp(func_name, "CIf") == 0 or string.strcmp(func_name, "CIfdef") == 0 or string.strcmp(func_name, "CIfndef") == 0 or string.strcmp(func_name, "CElif") == 0 or string.strcmp(func_name, "CElse") == 0 or string.strcmp(func_name, "CEndif") == 0:
|
||||
# The c.CIf-family spellings were removed: report the replacement.
|
||||
# (There is no runtime fallback: compile-time conditions use cif/celif/celse.)
|
||||
self.Gen.TypeGenErr.fatal_error(cl, "c.CIf/c.CIfdef/c.CIfndef were removed; use the cif/celif/celse statements and the defined(NAME) predicate instead (e.g. `cif defined(NAME):` ... `celse:` ...)", "NameError")
|
||||
self.Gen.TypeGenErr.fatal_error(cl, "c.CIf/c.CIfdef/c.CIfndef/c.CElif/c.CElse/c.CEndif were removed; use the cif/celif/celse statements and the defined(NAME) predicate instead (e.g. `cif defined(NAME):` ... `celse:` ...)", "NameError")
|
||||
return None
|
||||
elif is_coro_mod != 0 and string.strcmp(func_name, "coro_run") == 0:
|
||||
# coro.coro_run(frame): inline translation (resume loop until done, returns the ret slot).
|
||||
|
||||
@@ -269,9 +269,9 @@ novirtual class ExprGenName(ExprGenBase.ExprGenBase):
|
||||
# All lookup paths failed: fail-fast (NameError) instead of returning None and crashing
|
||||
# downstream. Exempt keywords/builtins (self/pool/None/_) whose absence is normal.
|
||||
if nm_id is None: return None
|
||||
if string.strcmp(nm_id, "CIf") == 0 or string.strcmp(nm_id, "CIfdef") == 0 or string.strcmp(nm_id, "CIfndef") == 0:
|
||||
# The c.CIf/c.CIfdef/c.CIfndef spellings were removed; report the replacement.
|
||||
self.Gen.TypeGenErr.fatal_error(node, "c.CIf/c.CIfdef/c.CIfndef were removed; use the cif/celif/celse statements and the defined(NAME) predicate instead (e.g. `cif defined(NAME):` ... `celse:` ...)", "NameError")
|
||||
if string.strcmp(nm_id, "CIf") == 0 or string.strcmp(nm_id, "CIfdef") == 0 or string.strcmp(nm_id, "CIfndef") == 0 or string.strcmp(nm_id, "CElif") == 0 or string.strcmp(nm_id, "CElse") == 0 or string.strcmp(nm_id, "CEndif") == 0:
|
||||
# The c.CIf-family spellings were removed; report the replacement.
|
||||
self.Gen.TypeGenErr.fatal_error(node, "c.CIf/c.CIfdef/c.CIfndef/c.CElif/c.CElse/c.CEndif were removed; use the cif/celif/celse statements and the defined(NAME) predicate instead (e.g. `cif defined(NAME):` ... `celse:` ...)", "NameError")
|
||||
return None
|
||||
if string.strcmp(nm_id, "self") == 0 or string.strcmp(nm_id, "pool") == 0 or string.strcmp(nm_id, "true") == 0 or string.strcmp(nm_id, "false") == 0 or string.strcmp(nm_id, "None") == 0 or string.strcmp(nm_id, "match") == 0 or string.strcmp(nm_id, "_") == 0:
|
||||
return None
|
||||
|
||||
@@ -18,15 +18,15 @@ import lib.core.Gen.GenApi as GenApi
|
||||
|
||||
|
||||
# ============================================================
|
||||
# StmtGenCifMixin - compile-time CIf eval + NewXxxHandle factory
|
||||
# StmtGenCifMixin - compile-time cif eval + NewXxxHandle factory
|
||||
|
||||
|
||||
# ============================================================
|
||||
# StmtGenCifMixin - CIf eval + factory (lowest base class)
|
||||
# StmtGenCifMixin - cif eval + factory (lowest base class)
|
||||
novirtual class StmtGenCifMixin:
|
||||
"""Compile-time CIf evaluation and NewXxxHandle factory (lowest base class)."""
|
||||
"""Compile-time cif evaluation and NewXxxHandle factory (lowest base class)."""
|
||||
|
||||
# --- compile-time CIf eval state (was HandlesIf._g_cif_eval_ok) ---
|
||||
# --- compile-time cif eval state (was HandlesIf._g_cif_eval_ok) ---
|
||||
# use 8-byte type: Mixin standalone and Generator composite layouts must align
|
||||
Gen: Generator.Generator*
|
||||
CifEvalOk: sizet
|
||||
@@ -39,7 +39,7 @@ novirtual class StmtGenCifMixin:
|
||||
DiagStmtCount: int
|
||||
|
||||
# ============================================================
|
||||
# Cluster B: compile-time CIf macro eval (migrated from HandlesIf.vp)
|
||||
# Cluster B: compile-time cif macro eval (migrated from HandlesIf.vp)
|
||||
|
||||
def _is_cif_attr(self, attr: str) -> int:
|
||||
"""Check the internal cif marker attribute name produced by the parser (c.@CIf family).
|
||||
@@ -54,7 +54,7 @@ novirtual class StmtGenCifMixin:
|
||||
return 0
|
||||
|
||||
def _is_cif_call(self, node: ast.AST*) -> int:
|
||||
"""Check whether test is a c.CIf-family call (or a bare CIf-family call)."""
|
||||
"""Check whether test is a cif marker call (c.@CIf family, or a bare @CIf-family name)."""
|
||||
if node is None or node.kind() != ast.ASTKind.Call: return 0
|
||||
cl: ast.Call* = ast.Call*(node)
|
||||
if cl.func is None: return 0
|
||||
|
||||
Reference in new issue
Block a user