Skip to content

Commit

Permalink
refactor(jvm): relocate signature types
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `types::signature` is moved to other packages
  • Loading branch information
henryhchchc committed Apr 23, 2024
1 parent 419ec25 commit bab4ab0
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 29 deletions.
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/class_parsing.rs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
10 changes: 6 additions & 4 deletions src/jvm/class/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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<FieldSignature>,
pub signature: Option<field::Signature>,
/// The runtime visible annotations.
pub runtime_visible_annotations: Vec<super::Annotation>,
/// The runtime invisible annotations.
Expand Down
3 changes: 3 additions & 0 deletions src/jvm/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down
3 changes: 3 additions & 0 deletions src/jvm/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<clinit>";
Expand Down
12 changes: 4 additions & 8 deletions src/jvm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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<ClassSignature>,
pub signature: Option<class::Signature>,
/// The record components of the class if the class is `record`.
pub record: Option<Vec<class::RecordComponent>>,
/// Unrecognized JVM attributes.
Expand Down Expand Up @@ -135,7 +131,7 @@ pub struct Field {
/// Indicates if the field is deprecated.
pub is_deperecated: bool,
/// The generic signature.
pub signature: Option<FieldSignature>,
pub signature: Option<field::Signature>,
/// The runtime visible annotations.
pub runtime_visible_annotations: Vec<Annotation>,
/// The runtime invisible annotations.
Expand Down Expand Up @@ -185,7 +181,7 @@ pub struct Method {
/// Indicates if the method is deprecated.
pub is_deprecated: bool,
/// The generic signature.
pub signature: Option<MethodSignature>,
pub signature: Option<method::Signature>,
/// Unrecognized JVM attributes.
pub free_attributes: Vec<(String, Vec<u8>)>,
}
Expand Down
1 change: 0 additions & 1 deletion src/types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//! Module containing the APIs for the JVM type system.
pub mod field_type;
pub mod method_descriptor;
pub mod signitures;
15 changes: 0 additions & 15 deletions src/types/signitures/mod.rs

This file was deleted.

0 comments on commit bab4ab0

Please sign in to comment.