From bab4ab0dd71675a7f99e4deefd0203b4dc2b05b3 Mon Sep 17 00:00:00 2001 From: Henry Chu Date: Tue, 23 Apr 2024 10:07:55 +0800 Subject: [PATCH] refactor(jvm): relocate signature types BREAKING CHANGE: `types::signature` is moved to other packages --- fuzz/fuzz_targets/class_parsing.rs | 2 +- src/jvm/class/mod.rs | 10 ++++++---- src/jvm/field.rs | 3 +++ src/jvm/method.rs | 3 +++ src/jvm/mod.rs | 12 ++++-------- src/types/mod.rs | 1 - src/types/signitures/mod.rs | 15 --------------- 7 files changed, 17 insertions(+), 29 deletions(-) delete mode 100644 src/types/signitures/mod.rs diff --git a/fuzz/fuzz_targets/class_parsing.rs b/fuzz/fuzz_targets/class_parsing.rs index 41a0880..dd667a6 100644 --- a/fuzz/fuzz_targets/class_parsing.rs +++ b/fuzz/fuzz_targets/class_parsing.rs @@ -1,7 +1,7 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use mokapot::jvm::class::Class; +use mokapot::jvm::Class; fuzz_target!(|data: &[u8]| { let _ = Class::from_reader(data); diff --git a/src/jvm/class/mod.rs b/src/jvm/class/mod.rs index 0dfc5af..f74ddea 100644 --- a/src/jvm/class/mod.rs +++ b/src/jvm/class/mod.rs @@ -8,17 +8,19 @@ use bitflags::bitflags; use crate::{ macros::see_jvm_spec, - types::{ - field_type::FieldType, method_descriptor::MethodDescriptor, signitures::FieldSignature, - }, + types::{field_type::FieldType, method_descriptor::MethodDescriptor}, }; use super::{ + field, parsing::Error, references::{ClassRef, FieldRef, MethodRef}, Class, ConstantValue, Field, Method, }; +/// A generic type signature for a class. +pub type Signature = String; + impl Class { /// Gets a method of the class by its name and descriptor. #[must_use] @@ -286,7 +288,7 @@ pub struct RecordComponent { /// The type of the component. pub component_type: FieldType, /// The generic signature of the component. - pub signature: Option, + pub signature: Option, /// The runtime visible annotations. pub runtime_visible_annotations: Vec, /// The runtime invisible annotations. diff --git a/src/jvm/field.rs b/src/jvm/field.rs index f4e83db..a904fac 100644 --- a/src/jvm/field.rs +++ b/src/jvm/field.rs @@ -14,6 +14,9 @@ impl Field { } } +/// A generic type signature for a field, a formal parameter, a local variable, or a record component. +pub type Signature = String; + use bitflags::bitflags; bitflags! { diff --git a/src/jvm/method.rs b/src/jvm/method.rs index 8045261..40dd4bb 100644 --- a/src/jvm/method.rs +++ b/src/jvm/method.rs @@ -4,6 +4,9 @@ use bitflags::bitflags; use super::{references::MethodRef, Method}; +/// A generic type signature for a method. +pub type Signature = String; + impl Method { /// The method of a static initializer block. pub const CLASS_INITIALIZER_NAME: &'static str = ""; diff --git a/src/jvm/mod.rs b/src/jvm/mod.rs index afe1115..2b3c105 100644 --- a/src/jvm/mod.rs +++ b/src/jvm/mod.rs @@ -6,11 +6,7 @@ use itertools::Itertools; use crate::{ macros::see_jvm_spec, - types::{ - field_type::FieldType, - method_descriptor::MethodDescriptor, - signitures::{ClassSignature, FieldSignature, MethodSignature}, - }, + types::{field_type::FieldType, method_descriptor::MethodDescriptor}, }; use self::{ @@ -82,7 +78,7 @@ pub struct Class { /// Indicates whether the class is deprecated. pub is_deprecated: bool, /// The generic signature of the class. - pub signature: Option, + pub signature: Option, /// The record components of the class if the class is `record`. pub record: Option>, /// Unrecognized JVM attributes. @@ -135,7 +131,7 @@ pub struct Field { /// Indicates if the field is deprecated. pub is_deperecated: bool, /// The generic signature. - pub signature: Option, + pub signature: Option, /// The runtime visible annotations. pub runtime_visible_annotations: Vec, /// The runtime invisible annotations. @@ -185,7 +181,7 @@ pub struct Method { /// Indicates if the method is deprecated. pub is_deprecated: bool, /// The generic signature. - pub signature: Option, + pub signature: Option, /// Unrecognized JVM attributes. pub free_attributes: Vec<(String, Vec)>, } diff --git a/src/types/mod.rs b/src/types/mod.rs index ffadda5..e3567eb 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -1,4 +1,3 @@ //! Module containing the APIs for the JVM type system. pub mod field_type; pub mod method_descriptor; -pub mod signitures; diff --git a/src/types/signitures/mod.rs b/src/types/signitures/mod.rs deleted file mode 100644 index d51c2aa..0000000 --- a/src/types/signitures/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! Generic type signitures in the JVM -//! This module is work in progress, and the signatures that are not yet implemented are aliased to [`String`]. -//! -#![doc = see_jvm_spec!(4, 7, 9, 1)] - -use crate::macros::see_jvm_spec; - -/// A generic type signature for a class. -pub type ClassSignature = String; - -/// A generic type signature for a method. -pub type MethodSignature = String; - -/// A generic type signature for a field, a formal parameter, a local variable, or a record component. -pub type FieldSignature = String;