zink-lang / zink

Rustic programming language that targets the Ethereum Virtual Machine
https://zink-lang.org
GNU General Public License v3.0
137 stars 12 forks source link

Dynamic arrays as parameters of internal functions #250

Open clearloop opened 1 month ago

clearloop commented 1 month ago

Describe the feature

for the case using dynamic parameters in internal functions:

pub fn foo(arr: String) {
  // here we are using `calldataload`
  bar(arr)
}

fn bar(arr: String) {
  // do sth ...
}

Solution

We are loading parameters of internal function from memory in zink, the memory slots are allocated in compilation but for dynamic variables, we'll use the pre-calculated slot & MSIZE to implement this

NOTE: if the above solution doesn't work, try to figure out a better one, otherwise totally align to solidity's implementation