Skip to main content

JavaAst

Struct JavaAst 

Source
pub struct JavaAst {
    pub facts: Option<JavaFacts>,
    pub const_fields: HashMap<String, JavaId>,
    pub const_scalars: HashSet<String>,
    pub noop_private_methods: HashMap<String, HashMap<usize, Vec<NoopCandidate>>>,
    pub field_types: HashMap<String, JType>,
    pub unit_shadows_lang: bool,
    pub raw_generic_names: HashSet<String>,
    pub final_fields: HashSet<String>,
    pub current_return_ty: Option<JType>,
    pub inline_methods: HashMap<String, (Vec<String>, JavaId, String)>,
    pub unit_string_identity: bool,
    /* private fields */
}

Fields§

§facts: Option<JavaFacts>

外部事实(前端注入;编译单元生命周期)。None = 纯源码保守模式。

§const_fields: HashMap<String, JavaId>

类级常量字段(static final 且字面量/字面量数组初始化、无写、无同名局部) → 初始化节点。由 simplify_unit 填充(跨方法解密的字符串表)。

§const_scalars: HashSet<String>

可安全做 VarRef → 字面量传播的常量字段名(标量字面量且声明类型 与字面量种类精确匹配——过载解析/常量池身份不受影响)。 数组常量不进(只走下标折叠,整表引用不复制)。

§noop_private_methods: HashMap<String, HashMap<usize, Vec<NoopCandidate>>>

空私有方法(no-op 调用清理用):名字 → 元数 → 同名同元数全部 候选(参数类型表 + 是否 private 空体)。调用点做类型适用性消解 (唯一适用者且为 private 空体 → no-op)。同名任意方法含 varargs → 该名整体放弃(varargs 可吸收任意元数)。由 simplify_unit 填充 (–dead-code 门控)。

§field_types: HashMap<String, JType>

字段声明类型表(名字 → JType;同名二见移除)——调用点实参静态 类型解析用(VarRef 解析不到局部时查字段)。collect_unit_consts 填充。

§unit_shadows_lang: bool

本单元声明了名为 String/StringBuilder 的类型(遮蔽 java.lang—— new String(“x”) 折叠/字符串链折叠在该单元全部拒绝。探针 T4a/b 抓获:class String{…} 同文件时 new String 折叠产出不可编译或 静默错值)。collect_unit_consts 每轮重算。

§raw_generic_names: HashSet<String>

已知为泛型的类型简单名(单元内带 ty_params 的类型 + 常见 JDK 泛型库类)。raw 引用(无类型实参)这些名字时,接收位传播 改变成员解析(raw 擦除 vs 泛型形参——CAP#1 编译错)。

§final_fields: HashSet<String>

final 字段名集合(同名二见移除——保守)。static_exec 截断守卫 用:前缀字段写被 rest 再赋值时,仅 final 才放弃(非 final 的 材料化写是死写,语义恒等、可编译)。

§current_return_ty: Option<JType>

当前正在简化的方法返回类型(simplify_member 设置)——窄类型 return 的常量收窄守卫用(if→三元合并前检查)。None = 非方法体。

§inline_methods: HashMap<String, (Vec<String>, JavaId, String)>

可内联的单 return 方法:名字 → (参数名表, 返回表达式节点, 声明 该方法的类的简单名)。owner 供 const_method_inline 的归属守卫: 限定调用的接收者类名必须与之一致——名字匹配不判归属会把 JDK 的 Integer.valueOf 当本类同名方法内联。由 simplify_unit 填充(解密 helper:d(0) → 方法体)。

§unit_string_identity: bool

单元级 String 身份比较存在标志(collect_unit_consts 每轮重算)。 new String(lit) 解包为池化字面量会翻转任何 == 观察点——字段 init 解包的观察点在其他方法里(InputNoWhitespaceAfterWithEmoji 抓获 合成证实:a == “hello” false→true),单根扫描看不见 → 单元级守卫。

Implementations§

Source§

impl JavaAst

Source

pub fn new() -> Self

Source

pub fn clone_node(&mut self, id: JavaId, children: Vec<JavaId>) -> JavaId

以 node 的负载 + 指定 children 构造新节点(深拷贝/替换用)。

Source

pub fn node(&self, id: JavaId) -> &Node

Source

pub fn data(&self, id: JavaId) -> &NodeData

Source

pub fn kind(&self, id: JavaId) -> NodeKind

固有方法(与 Lang trait 同名;供不依赖引擎的下游使用,如 printer)。

Source

pub fn node_count(&self) -> usize

arena 节点总数(诊断/深度测量用)。

Source

pub fn children(&self, id: JavaId) -> &[JavaId]

Source

pub fn block(&mut self, stmts: Vec<JavaId>) -> JavaId

Source

pub fn empty(&mut self) -> JavaId

Source

pub fn expr_stmt(&mut self, e: JavaId) -> JavaId

Source

pub fn var_decl( &mut self, name: &str, ty: JType, init: Option<JavaId>, ) -> JavaId

Source

pub fn var_decl_final( &mut self, name: &str, ty: JType, init: Option<JavaId>, final_mod: bool, ) -> JavaId

final 局部声明(JLS 4.12.4:case 标签常量的必要条件—— final 局部删除曾致 case ARRAY_BOUND: 失去常量性不可编译, LargeFile.java 抓获)。

Source

pub fn assign(&mut self, target: JavaId, value: JavaId) -> JavaId

Source

pub fn assign_op(&mut self, op: BinOp, target: JavaId, value: JavaId) -> JavaId

Source

pub fn if_(&mut self, cond: JavaId, then: JavaId, els: Option<JavaId>) -> JavaId

Source

pub fn while_(&mut self, cond: JavaId, body: JavaId) -> JavaId

Source

pub fn do_while(&mut self, body: JavaId, cond: JavaId) -> JavaId

Source

pub fn for_( &mut self, inits: Vec<JavaId>, cond: Option<JavaId>, steps: Vec<JavaId>, body: JavaId, ) -> JavaId

Source

pub fn for_each( &mut self, name: &str, ty: JType, iterable: JavaId, body: JavaId, ) -> JavaId

Source

pub fn yield_(&mut self, expr: JavaId) -> JavaId

Source

pub fn ret(&mut self, value: Option<JavaId>) -> JavaId

Source

pub fn break_(&mut self, label: Option<&str>) -> JavaId

Source

pub fn continue_(&mut self, label: Option<&str>) -> JavaId

Source

pub fn throw(&mut self, e: JavaId) -> JavaId

Source

pub fn try_( &mut self, resources: Vec<JavaId>, try_block: JavaId, catches: Vec<JavaId>, finally: Option<JavaId>, ) -> JavaId

Source

pub fn catch_(&mut self, ty_raw: &str, name: &str, block: JavaId) -> JavaId

Source

pub fn synchronized(&mut self, lock: JavaId, block: JavaId) -> JavaId

Source

pub fn switch_(&mut self, subject: JavaId, cases: Vec<JavaId>) -> JavaId

Source

pub fn case_( &mut self, labels: Vec<JavaId>, is_default: bool, arrow: bool, stmts: Vec<JavaId>, ) -> JavaId

Source

pub fn label(&mut self, name: &str, stmt: JavaId) -> JavaId

Source

pub fn assert_(&mut self, cond: JavaId, msg: Option<JavaId>) -> JavaId

Source

pub fn raw(&mut self, text: &str) -> JavaId

Source

pub fn bin(&mut self, op: BinOp, l: JavaId, r: JavaId) -> JavaId

Source

pub fn un(&mut self, op: UnOp, e: JavaId) -> JavaId

Source

pub fn call(&mut self, callee: JavaId, args: Vec<JavaId>) -> JavaId

Source

pub fn member(&mut self, obj: JavaId, name: &str) -> JavaId

Source

pub fn index(&mut self, arr: JavaId, idx: JavaId) -> JavaId

Source

pub fn cast(&mut self, ty: JType, e: JavaId) -> JavaId

Source

pub fn paren(&mut self, e: JavaId) -> JavaId

Source

pub fn ternary(&mut self, c: JavaId, a: JavaId, b: JavaId) -> JavaId

Source

pub fn new_(&mut self, ty: JType, args: Vec<JavaId>) -> JavaId

Source

pub fn new_anon( &mut self, ty: JType, args: Vec<JavaId>, body_raw: String, ) -> JavaId

Source

pub fn new_array( &mut self, ty: JType, dims: u16, sized: u16, sizes: Vec<JavaId>, init: Option<JavaId>, ) -> JavaId

Source

pub fn group(&mut self, stmts: Vec<JavaId>) -> JavaId

合成分组(无作用域)。

Source

pub fn array_lit(&mut self, elems: Vec<JavaId>) -> JavaId

Source

pub fn var(&mut self, name: &str) -> JavaId

Source

pub fn lit(&mut self, l: Lit) -> JavaId

Source

pub fn this(&mut self) -> JavaId

Source

pub fn super_(&mut self) -> JavaId

Source

pub fn instance_of( &mut self, e: JavaId, ty: JType, bind: Option<&str>, ) -> JavaId

Source

pub fn lambda(&mut self, params_raw: &str, body: JavaId) -> JavaId

Source

pub fn method_ref(&mut self, receiver: JavaId, name: &str) -> JavaId

Source

pub fn method_call( &mut self, obj: JavaId, name: &str, args: Vec<JavaId>, ) -> JavaId

obj.name(args…) 调用。

Source

pub fn plain_call(&mut self, name: &str, args: Vec<JavaId>) -> JavaId

裸方法调用 name(args…)(隐式 this / static)。

Source

pub fn var_type(&self, id: JavaId) -> Option<&JType>

作用域解析后的 VarRef 类型(prepare 之后有效)。

Source

pub fn any_string_identity(&self, roots: &[JavaId]) -> bool

root 子树内是否存在「两侧都可能为 String」的 ==/!=(引用比较)? 折叠守卫用:new String(lit)/常量链等产出池化字面量会改变 == 语义。 结果按 (root, prepare 代次) 缓存——prepare 每次改树后清空, 首次查询全扫一次,同轮内所有守卫调用复用。 多根扫描:任一根存在 String 身份比较。

Source

pub fn has_string_identity_compare(&self, root: JavaId) -> bool

Source

pub fn set_param_scope(&mut self, params: &[(String, JType)])

设置当前方法的参数类型表(作为根作用域参与解析)。

Source

pub fn is_param_name(&self, name: &str) -> bool

名字是否为当前方法参数(虚拟执行的字段写守卫——参数写不得 误记为字段写)。

Source

pub fn set_facts(&mut self, facts: JavaFacts)

名字键 → 名字反查(虚拟执行的字段写材料化)。 注入外部事实(前端 IR 权威陈述)。编译单元生命周期——换单元 前必须 clear_facts(simplify_unit / simplify_unit_with_facts 门面自动管理)。重复注入覆盖。

Source

pub fn clear_facts(&mut self)

清空外部事实(回到纯源码保守模式)。

Source

pub fn name_of_key(&self, k: u32) -> Option<String>

Source

pub fn clear_param_scope(&mut self)

Source§

impl JavaAst

Source

pub fn intern_sym(&mut self, name: &str) -> Sym

名字 → 实化键(持久表,只增;同名字恒同键)。 intern 名字 → Sym(复用 name_intern 表 + sym_names 向量)。

Source

pub fn sn(&self, sym: Sym) -> &str

Sym → 名字原文。

Trait Implementations§

Source§

impl Debug for JavaAst

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for JavaAst

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Lang for JavaAst

Source§

fn prepare(&mut self, root: JavaId)

重建缓存:

  1. 效果表——arena 按升序扫描(child index < parent index 不变量);
  2. 变量类型表——从 root 做作用域栈遍历。
Source§

type Id = JavaId

稳定节点句柄(通常是 Copy 的索引 newtype)。
Source§

type NameKey = u32

名字等价类句柄(Java:u32 intern id)。区域扫描的全部名字比较 走它——语言侧应保证同名字同键、比较为整数等值(无字符串 memcmp)。
Source§

fn kind(&self, id: JavaId) -> NodeKind

Source§

fn children(&self, id: JavaId) -> &[JavaId]

Source§

fn set_child(&mut self, parent: JavaId, index: usize, new: JavaId)

把 parent 的第 index 个孩子替换为 new。
Source§

fn remove_child(&mut self, parent: JavaId, index: usize)

删除 parent 的第 index 个孩子。
Source§

fn splice( &mut self, node: JavaId, index: usize, remove: usize, insert: Vec<JavaId>, )

从 node 的第 index 个孩子开始删 remove 个、插入 insert。
Source§

fn build_return(&mut self, value: Option<JavaId>) -> JavaId

Source§

fn build_block(&mut self, stmts: Vec<JavaId>) -> JavaId

Source§

fn build_unary(&mut self, op: UnOp, operand: JavaId) -> JavaId

Source§

fn build_bool(&mut self, v: bool) -> JavaId

Source§

fn build_int(&mut self, v: i64, long: bool) -> JavaId

构造整数/long 字面量(常量折叠产物)。long 为 true 时带 L 语义。
Source§

fn build_str(&mut self, s: &str) -> JavaId

构造字符串字面量(字符串常量折叠产物)。
Source§

fn build_char(&mut self, c: char) -> JavaId

构造字符字面量(部分求值产物:(char)('a'+1) → ‘b’)。
Source§

fn build_bin(&mut self, op: BinOp, l: JavaId, r: JavaId) -> JavaId

构造二元运算节点(常量折叠 / 取反重写等需要重建比较运算时使用)。
Source§

fn build_ternary(&mut self, c: JavaId, a: JavaId, b: JavaId) -> JavaId

构造三元表达式 c ? a : b(if→ternary 归并)。
Source§

fn build_assign(&mut self, target: JavaId, value: JavaId) -> JavaId

构造简单赋值 target = value(if→三元赋值归并)。
Source§

fn fold_lit_bin(&mut self, op: BinOp, l: JavaId, r: JavaId) -> Option<JavaId>

字面量二元折叠:算术/位运算/移位(+ - * / % << >> >>> & | ^) 与字符串拼接。操作数为字面量节点 id;返回折叠产物节点。
Source§

fn fold_lit_cmp(&mut self, op: BinOp, l: JavaId, r: JavaId) -> Option<bool>

字面量比较折叠(如 1 < 2)。可比较的字面量种类与字符串比较 语义(引用比较 vs 值比较)由语言侧决定;返回布尔结果。
Source§

fn fold_lit_neg(&mut self, v: i64, wide: bool) -> Option<i64>

负数值字面量的取反(-(-lit) 外层负消除)。宽度溢出时必须 返回 None 拒绝折叠(如 Java i32 的 -(-2147483648))。 默认实现按 i64 拒绝 i64::MIN 取反(防 debug panic / release 回绕)。
Source§

fn reassoc_delta( &mut self, op1: BinOp, k1: i64, op2: BinOp, k2: i64, wide: bool, ) -> Option<ReassocOutcome<JavaId>>

常量重结合合并:(x op1 K1) op2 K2 的常量合并结果。 语言侧负责宽度回绕(Java i32 的 K1+K2 溢出必须回绕,否则 产物是非法字面量)。
Source§

fn copy_subtree(&mut self, id: JavaId) -> JavaId

深拷贝子树(返回新 Id)。
Source§

fn effect(&self, id: JavaId) -> Effect

整棵子树的聚合效果(最坏情况)。语言侧应缓存(见 prepare)。
Source§

fn invalidate_effect(&mut self, id: JavaId)

使 id 的聚合效果缓存失效(若有)。引擎在同 pass 批量应用编辑后 沿祖先链调用——祖先的聚合效果含被改子树,必须失效, 后续 effect() 读取回退为按需重算(子缓存仍有效,代价 O(孩子数))。 默认空实现:无缓存的语言每次现算,天然正确。
Source§

fn debug_verify_events(&self, stmt: JavaId)

id 子树的区域事件序列(使用索引,prepare 期间预计算)。 事件序必须等于 scan_region 原递归的遍历序;返回 None 表示该 节点无索引(未构建/已失效)——scan_region 回退为原递归遍历。 引擎在应用编辑后沿祖先链调用 invalidate_effect 使索引失效。 事件索引一致性自检(惰性重建 B3 调试):默认空实现。
Source§

fn region_events(&self, id: JavaId) -> Option<&[RegionEvent<JavaId, u32>]>

Source§

fn var_key(&self, id: JavaId) -> Option<u32>

节点的名字键(VarRef/VarDecl/ForEach/Catch 等命名节点); 无名节点返回 None。
Source§

fn stmt_var_ref_count(&self, stmt: JavaId, key: u32) -> Option<u32>

Syntactic VarRef count for key inside this statement subtree. None = no fresh index (unbuilt/stale) — callers fall back to a recursive walk. Indexed languages return Some(0) for a statement that simply does not mention the name.
Source§

fn stmt_lambda_captures(&self, stmt: JavaId, key: u32) -> Option<bool>

Whether a lambda inside this statement subtree captures key. Same None contract as Self::stmt_var_ref_count.
Source§

fn stmt_kill_event(&self, stmt: JavaId, key: u32) -> Option<StmtKill<JavaId>>

Precomputed statement-level kill event for key. None = no fresh index (callers fall back to crate::rules::scan_kill_event).
Source§

fn stmt_mentions(&self, stmt: JavaId, key: u32) -> Option<bool>

Whether the statement syntactically mentions key (VarRef) or declares it (VarDecl/ForEach/Catch). None = no index.
Source§

fn stmt_opaque(&self, stmt: JavaId) -> Option<bool>

Whether the statement subtree contains an opaque region. None = no index.
Source§

fn fact_single_def(&self, key: u32) -> bool

变量(按名字键)在源码外无隐藏写且全部可见写恰为一次 (单一定义)。传播/钻石折叠据此跳过写窗口扫描。
Source§

fn fact_single_use(&self, key: u32) -> bool

变量(按名字键)的读点恰为一次(前端权威计数)。传播据此 免句法引用计数兜底。
Source§

fn fact_bool_valued(&self, key: u32) -> bool

变量(按名字键)的静态类型为原始布尔。类型敏感的布尔折叠 据此放行 int 形状。
Source§

fn fact_call_effect(&self, name: &str) -> Option<Effect>

按被调成员名的副作用上限(池级/IR 分析:纯方法调用、无抛 字段读等)。None = 未知(保守)。条件折叠/短路重建据此 放行含调用的条件。
Source§

fn node_index(&self, id: JavaId) -> usize

节点在语言 arena 中的稠密下标(供引擎位图/数组索引)。
Source§

fn id_of_index(&self, idx: usize) -> JavaId

node_index 的逆映射(下标 → Id)。cure-tree 工具包的线性 扫描(效果表重建、名字键扩展)需要按 arena 下标遍历。
Source§

fn is_opaque(&self, id: JavaId) -> bool

节点是否不透明(内部含不可解析原文,读/写集不可证明): Java 的 Raw 节点与匿名类体(anon_raw)。区域用量分析的可靠性 前提——漏判会导致捕获变量被误删(对抗波 4 抓获)。
Source§

fn own_effect(&self, id: JavaId) -> Effect

节点自身(不含 children)的效果贡献。
Source§

fn is_bool(&self, id: JavaId) -> bool

表达式是否为原始 boolean 类型(装箱 Boolean 必须返回 false)。
Source§

fn is_exact_int(&self, id: JavaId) -> bool

表达式是否具有精确整数类型(byte/short/int/long/char),用于算术恒等式守卫。
Source§

fn is_local_var(&self, id: JavaId) -> bool

是否为语言层的普通局部变量(可安全删除赋值;字段/全局必须 false)。
Source§

fn is_inferred_decl(&self, decl: JavaId) -> bool

声明是否为推断类型(Java 10 var)。推断声明剥除 init 后 变成 var x;——非法源码(obf_fuzz 差分抓获)。剥 init 类规则 必须拒绝。默认 false。
Source§

fn is_char_decl(&self, decl: JavaId) -> bool

声明是否为字符类型。字符类型变量对 int 字面量内联类型敏感: char c = 98; println(c) 打印 ‘b’,而内联成 println(98) 打印 98——静态类型可被 println / 字符串拼接观察。窄域规则(如 local_propagation)须拒绝非 Char 字面量值出字符声明。
Source§

fn has_pattern_bindings(&self, root: JavaId) -> bool

子树内是否含模式绑定(Java instanceof pattern:绑定作用域按 JLS 6.3 流可达性可越出语句本身到 enclosing block——块展平/语句 移动类规则须拒绝。默认 false(无模式绑定的语言)。
Source§

fn is_long_decl(&self, decl: JavaId) -> bool

声明(VarDecl 节点)的类型域是否容纳 int 算术结果。窄类型 (Java byte/short/char)的复合赋值含隐式收窄 (b += K ≡ b = (byte)(b + K))——把 delta 折回声明会产出 非法(超域常量)或变义(丢静态类型:char ch = 99 内联进 println 打数字而非字符)的字面量。默认 true(宽域语言)。
Source§

fn is_wide_decl(&self, decl: JavaId) -> bool

Source§

fn ternary_merge_ok(&self, target: Option<JavaId>, branches: &[JavaId]) -> bool

if→三元合并前的类型上下文校验。窄基本类型(Java short/byte/char) 的 return/赋值允许常量表达式收窄;if 的两支各自是常量表达式, 合并成非常量三元后收窄失效(return cond ? A|B : C|D; 对 short 返回不可编译)。默认放行;Java 侧按返回类型/目标类型裁决。
Source§

fn ternary_arg_unsound(&self, decl: JavaId, _value: JavaId) -> bool

三元值内联进 Call/New 实参位是否可能丢失泛型推断(声明为参数化 引用类型时目标类型是推断锚点)。默认 false。
Source§

fn propagation_cast_unsound(&self, decl: JavaId, value: JavaId) -> bool

局部传播把值内联进 cast 操作数时的语言类型守卫(Java 装箱: Boolean b = call(); (T) b → (T) call() 把基本 boolean 塞进 类型变量 cast,非法)。默认放行。
Source§

fn receiver_propagation_unsound( &self, decl: JavaId, value: JavaId, use_parent: Option<JavaId>, use_at_head: bool, ) -> bool

局部传播到成员访问接收位是否类型不可靠:声明的静态类型与 init 表达式的静态类型在成员解析上可能不等价(Java raw 泛型: List l = m(); l.add("x") 的 raw 擦除收 Object,内联成 m().add("x") 后按泛型收 CAP#1 → javac 硬错——mockito ReturningDefaultValuesTest 抓获)。仅接收位敏感(实参位 raw↔ 泛型双向兼容)。默认 false(无 raw 泛型的语言)。
Source§

fn bin_op(&self, id: JavaId) -> Option<BinOp>

Source§

fn un_op(&self, id: JavaId) -> Option<UnOp>

Source§

fn literal(&self, id: JavaId) -> Option<LitRef<'_>>

Source§

fn var_name(&self, id: JavaId) -> Option<&str>

变量相关名字:VarRef / VarDecl 读写的名字,以及 ForEach / Catch 的声明绑定名。
Source§

fn member_name(&self, id: JavaId) -> Option<&str>

成员访问/方法引用的成员名(x.f / x.m() / X::m 的 f/m 部分)。 结构相等性比较用(var_name 只覆盖 VarRef——x.a 与 x.b 曾被误判 相等 → ternary_fold 删除活分支,Types.java Rewriter.high 抓获)。
Source§

fn double_not_sound(&self, _operand: JavaId) -> bool

!!x ≡ x 恒等式在本语言是否成立(DoubleNot 规则守卫)。 蕴含 x 为布尔值。Java:! 操作数必须 boolean——可编译的 !!x 其 x 恒 boolean → 恒成立。JS:!x 是布尔胁迫(!!0 === false ≠ 0)→ 仅语法级布尔(is_bool)成立。默认取 is_bool(保守)。
Source§

fn var_cast_position_ok(&self, value: JavaId, typed: JavaId) -> bool

VarRef 值替换进 cast/instanceof 类型判定位后的可编译性裁决 (传播守卫)。引擎只判形状(沿 Paren 链首遇 Cast/InstanceOf, 见 typed_position)——类型相容性归语言侧:值的声明类型未解析 (自由名——反编译残缺作用域常态)→ 未知类型可 cast 到任何 引用类型,恒可编译;声明类型与目标类型同名 → 恒合法;其余 交给语言的类型知识(Java:Object 任一侧放行,否则保守拒绝—— interface/子类关系不可判)。默认 true(无静态类型判定位的语言)。
Source§

fn is_field_name(&self, name: &str) -> bool

名字是否是本单元声明的字段(字段读的可移动性判定——局部/参数 不可被调用改变,字段可以)。默认 false(名字未声明 → 当作可移动, 手工构建的 AST 无作用域解析时不会误伤)。
Source§

fn payload_equal(&self, a: JavaId, b: JavaId) -> bool

节点负载等价(NodeData 中的非孩子字段:New.ty/anon_raw、 Cast.ty、InstanceOf.ty/bind、Lambda.params_raw、VarDecl.ty 等)。 structurally_equal 用——负载不比较曾把 cond ? new FairSync() : new NonfairSync()(参数相同、类型不同)判相等折叠:JDK 语料 90 处真实误折(ReentrantReadWriteLock 锁公平性、DirectByteBuffer 字节序、instanceof 守卫 cast → CCE,5 例运行时行为改变证实)。
Source§

fn assign_op(&self, id: JavaId) -> Option<BinOp>

赋值运算(= 之外的复合赋值也在此表达;None 表示简单赋值)。
Source§

fn same_binding(&self, a: Self::Id, b: Self::Id) -> bool

两个节点是否指向同一个存储位置。默认按名字键(Java 的 作用域信息由前端 facts 提供);有绑定解析的后端(TS/JS)应覆盖 为 BindingId 等值,避免同名遮蔽被当成同一变量。
Source§

fn contains_hoisted_decl(&self, _root: Self::Id) -> bool

子树是否含可提升/条件初始化声明(JS 的 if (c) function f(){} ——Annex B:绑定被 var 提升但初始化条件化;搬移/删除该声明改变 语义)。ConstCondition 的 then 解包 / else 丢弃需拒绝。 默认 false(Java 无嵌套函数声明)。
Source§

fn block_hoists_decl(&self, _block: Self::Id) -> bool

块展开是否改变 Annex B 块级函数声明的提升语义(TS 判直接孩子; Java 恒 false)。
Source§

fn is_tagged_template(&self, _id: Self::Id) -> bool

是否为标签模板节点(tagged template literal)。标签位的 this 绑定取决于 tag 是 Reference 还是值——折臂/短路改写会 改变 this((true ? obj.f : null)\`vsobj.f```)。
Source§

fn assign_target_paren_required(&self, _inner: Self::Id) -> bool

赋值目标位的 Paren 是否语义显著(JS 具名求值:(fn) = function(){} 不推断 name,删括号会改变 Function.prototype.name)。
Source§

fn local_propagation_value_ok(&self, _decl: Self::Id, _value: Self::Id) -> bool

局部传播的值形态是否稳定(复制到使用点不改变求值时间语义)。 Java:任意表达式(类型系统/纯读假设——引擎既有扫描保证)。 JS:仅字面量(全局/闭包变量可在外层被改写;var local2 = y; … y 变化 …; return {local2} 内联会读到新值——Test262 eval 家族抓获)。
Source§

fn stmt_has_opaque_region(&self, _stmt: Self::Id) -> bool

语句子树是否含规则不可见的原文区域(Raw/类表达式/解构模式)。
Source§

fn value_may_throw_unresolved(&self, _value: Self::Id) -> bool

值子树是否读取可能未解析的名字(未声明全局 → 求值抛 ReferenceError)。死存储/死声明删除会把这次抛异常一并删掉 (JS var o = {notDefined};——Test262 object/not-defined 抓获)。
Source§

fn dead_decl_allowed(&self, _decl: Self::Id) -> bool

声明删除规则(dead_decl)是否允许删除该声明。Java:允许; TS:仅 var(let/const/using 的 TDZ/词法遮蔽/dispose 语义会因 删除而改变——Test262 annexB block-decl 家族抓获)。
Source§

fn is_function_like(&self, id: Self::Id) -> bool

函数边界(λ 捕获扫描用):Java 为 Lambda;TS 还含函数声明 (FuncStmt——function i(){ use(x) } 对 x 是按引用捕获)。
Source§

fn grammar_paren_required(&self, _inner: Self::Id) -> bool

Paren 的语法必要性(paren_removal 守卫):该内层形态在 紧位置(二元/一元运算数位)是否必须带括号——产生式约束, 优先级序表达不了。JS:箭头/对象字面量/Raw 形态在运算数位 语法必需括号(a ?? (() => true))。默认 false(打印层 优先级模型完备的语言——如 Java)。
Source§

fn cost_weight(&self, kind: NodeKind) -> u64

节点成本权重(用于“改写必须严格降本”的门槛)。

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.