Skip to content
This repository was archived by the owner on May 4, 2024. It is now read-only.

Commit b5b567a

Browse files
committed
fixup! Implement IR support
1 parent f5a7813 commit b5b567a

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

language/move-binary-format/src/deserializer.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,6 +1855,9 @@ impl Opcodes {
18551855
0x4B => Ok(Opcodes::CAST_U16),
18561856
0x4C => Ok(Opcodes::CAST_U32),
18571857
0x4D => Ok(Opcodes::CAST_U256),
1858+
0x4E => Ok(Opcodes::GET_FUNC_PTR),
1859+
0x4F => Ok(Opcodes::GET_FUNC_PTR_GENERIC),
1860+
0x50 => Ok(Opcodes::CALL_FUNC_PTR),
18581861
_ => Err(PartialVMError::new(StatusCode::UNKNOWN_OPCODE)),
18591862
}
18601863
}

language/move-bytecode-verifier/src/signature.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,10 @@ impl<'a> SignatureChecker<'a> {
356356
}
357357
Vector(ty) => self.check_signature_token(ty),
358358
StructInstantiation(_, type_arguments) => self.check_signature_tokens(type_arguments),
359-
Function(_) => Err(PartialVMError::new(StatusCode::INVALID_SIGNATURE_TOKEN)
360-
.with_message("function not allowed".to_string())),
359+
Function(func_ty) => {
360+
func_ty.parameters.iter().map(|ty| self.check_signature_token(ty)).collect::<PartialVMResult<()>>()?;
361+
func_ty.return_.iter().map(|ty| self.check_signature_token(ty)).collect::<PartialVMResult<()>>()
362+
}
361363
}
362364
}
363365

language/move-bytecode-verifier/src/stack_usage_verifier.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ impl<'a> StackUsageVerifier<'a> {
272272
Bytecode::GetFunctionPointer(_) | Bytecode::GetFunctionPointerGeneric(_) => (0, 1),
273273
Bytecode::CallFunctionPointer(idx) => match &self.resolver.signature_at(*idx).0[0] {
274274
SignatureToken::Function(func_ty) => (
275-
func_ty.parameters.len() as u64,
275+
func_ty.parameters.len() as u64 + 1,
276276
func_ty.return_.len() as u64,
277277
),
278278
_ => {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
processed 2 tasks

language/move-vm/transactional-tests/tests/function_pointers/simple_get_and_call.mvir

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ main() {
1616
let a: u64;
1717
label b0:
1818
func = get_function_pointer(M.sum);
19-
a = call_function_pointer<|u64, u64| (u64)>(move(func), 0, 1);
19+
a = call_function_pointer<|u64, u64| (u64)>(0, 1, move(func));
2020
assert(move(a) == 1, 0);
21+
return;
2122
}

0 commit comments

Comments
 (0)