std:EVM/Runtime
lib/EVM/Runtime.omg
lib/EVM/Runtime.omg93 lines
1-- Compiler-owned native boundary operations. Handlers receive the restricted
2-- effect capabilities, never this record or the mutable memory behind Text.
3let Word256 = Word 256
4let State = std:EVM/State
5let Layout = std:EVM/State/Layout
6let Target = Word 160
7let Solidity = std:EVM/Solidity
8let Wire = < Native | Solidity : Solidity.Description >
9let Boundary =
10 < Native : Text
11 | NativeIn : { owner : Text, name : Text }
12 | Solidity :
13 { name : Text
14 , arguments : Solidity.Description
15 , result : Solidity.Description
16 , errors : Solidity.Description
17 }
18 >
19let Piece = < Raw : std:EVM/Signature.Chunk Word256 | Text : Text >
20-- The storage operations act on one owner, named by its selection: its type
21-- carries the validity proof, so no unchecked description reaches the
22-- compiler. Their meanings, over a logical state with one value per owner
23-- (the selection's reservation start); placement inside an owner is not
24-- observable:
25-- withState S sel k = k sel. The compiler passes a handle to the decoded
26-- plan where the continuation expects the selection.
27-- getState S A sel p k = k (the value at p). An index past the length
28-- reverts with empty data; a key never written reads the default of the
29-- value type.
30-- setState S A sel p v k = replace the value at p by v, then k.
31-- appendState S A sel p xs k = extend the list at p by xs, then k; reverts
32-- with empty data if its length would reach 2^64.
33-- stateLength S A sel p k = k (the length of the list at p).
34let Ops =
35 \(Code : Type) ->
36 { evm : std:EVM/Signature.Ops Word256 Bool Code
37 , readText : Word256 -> (Text -> Word256 -> Code) -> Code
38 , outputNative : List Piece -> Code
39 , readValue : forall (A : Type) -> Word256 -> (A -> Code) -> Code
40 , readSolidity : forall (A : Type) -> Solidity.Description -> Word256 -> (A -> Code) -> Code
41 , outputSolidity : forall (A : Type) -> Solidity.Description -> A -> Code
42 , emitSolidity : forall (A : Type) -> Solidity.Description -> A -> Code -> Code
43 , rejectSolidity : forall (A : Type) -> Solidity.Description -> A -> Code
44 , emitValue : forall (A : Type) -> Text -> A -> Code -> Code
45 , rejectValue : forall (A : Type) -> Text -> A -> Code
46 , callValue :
47 forall (A B : Type)
48 -> Boundary
49 -> Target
50 -> Optional Word256
51 -> A
52 -> (B -> Code)
53 -> Code
54 , tryCallValue :
55 forall (E A B : Type)
56 -> Boundary
57 -> Target
58 -> Optional Word256
59 -> A
60 -> (E -> Code)
61 -> (B -> Code)
62 -> Code
63 , optionalCallValue :
64 forall (A B : Type)
65 -> Boundary
66 -> Target
67 -> Optional Word256
68 -> A
69 -> Code
70 -> (B -> Code)
71 -> Code
72 , outputValue : forall (A : Type) -> A -> Code
73 , withState :
74 forall (S : Type) -> Layout.Selection S -> (Layout.Selection S -> Code) -> Code
75 , getState :
76 forall (S A : Type) -> Layout.Selection S -> State.Path S A -> (A -> Code) -> Code
77 , setState :
78 forall (S A : Type) -> Layout.Selection S -> State.Path S A -> A -> Code -> Code
79 , appendState :
80 forall (S A : Type)
81 -> Layout.Selection S
82 -> State.Path S (List A)
83 -> List A
84 -> Code
85 -> Code
86 , stateLength :
87 forall (S A : Type)
88 -> Layout.Selection S
89 -> State.Path S (List A)
90 -> (Word256 -> Code)
91 -> Code
92 }
93in { Piece, Boundary, Wire, Ops }