-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initialize the static variables without main method. #237
Comments
@lightszero What do you think? |
We should call the static constructor first |
Maybe we need a constructor method for each contract, like c# class? |
简洁的修改方式 是 懒汉模式,在每个入口函数插入一个检查。 |
But it should be executed once, if we call a recursive method, it should be executed only once.
|
Translate to EN: A simple way is to use lazy mode, insert a check method to init those static variables at the entry of each function. |
If we use lazy mode, it's not a problem. |
@erikzhang If we want to use lazy mode, could we add a new opcode if static field slot is null return null
else return slot.count |
Another way is that when we deploy a contract at the begining, we should call its constructor to complete its initialization(including static variables) |
My solution is that we allow the contract to have an optional special method: When an contract is invoked, we check its ABI first. If it has the method |
we can call it in other execution context, and after it, call the user method |
Personally, I don't want to see that we have too many special functions, we already have one. I think we can adjust NEF format, make NEF like window's exe format, which have different segments. |
I think we can implement the |
It's a good idea, if we process the static constructor, and after it, we save the static variables in the nef file, it could be easier to execute. |
got it |
close it via #219 . |
As #219 , we add abi offset for every method. But if there are static variables, we need to load them first.
The text was updated successfully, but these errors were encountered: