Skip to content

Commit 0ca2a61

Browse files
georgemitenkovJoshLind
authored andcommitted
[api] Addressing function value todos (aptos-labs#17047)
(cherry picked from commit dee4127) # Conflicts: # third_party/move/tools/move-resource-viewer/src/lib.rs
1 parent 23556a8 commit 0ca2a61

File tree

1 file changed

+26
-1
lines changed
  • third_party/move/tools/move-resource-viewer/src

1 file changed

+26
-1
lines changed

third_party/move/tools/move-resource-viewer/src/lib.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use move_core_types::{
2424
account_address::AccountAddress,
2525
function::{ClosureMask, MoveClosure},
2626
identifier::{IdentStr, Identifier},
27-
language_storage::{ModuleId, StructTag, TypeTag},
27+
language_storage::{FunctionParamOrReturnTag, ModuleId, StructTag, TypeTag},
2828
transaction_argument::{convert_txn_args, TransactionArgument},
2929
u256,
3030
value::{MoveStruct, MoveTypeLayout, MoveValue},
@@ -456,9 +456,34 @@ impl<V: CompiledModuleView> MoveValueAnnotator<V> {
456456
TypeTag::U256 => FatType::U256,
457457
TypeTag::U128 => FatType::U128,
458458
TypeTag::Vector(ty) => FatType::Vector(Box::new(self.resolve_type_impl(ty, limit)?)),
459+
<<<<<<< HEAD
459460
TypeTag::Function(..) => {
460461
// TODO(#15664) implement functions for fat types"
461462
todo!("functions for fat types")
463+
=======
464+
TypeTag::Function(function_tag) => {
465+
let mut convert_tags = |tags: &[FunctionParamOrReturnTag]| {
466+
tags.iter()
467+
.map(|t| {
468+
use FunctionParamOrReturnTag::*;
469+
Ok(match t {
470+
Reference(t) => {
471+
FatType::Reference(Box::new(self.resolve_type_impl(t, limit)?))
472+
},
473+
MutableReference(t) => FatType::MutableReference(Box::new(
474+
self.resolve_type_impl(t, limit)?,
475+
)),
476+
Value(t) => self.resolve_type_impl(t, limit)?,
477+
})
478+
})
479+
.collect::<anyhow::Result<Vec<_>>>()
480+
};
481+
FatType::Function(Box::new(FatFunctionType {
482+
args: convert_tags(&function_tag.args)?,
483+
results: convert_tags(&function_tag.results)?,
484+
abilities: function_tag.abilities,
485+
}))
486+
>>>>>>> dee41276c9 ([api] Addressing function value todos (#17047))
462487
},
463488
})
464489
}

0 commit comments

Comments
 (0)