[Q] I was wondering is it possible to get an address of a struct on the memory space? Inside initialise()
function after the Node
object creation, I want to get is address if it is possible. Since between contracts I can only transfer its address value.
Thank you for your valuable time and help.
library LinkedList {
uint80 constant None = uint80(0); /// NULL value.
struct data {
Node head;
Node[] node_array;
}
struct Node {
string data;
uint80 prev;
uint80 next;
}
function initialize(data storage self){
self.head = Node({prev: None, next: None, data: "",});
self.head.next = /// self.head's address.
}
}
Inside initialize()
following code piece works:
Node s = self.node_array[index];
uint addr;
assembly {
addr := s
}
Inside initialize()
the following code piece does not work:
Error: Expected elementary inline assembly operation.
self.head = Node({prev: None, next: None, data: 10,});
uint addr;
assembly {
addr := self.head
}
or
Node new_node;
new_node.data = d;
new_node.next = h.next;
new_node.prev = h.own;
uint newnode_addr;
assembly {
newnode_addr := new_node
}
newnode_addr
returns 0 instead of a valid address.
I am not able to do following assignment also:
Error: Type struct Node memory is not implicitly convertible to expected type struct Node storage pointer.
Node newnode = Node({prev: None, next: None, data: 10,});