fix(viperc): 浮点常量按目标类型/声明宽度直接出 f32,不再先出 double
- 浮点字面量在 f32 目标(float(1.5) / x: float = 1.5 / f32 形参)下直接物化 f32 常量, 负号折叠(-c)同口径;去掉旧的「f64 常量 + fptrunc」 - CDefine 浮点条目记录宽度种类(1=f64 / 2=f32):define PI: float = ... 的使用处 直接出 f32 常量,与 f32 字面量混算不再被提升成 double(现场 33 处 cvtss2sd) - 本模块注册 / pyi·vpi 跨模块重解析 / xmod 缓存三处都按注解裁决宽度,保持跨模块一致
This commit is contained in:
1 parent
3a687db0bb
commit
508428bbc9
12 files changed
+202
-29
No files matched your search
@@ -192,9 +192,17 @@ def cdefine_decl_bits(pool: memhub.MemBuddy*, annot: ast.AST*, value_node: ast.A
|
||||
|
||||
|
||||
# ---------------- register_cdefine_double (delegates to TypeGenCDef.register_cdefine_double) ----------------
|
||||
def register_cdefine_double(pool: memhub.MemBuddy*, name: str, value: double):
|
||||
"""Delegate to gen.register_cdefine_double"""
|
||||
if _g_gen is not None: _g_gen.TypeGenCDef.register_cdefine_double(pool, name, value)
|
||||
def register_cdefine_double(pool: memhub.MemBuddy*, name: str, value: double, is_f32: int = 0):
|
||||
"""Delegate to gen.register_cdefine_double (is_f32: 1=float 声明,0=double)"""
|
||||
if _g_gen is not None: _g_gen.TypeGenCDef.register_cdefine_double(pool, name, value, is_f32)
|
||||
|
||||
|
||||
# ---------------- cdefine_decl_float_bits (delegates to AssignGenMixin.cdefine_decl_float_bits) ----------------
|
||||
def cdefine_decl_float_bits(pool: memhub.MemBuddy*, annot: ast.AST*) -> int:
|
||||
"""define 声明的**浮点**宽度裁决:注解显式写了 float → 1(f32),double/未写 → 0。
|
||||
跨模块(.vpi 重解析 define 的 AST)注册必须用它,否则使用方把 f32 常量当 double 物化。"""
|
||||
if _g_gen is not None: return _g_gen.AssignGen.cdefine_decl_float_bits(pool, annot)
|
||||
return 0
|
||||
|
||||
|
||||
# ---------------- is_cdefine_annotation (delegates to AssignGenMixin.is_cdefine_annotation) ----------------
|
||||
|
||||
Reference in new issue
Block a user