-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
04eeb12
commit b93a81b
Showing
3 changed files
with
409 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Call | ||
|
||
```k | ||
requires "../configuration.md" | ||
requires "../switch.md" | ||
requires "../soroban.md" | ||
requires "integer.md" | ||
module HOST-CALL | ||
imports CONFIG-OPERATIONS | ||
imports SOROBAN-SYNTAX | ||
imports HOST-INTEGER | ||
imports SWITCH-SYNTAX | ||
``` | ||
|
||
## call | ||
|
||
```k | ||
// TODO Check reentry | ||
rule [hostfun-require-auth]: | ||
<instrs> hostCall ( "d" , "_" , [ i64 i64 i64 .ValTypes ] -> [ i64 .ValTypes ] ) | ||
=> loadObject(HostVal(ARGS)) | ||
~> loadObject(HostVal(FUNC)) | ||
~> loadObject(HostVal(ADDR)) | ||
~> call | ||
... | ||
</instrs> | ||
<locals> | ||
0 |-> < i64 > ADDR // Address | ||
1 |-> < i64 > FUNC // Symbol | ||
2 |-> < i64 > ARGS // Vec | ||
</locals> | ||
syntax InternalInstr ::= "call" [symbol(call)] | ||
// ------------------------------------------ | ||
rule [call]: | ||
<instrs> call | ||
=> #waitCommands | ||
~> returnCallResult | ||
... | ||
</instrs> | ||
<hostStack> ScAddress(TO) : Symbol(FUNC) : ScVec(ARGS) : S => S </hostStack> | ||
<callee> FROM </callee> | ||
<k> (.K => callContract(FROM, TO, FUNC, ARGS)) ... </k> | ||
syntax InternalInstr ::= "returnCallResult" [symbol(returnCallResult)] | ||
// ------------------------------------------------------------------------ | ||
rule [returnCallResult-error]: | ||
<instrs> returnCallResult => trap ... </instrs> | ||
<hostStack> Error(_,_) : _ </hostStack> | ||
rule [returnCallResult]: | ||
<instrs> returnCallResult | ||
=> allocObject(RES) | ||
~> returnHostVal | ||
... | ||
</instrs> | ||
<hostStack> RES:ScVal : S => S </hostStack> | ||
[owise] | ||
endmodule | ||
``` |
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
Oops, something went wrong.