Skip to content

ctron.plugin

编译器插件接口包 v1(T52;§8.3/§10.6 插件扩展点)

插件 = 普通 Ctron 包:derive 插件约定入口 pub fn ctron_derive(input: DeriveInput) -> Str (返回合成 Ctron 源码文本);lint 插件约定入口 pub fn ctron_lint(unit: LintUnit) -> List[LintDiag] (返回 W9xxx 诊断,码须在插件清单 plugin 块 codes 中先进表)。 编译器在本包声明与自身值镜像间做字段名序核对,不符 = E5060.iface(fail-closed)。

v1 冻结面:加字段 = 破坏性扩展,须走修订程序(设计案 §2.2: docs/superpowers/specs/2026-10-03-t52-plugin-sandbox.md)。

pub struct

struct DeriveField

Field Type
name Str
ty Str
mutable Bool

struct DeriveInput

Field Type
type_name Str
fields List[DeriveField]

struct LintFn

Field Type
name Str
line I32
params List[Str]
ret Str
attrs List[Str]
stmts I32
depth I32

struct LintUnit

LintFn.line:v1 恒 0(fn 节点无行号戳,p_fn2 不 nstamp;anm/stamp 尾槽序约束
下加戳需动 p_file 各 fn 分支,列 v2 与 T18 列级 span 同族)——插件诊断以
msg 携带 fn name 定位;LintDiag.line 同步回传,诊断渲染保留行位

Field Type
module Str
fns List[LintFn]

struct LintDiag

Field Type
code Str
line I32
msg Str