Skip to content

Commit

Permalink
[move] Remove SignatureTokenKind (#15211)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgemitenkov authored Nov 6, 2024
1 parent 021032c commit c14b4e9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 62 deletions.
32 changes: 2 additions & 30 deletions third_party/move/move-binary-format/src/file_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use crate::{
errors::{PartialVMError, PartialVMResult},
file_format_common,
internals::ModuleIndex,
IndexKind, SignatureTokenKind,
IndexKind,
};
use move_bytecode_spec::bytecode_spec;
use move_core_types::{
Expand Down Expand Up @@ -1315,35 +1315,7 @@ impl std::fmt::Debug for SignatureToken {
}

impl SignatureToken {
/// Returns the "value kind" for the `SignatureToken`
#[inline]
pub fn signature_token_kind(&self) -> SignatureTokenKind {
// TODO: SignatureTokenKind is out-dated. fix/update/remove SignatureTokenKind and see if
// this function needs to be cleaned up
use SignatureToken::*;

match self {
Reference(_) => SignatureTokenKind::Reference,
MutableReference(_) => SignatureTokenKind::MutableReference,
Bool
| U8
| U16
| U32
| U64
| U128
| U256
| Address
| Signer
| Struct(_)
| StructInstantiation(_, _)
| Vector(_) => SignatureTokenKind::Value,
// TODO: This is a temporary hack to please the verifier. SignatureTokenKind will soon
// be completely removed. `SignatureTokenView::kind()` should be used instead.
TypeParameter(_) => SignatureTokenKind::Value,
}
}

// Returns `true` if the `SignatureToken` is an integer type.
/// Returns true if the token is an integer type.
pub fn is_integer(&self) -> bool {
use SignatureToken::*;
match self {
Expand Down
26 changes: 0 additions & 26 deletions third_party/move/move-binary-format/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,32 +132,6 @@ impl fmt::Display for IndexKind {
}
}

// TODO: is this outdated?
/// Represents the kind of a signature token.
#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum SignatureTokenKind {
/// Any sort of owned value that isn't an array (Integer, Bool, Struct etc).
Value,
/// A reference.
Reference,
/// A mutable reference.
MutableReference,
}

impl fmt::Display for SignatureTokenKind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use SignatureTokenKind::*;

let desc = match self {
Value => "value",
Reference => "reference",
MutableReference => "mutable reference",
};

f.write_str(desc)
}
}

/// A macro which should be preferred in critical runtime paths for unwrapping an option
/// if a `PartialVMError` is expected. In debug mode, this will panic. Otherwise
/// we return an Err.
Expand Down
7 changes: 1 addition & 6 deletions third_party/move/move-binary-format/src/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//! immediately -- the views are a convenience to make that simpler. They've been written as lazy
//! iterators to aid understanding of the file format and to make it easy to generate views.
use crate::{access::ModuleAccess, file_format::*, SignatureTokenKind};
use crate::{access::ModuleAccess, file_format::*};
use move_core_types::{identifier::IdentStr, language_storage::ModuleId};
use std::{
collections::{BTreeMap, BTreeSet},
Expand Down Expand Up @@ -685,11 +685,6 @@ impl<'a, T: ModuleAccess> SignatureTokenView<'a, T> {
self.token
}

#[inline]
pub fn signature_token_kind(&self) -> SignatureTokenKind {
self.token.signature_token_kind()
}

#[inline]
pub fn is_reference(&self) -> bool {
self.token.is_reference()
Expand Down

0 comments on commit c14b4e9

Please sign in to comment.