structure-check: gate counts code lines, docs and comments in English
Gate ignores blank and full-line comment lines so the 250-line limit measures code bulk, not documentation weight; docs/README.md synced. Translate code comments to English in classfile, core config, namegen, rename assign, constants forms. Expand Plausible word bank with client-ecosystem terms (Module, Setting, Mixin, ...). cargo fmt clean, check.sh green.
This commit is contained in:
parent
ec28ec82e3
commit
39178420e4
42 changed files with 532 additions and 437 deletions
|
|
@ -1,9 +1,9 @@
|
|||
//! Типы операндов инструкций: константы, примитивы, условия, вызовы.
|
||||
//! Instruction operand types: constants, primitives, conditions, calls.
|
||||
|
||||
/// Идентификатор метки внутри одного метода.
|
||||
/// A label identifier within a single method.
|
||||
pub type Label = u32;
|
||||
|
||||
/// Константа для `ldc`/`ldc_w`/`ldc2_w`.
|
||||
/// A constant for `ldc`/`ldc_w`/`ldc2_w`.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum Const {
|
||||
Int(i32),
|
||||
|
|
@ -11,7 +11,7 @@ pub enum Const {
|
|||
Float(f32),
|
||||
Double(f64),
|
||||
String(String),
|
||||
/// Внутреннее имя класса (`java/lang/String`).
|
||||
/// The class's internal name (`java/lang/String`).
|
||||
Class(String),
|
||||
MethodType(String),
|
||||
MethodHandle {
|
||||
|
|
@ -21,7 +21,7 @@ pub enum Const {
|
|||
descriptor: String,
|
||||
itf: bool,
|
||||
},
|
||||
/// `CONSTANT_Dynamic`: имя, дескриптор, индекс bootstrap-метода.
|
||||
/// `CONSTANT_Dynamic`: name, descriptor, bootstrap-method index.
|
||||
Dynamic {
|
||||
name: String,
|
||||
descriptor: String,
|
||||
|
|
@ -29,7 +29,7 @@ pub enum Const {
|
|||
},
|
||||
}
|
||||
|
||||
/// Размер операнда/результата арифметики.
|
||||
/// Operand/result size of an arithmetic operation.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Prim {
|
||||
Int,
|
||||
|
|
@ -38,7 +38,7 @@ pub enum Prim {
|
|||
Double,
|
||||
}
|
||||
|
||||
/// Арифметическая/битовая операция; тип берётся из [`Prim`].
|
||||
/// An arithmetic/bitwise operation; the type comes from [`Prim`].
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Arith {
|
||||
Add,
|
||||
|
|
@ -55,7 +55,7 @@ pub enum Arith {
|
|||
Ushr,
|
||||
}
|
||||
|
||||
/// Условие перехода.
|
||||
/// A branch condition.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Cond {
|
||||
Eq,
|
||||
|
|
@ -66,10 +66,10 @@ pub enum Cond {
|
|||
Ge,
|
||||
}
|
||||
|
||||
/// Вид условного перехода (соответствует семействам `if*`).
|
||||
/// Kind of conditional branch (matches the `if*` families).
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum BranchCond {
|
||||
/// `if<cond>` относительно нуля.
|
||||
/// `if<cond>` against zero.
|
||||
Zero(Cond),
|
||||
/// `if_icmp<cond>`.
|
||||
Int(Cond),
|
||||
|
|
@ -79,7 +79,7 @@ pub enum BranchCond {
|
|||
Null { is_null: bool },
|
||||
}
|
||||
|
||||
/// Вид вызова.
|
||||
/// Kind of call.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum InvokeKind {
|
||||
Virtual,
|
||||
|
|
@ -88,7 +88,7 @@ pub enum InvokeKind {
|
|||
Interface,
|
||||
}
|
||||
|
||||
/// Конверсия типов (`i2l`, `f2b`, ... — JVMS §6.5.i2<b|c|s|l|f|d>).
|
||||
/// Type conversion (`i2l`, `f2b`, ... — JVMS §6.5.i2<b|c|s|l|f|d>).
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Convert {
|
||||
I2L,
|
||||
|
|
@ -108,7 +108,7 @@ pub enum Convert {
|
|||
D2F,
|
||||
}
|
||||
|
||||
/// Тип элемента массива для `newarray`/`*aload`/`*astore`.
|
||||
/// Array element type for `newarray`/`*aload`/`*astore`.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ArrayKind {
|
||||
Boolean,
|
||||
|
|
@ -122,10 +122,10 @@ pub enum ArrayKind {
|
|||
Reference,
|
||||
}
|
||||
|
||||
/// Тип слота локальной переменной для `*load*`/`*store*`.
|
||||
/// Local-variable slot type for `*load*`/`*store*`.
|
||||
///
|
||||
/// Хранится явно: выбор опкода (`iload` vs `aload`) — подсказка верификатору,
|
||||
/// потерять её при round-trip нельзя.
|
||||
/// Stored explicitly: the opcode choice (`iload` vs `aload`) is a hint to the
|
||||
/// verifier, and losing it on a round-trip is not acceptable.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum SlotKind {
|
||||
Int,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//! Инструкции IR: смещения отсутствуют, ветвления адресуют [`Label`].
|
||||
//! IR instructions: no offsets, branches address a [`Label`].
|
||||
//!
|
||||
//! Это принципиально: любой пасс, меняющий порядок/длину инструкций, не обязан
|
||||
//! пересчитывать jump-офсеты — это делает writer один раз в конце пайплайна.
|
||||
//! This is fundamental: any pass that changes instruction order/length need not
|
||||
//! recompute jump offsets — the writer does that once at the end of the pipeline.
|
||||
|
||||
mod kinds;
|
||||
|
||||
|
|
@ -9,32 +9,32 @@ pub use kinds::{
|
|||
Arith, ArrayKind, BranchCond, Cond, Const, Convert, InvokeKind, Label, Prim, SlotKind,
|
||||
};
|
||||
|
||||
/// Мнемоника одной инструкции.
|
||||
/// Mnemonic of a single instruction.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum Insn {
|
||||
/// Маркер метки. Ветвления указывают на [`Label`], writer вычисляет смещения.
|
||||
/// Label marker. Branches point at a [`Label`]; the writer computes offsets.
|
||||
Mark(Label),
|
||||
Nop,
|
||||
AconstNull,
|
||||
Const(Const),
|
||||
/// Загрузка локальной переменной (`iload`, `aload`, ...).
|
||||
/// Load a local variable (`iload`, `aload`, ...).
|
||||
Load {
|
||||
slot: u16,
|
||||
kind: SlotKind,
|
||||
},
|
||||
/// Сохранение локальной переменной.
|
||||
/// Store a local variable.
|
||||
Store {
|
||||
slot: u16,
|
||||
kind: SlotKind,
|
||||
},
|
||||
/// `iinc` — увеличение локальной переменной на константу.
|
||||
/// `iinc` — increase a local variable by a constant.
|
||||
Iinc {
|
||||
index: u16,
|
||||
delta: i32,
|
||||
},
|
||||
/// Загрузка элемента массива.
|
||||
/// Load an array element.
|
||||
ArrayLoad(ArrayKind),
|
||||
/// Сохранение элемента массива.
|
||||
/// Store an array element.
|
||||
ArrayStore(ArrayKind),
|
||||
Pop,
|
||||
Pop2,
|
||||
|
|
@ -45,23 +45,23 @@ pub enum Insn {
|
|||
Dup2X1,
|
||||
Dup2X2,
|
||||
Swap,
|
||||
/// `iadd`, `lmul`, `lneg`, ... — тип + операция.
|
||||
/// `iadd`, `lmul`, `lneg`, ... — type + operation.
|
||||
Binary {
|
||||
prim: Prim,
|
||||
op: Arith,
|
||||
},
|
||||
/// Сравнение длин (`lcmp`) и плавающих (`fcmpl`/`fcmpg`).
|
||||
/// Comparison of longs (`lcmp`) and floats (`fcmpl`/`fcmpg`).
|
||||
Cmp {
|
||||
prim: Prim,
|
||||
nan_great: bool,
|
||||
},
|
||||
/// Конверсия типов (`i2l`, `d2f`, ...).
|
||||
/// Type conversion (`i2l`, `d2f`, ...).
|
||||
Convert(Convert),
|
||||
Branch(BranchCond, Label),
|
||||
Goto(Label),
|
||||
/// `jsr` — вызов подпрограммы (только классы версии ≤ 50).
|
||||
/// `jsr` — subroutine call (only version ≤ 50 classes).
|
||||
Jsr(Label),
|
||||
/// `ret` — возврат из подпрограммы (`jsr`/`ret` парны).
|
||||
/// `ret` — return from a subroutine (`jsr`/`ret` come in pairs).
|
||||
Ret(u16),
|
||||
TableSwitch {
|
||||
default: Label,
|
||||
|
|
@ -73,9 +73,9 @@ pub enum Insn {
|
|||
default: Label,
|
||||
pairs: Vec<(i32, Label)>,
|
||||
},
|
||||
/// `return`/`ireturn`/...; `None` — пустой возврат.
|
||||
/// `return`/`ireturn`/...; `None` — void return.
|
||||
Return(Option<Prim>),
|
||||
/// `areturn` — возврат ссылки (у [`Prim`] нет ссылочного типа).
|
||||
/// `areturn` — return a reference ([`Prim`] has no reference type).
|
||||
AReturn,
|
||||
GetStatic {
|
||||
owner: String,
|
||||
|
|
@ -112,7 +112,7 @@ pub enum Insn {
|
|||
New(String),
|
||||
NewArray(ArrayKind),
|
||||
ANewArray(String),
|
||||
/// `multianewarray` — массив любого измерения; `dims` — сколько измерений со стека.
|
||||
/// `multianewarray` — array of any dimension; `dims` — how many dimensions from the stack.
|
||||
MultiANewArray {
|
||||
descriptor: String,
|
||||
dims: u8,
|
||||
|
|
@ -126,7 +126,7 @@ pub enum Insn {
|
|||
}
|
||||
|
||||
impl Insn {
|
||||
/// Метки, на которые ссылается инструкция (для построения CFG).
|
||||
/// Labels the instruction references (for building the CFG).
|
||||
pub fn targets(&self) -> Vec<Label> {
|
||||
match self {
|
||||
Insn::Branch(_, label) | Insn::Goto(label) | Insn::Jsr(label) => vec![*label],
|
||||
|
|
@ -154,7 +154,7 @@ impl Insn {
|
|||
}
|
||||
}
|
||||
|
||||
/// Незакодированный переход (для вставки opaque-предикатов и перестройки CFG).
|
||||
/// An encoded jump target (for inserting opaque predicates and rebuilding the CFG).
|
||||
pub fn branch_target_mut(&mut self) -> Option<&mut Label> {
|
||||
match self {
|
||||
Insn::Branch(_, label) | Insn::Goto(label) => Some(label),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue