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:
Loki 2026-10-09 10:31:02 +02:00
parent ec28ec82e3
commit 39178420e4
Signed by: boba
GPG key ID: 253067914055423B
42 changed files with 532 additions and 437 deletions

View file

@ -1,7 +1,8 @@
//! Кадры `StackMapTable` при чтении: вариант в вариант, дельты как есть.
//! `StackMapTable` frames on read: variant to variant, deltas as-is.
//!
//! Backend хранит кадры в номерах инструкций (см. `from_bytes_code_attributes`),
//! наш IR — тоже: writer сам пересчитает их в байты при `to_bytes`.
//! The backend stores frames in instruction indices (see
//! `from_bytes_code_attributes`), and so does our IR: the writer recomputes them
//! into bytes on `to_bytes`.
use ristretto_classfile::ConstantPool;
use ristretto_classfile::attributes::{StackFrame, VerificationType as RtType};
@ -10,7 +11,7 @@ use super::super::pool::class_name;
use crate::error::ClassfileError;
use crate::format::{StackMapFrame, VerificationType};
/// Кадры backend'а → наши (индексные дельты — как есть).
/// Backend frames → ours (index deltas — as-is).
pub(super) fn to_frames(
frames: &[StackFrame],
pool: &ConstantPool<'_>,
@ -66,7 +67,7 @@ fn to_frame(frame: &StackFrame, pool: &ConstantPool<'_>) -> Result<StackMapFrame
})
}
/// Единственный элемент стека кадра (`same_locals_1_stack_item`).
/// The frame's single stack element (`same_locals_1_stack_item`).
fn single(stack: &[RtType], pool: &ConstantPool<'_>) -> Result<VerificationType, ClassfileError> {
let mut types = types(stack, pool)?.into_iter();
match (types.next(), types.next()) {
@ -84,7 +85,7 @@ fn types(
values.iter().map(|value| vtype(value, pool)).collect()
}
/// Тип верификации backend'а → наш тип (имя класса берётся из constant pool).
/// Backend verification type → our type (the class name comes from the constant pool).
fn vtype(value: &RtType, pool: &ConstantPool<'_>) -> Result<VerificationType, ClassfileError> {
Ok(match value {
RtType::Top => VerificationType::Top,
@ -99,7 +100,7 @@ fn vtype(value: &RtType, pool: &ConstantPool<'_>) -> Result<VerificationType, Cl
})
}
/// Тип перехвата (`0` — catch-all для `finally`/`any`).
/// The catch type (`0` — catch-all for `finally`/`any`).
pub(super) fn catch_type(
pool: &ConstantPool<'_>,
index: u16,

View file

@ -1,7 +1,7 @@
//! Метки тела метода: где обязаны стоять и как резолвятся.
//! Method-body labels: where they must stand and how they resolve.
//!
//! Backend нумерует инструкции по порядку — метки ставятся прямо на номера,
//! без байтовых смещений.
//! The backend numbers instructions in order — labels are placed directly on the
//! numbers, without byte offsets.
use std::collections::{BTreeMap, BTreeSet};
@ -11,10 +11,10 @@ use ristretto_classfile::attributes::{ExceptionTableEntry, Instruction};
use crate::error::ClassfileError;
use crate::insn::Label;
/// Номера инструкций, на которых обязана стоять метка.
/// Instruction numbers that must carry a label.
///
/// `extra` — позиции отладочных таблиц (уже номерами): вставки пассов
/// не должны оставлять их без меток.
/// `extra` — debug-table positions (already as numbers): pass insertions must
/// not leave them without a label.
pub(super) fn label_indexes(
code: &[Instruction],
exception_table: &[ExceptionTableEntry],
@ -36,7 +36,7 @@ pub(super) fn label_indexes(
Ok(indexes)
}
/// Цели ветвлений backend'а: для `if*`/`goto` — абсолютный номер, для `switch` — дельта.
/// Backend branch targets: for `if*`/`goto` an absolute number, for `switch` a delta.
fn branch_indexes(instruction: &Instruction, index: u16) -> Vec<i32> {
let base = i32::from(index);
match instruction {
@ -73,7 +73,7 @@ fn once(value: i32) -> std::iter::Once<i32> {
std::iter::once(value)
}
/// Превратить отсортированный набор номеров в последовательные метки.
/// Turn a sorted set of numbers into sequential labels.
pub(super) fn assign(indexes: &BTreeSet<u32>) -> BTreeMap<u32, Label> {
indexes
.iter()
@ -82,7 +82,7 @@ pub(super) fn assign(indexes: &BTreeSet<u32>) -> BTreeMap<u32, Label> {
.collect()
}
/// Метка для номера инструкции.
/// The label for an instruction number.
pub(super) fn lookup(labels: &BTreeMap<u32, Label>, index: u16) -> Result<Label, ClassfileError> {
labels
.get(&u32::from(index))
@ -90,7 +90,7 @@ pub(super) fn lookup(labels: &BTreeMap<u32, Label>, index: u16) -> Result<Label,
.ok_or_else(|| ClassfileError::Parse(format!("нет метки для инструкции {index}")))
}
/// Позиции отладочных таблиц, которым нужны метки.
/// Debug-table positions that need labels.
pub(super) fn collect_debug_labels(
attributes: &[RtAttr],
starts: &[u16],
@ -122,7 +122,7 @@ pub(super) fn collect_debug_labels(
Ok(())
}
/// Байт → номер инструкции (только границы инструкций).
/// Byte → instruction number (instruction boundaries only).
pub(super) fn byte_to_index(starts: &[u16], byte: u16) -> Result<u32, ClassfileError> {
starts
.iter()
@ -131,7 +131,7 @@ pub(super) fn byte_to_index(starts: &[u16], byte: u16) -> Result<u32, ClassfileE
.ok_or_else(|| ClassfileError::Parse(format!("смещение {byte} мимо инструкции")))
}
/// Конец диапазона `[start, start+length)`: индекс за концом.
/// End of the range `[start, start+length)`: the index past the end.
fn end_index(
starts: &[u16],
start: u16,
@ -148,7 +148,7 @@ fn end_index(
byte_to_index(starts, end)
}
/// Метка для байтового смещения отладочной таблицы.
/// The label for a debug table's byte offset.
pub(super) fn resolve_byte(
labels: &BTreeMap<u32, Label>,
starts: &[u16],
@ -161,7 +161,7 @@ pub(super) fn resolve_byte(
.ok_or_else(|| ClassfileError::Parse(format!("нет метки для смещения {byte}")))
}
/// Метка конца диапазона отладочной таблицы.
/// The end label of a debug table's range.
pub(super) fn resolve_end(
labels: &BTreeMap<u32, Label>,
starts: &[u16],

View file

@ -1,10 +1,10 @@
//! `Code` backend'а → тело метода нашего IR: метки, исключения, кадры.
//! Backend `Code` → our IR method body: labels, exceptions, frames.
//!
//! Backend уже перевёл байтовые смещения в номера инструкций — конвертеры
//! работают прямо с ними: метки ставятся на целях переходов, границах
//! try-блоков и позициях отладочных таблиц; кадры переносятся как есть
//! (индексные дельты). Позиции `LineNumberTable`/`LocalVariableTable` —
//! тоже метки, поэтому вставки пассов их не ломают (байты досчитает writer).
//! The backend already turned byte offsets into instruction indices — the
//! converters work directly with them: labels are placed on branch targets,
//! try-block boundaries and debug-table positions; frames are carried over as-is
//! (index deltas). `LineNumberTable`/`LocalVariableTable` positions are labels
//! too, so pass insertions don't break them (the writer recomputes the bytes).
mod frames;
mod labels;
@ -27,7 +27,7 @@ use crate::model::{
use frames::{catch_type, to_frames};
use labels::{assign, collect_debug_labels, label_indexes, lookup, resolve_byte, resolve_end};
/// Тело метода целиком: backend `Code` → наш [`Code`].
/// The whole method body: backend `Code` → our [`Code`].
pub(super) fn convert_code(
max_stack: u16,
max_locals: u16,
@ -150,7 +150,7 @@ pub(super) fn convert_code(
})
}
/// Байтовые смещения инструкций и длина тела метода.
/// Instruction byte offsets and the method body length.
fn layout(code: &[Instruction]) -> Result<(Vec<u16>, u16), ClassfileError> {
let mut cursor = Cursor::new(Vec::new());
let mut offsets = Vec::with_capacity(code.len());