feat(viperc/diag): 报错定位到具体表达式 + 栈帧跟踪当前语句(方案 A+B)
A:报错节点是合成节点(lineno==0,如构造器内联出的参数赋值)时,优先用“正在翻译的实参 位置”兜底 → 报错精确指向调用处的表达式(如 `&_on_submit`),不再退回函数定义行。 - TypeGenBase 新增 CurArgFile/CurArgLine/CurArgCol 与 set_cur_arg() - CallGenLib 翻译实参前调用 set_cur_arg(当前文件, arg_node 位置) - TypeGenErr 兜底顺序改为:节点自身行号 → CurArg → 栈最内层帧 - 语句边界清空 CurArg,避免兜底串味到上一条语句的实参 B:栈帧跟踪“当前语句”位置(Python traceback 口径) - TypeGenBase.update_top_trace_position():更新最内层帧的 lineno/col - translate_stmt 每条语句推进时调用 → 报错时栈帧给出的是调用点所在语句,而非函数定义行 配合 A 即可得到“调用点 + 具体表达式”两帧。
This commit is contained in:
1 parent
70c271d2a4
commit
0678cc8c48
4 files changed
+41
-2
No files matched your search
@@ -221,6 +221,9 @@ novirtual class CallGenLib(CallGenBase.CallGenBase):
|
||||
if self.Gen.ExprGenBase._str_rejects_ptr_kind(cur) != 0:
|
||||
if VpiReader._vpi_param_annot_seg_is(sha1_buf, cls_nm, meth_nm, idx, "str") != 0 or VpiReader._vpi_param_annot_seg_is(sha1_buf, cls_nm, meth_nm, idx, "bytes") != 0:
|
||||
self.Gen.ExprGenBase.fail_if_str_annot_agg_ptr(cur, 1, arg_node)
|
||||
# 记录当前实参位置:被调者内部报错若是合成节点(无行号),可据此定位到这个实参表达式
|
||||
if arg_node is not None:
|
||||
self.Gen.TypeGenBase.set_cur_arg(self.Gen.TypeGenResolve.get_current_file(), arg_node.lineno, arg_node.col_offset + 1)
|
||||
node_v = self._coerce_arg_value_to_ty(pool, builder, node_v, tgt_ty, arg_node, trans, tpl_src)
|
||||
if new_head is None: new_head = node_v
|
||||
else: new_tail.Next = node_v
|
||||
|
||||
Reference in new issue
Block a user