Last active
August 26, 2022 19:17
-
-
Save rlkelly/c746405d3a3a4de90854aa231ebd5e33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from starkware.cairo.common.alloc import alloc | |
from starkware.cairo.common.invoke import invoke | |
from starkware.cairo.common.registers import get_label_location | |
func add_nums(a: felt, b: felt) -> (sum: felt): | |
return (a + b) | |
end | |
func invoke_func( | |
func_ptr : codeoffset, | |
foo_args_len: felt, | |
foo_args: felt*, | |
): | |
let (func_pc) = get_label_location(func_ptr) | |
invoke(func_pc, foo_args_len, foo_args) | |
return () | |
end | |
@external | |
func test_generic(): | |
alloc_locals | |
let (local array : felt*) = alloc() | |
assert array[0] = 1 | |
assert array[1] = 2 | |
invoke_func(add_nums, 2, array) | |
return () | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment