Skip to main content

Ctx

Trait Ctx 

Source
pub trait Ctx {
Show 34 methods // Required methods fn class_name(&self) -> &str; fn find_outer(&self, internal: &str) -> Option<String>; fn family(&self, root: &str) -> Family; fn nested_is_static(&self, internal: &str) -> bool; fn class_has_this0(&self, internal: &str) -> bool; fn is_subtype_of(&self, sub: &JavaType, sup: &str) -> bool; fn class_supers_args( &self, internal: &str, args: &[GenericType], ) -> Vec<(String, Vec<GenericType>)>; fn is_generic_call(&self, e: &Expr) -> bool; fn generic_call_formals( &self, e: &Expr, ) -> Option<(Vec<GenericType>, Vec<String>)>; fn polymorphic_ret_cast( &self, cls: &str, name: &str, desc: &MethodDescriptor, ) -> Option<JavaType>; fn ctor_formals_by_arity( &self, internal: &str, arity: usize, ) -> Option<Vec<GenericType>>; fn is_interface(&self, internal: &str) -> bool; fn is_sealed(&self, internal: &str) -> bool; fn has_class(&self, internal: &str) -> bool; fn class_bases( &self, internal: &str, ) -> Option<(Vec<String>, Option<String>)>; fn outer_param_via_super(&self, internal: &str) -> bool; fn nested_method( &self, l: &LambdaExpr, outer_vt: &VarTable, ) -> Option<MethodBody>; // Provided methods fn source_level(&self) -> u16 { ... } fn obscured_member_escape(&self, _owner: &str, _member: &str) -> bool { ... } fn obscured_simple(&self, _internal: &str) -> Option<String> { ... } fn pool_id(&self) -> u64 { ... } fn local_class_internal(&self, simple: &str) -> Option<String> { ... } fn class_type_params(&self, internal: &str) -> Vec<TypeParam> { ... } fn generic_call_mt_typevars(&self, e: &Expr) -> Vec<String> { ... } fn super_name(&self, internal: &str) -> Option<String> { ... } fn field_flags( &self, internal: &str, name: &str, ) -> Option<FieldAccessFlags> { ... } fn method_flags( &self, internal: &str, name: &str, desc: &str, ) -> Option<MethodAccessFlags> { ... } fn declares_field(&self, internal: &str, name: &str) -> bool { ... } fn declares_field_display(&self, internal: &str, display: &str) -> bool { ... } fn declares_method_named(&self, internal: &str, name: &str) -> bool { ... } fn is_fw_shadow(&self, internal: &str) -> bool { ... } fn ctor_param_types( &self, internal: &str, skip: usize, n: usize, args: &[Expr], ) -> Option<Vec<JavaType>> { ... } fn sam_ret_cast(&self, g: &GenericType, sam_name: &str) -> Option<TypeRef> { ... } fn class_declares_generics(&self, internal: &str) -> bool { ... }
}
Expand description

Front-end services used by the shared passes and the emitter.

Required Methods§

Source

fn class_name(&self) -> &str

Internal name of the class currently being emitted (e.g. java/util/ArrayList).

Source

fn find_outer(&self, internal: &str) -> Option<String>

The class that internal is nested in, when the container records the nesting (JVM InnerClasses/NestHost; DEX inner-class annotations). None for a top-level class — including literal-$ names that only look nested.

Source

fn family(&self, root: &str) -> Family

Nested-class family of root, as far as the container records it.

Source

fn nested_is_static(&self, internal: &str) -> bool

True when a nested class is static (Outer$Inner with ACC_STATIC), so it is not constructed with an enclosing instance.

Source

fn class_has_this0(&self, internal: &str) -> bool

True when the class carries a synthetic this$0 field (an inner class with an enclosing instance parameter).

Source

fn is_subtype_of(&self, sub: &JavaType, sup: &str) -> bool

True when sub is assignable to sup (both internal names).

Source

fn class_supers_args( &self, internal: &str, args: &[GenericType], ) -> Vec<(String, Vec<GenericType>)>

Superclasses/interfaces of internal with the given type arguments applied: [(java/lang/Object, []), ...], most-derived first.

Source

fn is_generic_call(&self, e: &Expr) -> bool

True when the call carries inferred type arguments that the source must spell out.

Source

fn generic_call_formals( &self, e: &Expr, ) -> Option<(Vec<GenericType>, Vec<String>)>

Instantiated formal parameter types of a generic call plus the callee’s own method type variables (for witness casts). None when the call has no inferred type arguments to spell out.

Source

fn polymorphic_ret_cast( &self, cls: &str, name: &str, desc: &MethodDescriptor, ) -> Option<JavaType>

The instantiated return type of a call whose methodref owner redeclares the method with a self-covariant return (Stream over BaseStream).

Source

fn ctor_formals_by_arity( &self, internal: &str, arity: usize, ) -> Option<Vec<GenericType>>

Constructor parameter types of internal matching arity, for rendering new arguments against the right overload.

Source

fn is_interface(&self, internal: &str) -> bool

True when internal is an interface.

Source

fn is_sealed(&self, internal: &str) -> bool

True when internal is sealed (its permitted subclasses are recorded).

Source

fn has_class(&self, internal: &str) -> bool

True when the container holds this class at all (naming probes use it to test Outer$1Local-style candidates).

Source

fn class_bases(&self, internal: &str) -> Option<(Vec<String>, Option<String>)>

Interfaces and superclass of internal (internal names, declaration order). None when the class is unknown to the front-end.

Source

fn outer_param_via_super(&self, internal: &str) -> bool

True when internal is an inner class whose constructor forwards its enclosing instance straight to super (javac 21+ drops this$0 in that case, but call sites still need the qualified-new form).

Source

fn nested_method( &self, l: &LambdaExpr, outer_vt: &VarTable, ) -> Option<MethodBody>

Decompile the nested method a lambda site refers to — a lambda body, an anonymous-class method, or a local-class method — and run the front-end’s own idiom recovery on it.

This is where machine-specific desugaring lives: the shared emitter asks for a finished statement tree and prints it. The LambdaExpr carries the call-site facts (impl owner/name/descriptor, the SAM’s parameter names, the capture expressions, and any front-end annotations it attached, e.g. capture snapshots); outer_vt is the enclosing method’s variable table — the lexical scope the body will be printed in.

Provided Methods§

Source

fn source_level(&self) -> u16

Source level gate for version-dependent rendering: the JVM front-end returns the class-file major version; a DEX front-end returns the equivalent language level it decided to target. 52 means “Java 8 features available” (lambdas, diamond, …).

Source

fn obscured_member_escape(&self, _owner: &str, _member: &str) -> bool

The front-end’s render-time import map: when a referenced internal name is OBSCURED in the current compilation unit (its qualified form’s first segment binds to an in-scope class name — JLS 6.4.2), the front-end emits a single-type import for it and the render must use the SIMPLE name. Returns the simple name when so; None renders normally. Default None (no import machinery). 静态成员引用的遮蔽逃逸:owner 点分渲染的首段被作用域内的 名字(字段/继承成员)遮蔽、且类型导入的简单名同样会被捕获时, 成员引用改走单静态导入(渲染为裸成员名,前端记录 import static owner.member;)。JLS 6.4.2:表达式名解析优先 绑定变量——d.j.v 的 d 绑定到继承字段 d 后成员链断裂 (找不到符号 变量 j)。默认 false(无该机制的前端)。

Source

fn obscured_simple(&self, _internal: &str) -> Option<String>

Source

fn pool_id(&self) -> u64

Identity of the backing container (pool), for caches keyed on pool-dependent pure queries (Printer::shorten memoization). Default 0 is safe only for single-pool processes; multi-pool front-ends (ddc/jcdc) override with the pool pointer so a second pool never reads the first pool’s cached shortenings.

Source

fn local_class_internal(&self, simple: &str) -> Option<String>

Local-class name recorded for a $-style synthetic marker, when the container records one (Outer$1Local -> Local).

Source

fn class_type_params(&self, internal: &str) -> Vec<TypeParam>

Generic type parameters declared by internal (from its class signature); empty when the container records none.

Source

fn generic_call_mt_typevars(&self, e: &Expr) -> Vec<String>

Type variables of the method the call refers to (used to decide whether a formal still carries the callee’s own typevars).

Source

fn super_name(&self, internal: &str) -> Option<String>

Superclass of internal (internal name); None at Object/unknown.

Source

fn field_flags(&self, internal: &str, name: &str) -> Option<FieldAccessFlags>

Access flags of the field internal.name; None when absent.

Source

fn method_flags( &self, internal: &str, name: &str, desc: &str, ) -> Option<MethodAccessFlags>

Access flags of the method internal.name(desc); None when absent.

Source

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

True when internal declares any field named name.

Source

fn declares_field_display(&self, internal: &str, display: &str) -> bool

True when internal declares any field whose RENDERED display equals display (the registry’s rename applied; the raw name when no entry exists). Field references carry the DISPLAY name at emit time, so shadow checks must compare in display space — a raw-named field can render exactly the name another class’s field displays.

Source

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

True when internal declares a method named name (any descriptor).

Source

fn is_fw_shadow(&self, internal: &str) -> bool

True when internal is a framework-shadow stub class (the front-end relocates its FILE identity; references render the raw framework FQN — the platform class is what the bytecode means).

Source

fn ctor_param_types( &self, internal: &str, skip: usize, n: usize, args: &[Expr], ) -> Option<Vec<JavaType>>

Parameter types of the <init> of internal matching skip + n descriptor args, with skip leading synthetic parameters removed. Used to print new arguments with boolean/char constant adjustment.

Source

fn sam_ret_cast(&self, g: &GenericType, sam_name: &str) -> Option<TypeRef>

Instantiated SAM return of a functional interface’s method, resolved against a cast’s type arguments ((Function<I,R>) lambda needs (R) value witnesses on the impl body’s returns).

Source

fn class_declares_generics(&self, internal: &str) -> bool

True when internal declares class-level type parameters (so new internal<>(...) should carry a diamond).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§