Skip to content

Commit

Permalink
[resource-viewer] Store TypeTag with Vectors in AnnotatedMoveValue
Browse files Browse the repository at this point in the history
Currently if arrays are empty, there is no way to know the interior type. This
adds a TypeTag to AnnotatedMoveValue::Vector so that this information is
preserved.

Closes: aptos-labs#7166
  • Loading branch information
metajack authored and bors-libra committed Jan 8, 2021
1 parent 4b8782d commit 453eae5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions language/tools/resource-viewer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use diem_types::{
};
use move_core_types::{
identifier::Identifier,
language_storage::{ModuleId, StructTag},
language_storage::{ModuleId, StructTag, TypeTag},
value::{MoveStruct, MoveValue},
};
use move_vm_runtime::data_cache::RemoteCache;
Expand Down Expand Up @@ -49,7 +49,7 @@ pub enum AnnotatedMoveValue {
U128(u128),
Bool(bool),
Address(AccountAddress),
Vector(Vec<AnnotatedMoveValue>),
Vector(TypeTag, Vec<AnnotatedMoveValue>),
Bytes(Vec<u8>),
Struct(AnnotatedMoveStruct),
}
Expand Down Expand Up @@ -170,6 +170,7 @@ impl<'a> MoveValueAnnotator<'a> {
.collect::<Result<_>>()?,
),
_ => AnnotatedMoveValue::Vector(
ty.type_tag().unwrap(),
a.iter()
.map(|v| self.annotate_value(v, ty.as_ref()))
.collect::<Result<_>>()?,
Expand Down Expand Up @@ -207,7 +208,7 @@ fn pretty_print_value(
AnnotatedMoveValue::U64(v) => write!(f, "{}", v),
AnnotatedMoveValue::U128(v) => write!(f, "{}u128", v),
AnnotatedMoveValue::Address(a) => write!(f, "{}", a.short_str_lossless()),
AnnotatedMoveValue::Vector(v) => {
AnnotatedMoveValue::Vector(_, v) => {
writeln!(f, "[")?;
for value in v.iter() {
write_indent(f, indent + 4)?;
Expand Down

0 comments on commit 453eae5

Please sign in to comment.