contract c {
struct Data {
u256 x;
u256 y;
}
Data[2**10] data;
u256[2**10 + 3] ids;
fn setIDStatic(u256 id) {
ids[2] = id;
}
fn setID(u256 index, u256 id) {
ids[index] = id;
}
fn setData(u256 index, u256 x, u256 y) {
data[index].x = x;
data[index].y = y;
}
fn getID(u256 index) -> (u256) {
return ids[index];
}
fn getData(u256 index) -> (u256 x, u256 y) {
x = data[index].x;
y = data[index].y;
}
fn getLengths() -> (u256 l1, u256 l2) {
l1 = data.length;
l2 = ids.length;
}
}
// ====
// compileToEwasm: also
// compileViaYul: also
// ----
// setIDStatic(u256): 0xb ->
// getID(u256): 0x2 -> 0xb
// setID(u256,u256): 0x7, 0x8 ->
// getID(u256): 0x7 -> 0x8
// setData(u256,u256,u256): 0x7, 0x8, 0x9 ->
// setData(u256,u256,u256): 0x8, 0xa, 0xb ->
// getData(u256): 0x7 -> 0x8, 0x9
// getData(u256): 0x8 -> 0xa, 0xb
// getLengths() -> 0x400, 0x403