Commit 65fef7b
authored
refactor: Add a new trait between AsmMachine and Box<AsmCoreMachine> (#472)
In current design, AsmMachine is a rigid type containing
Box<AsmCoreMachine> directly. This is required in a sense that assembly
VM needs to know the inner data structures of AsmCoreMachine so as to
function. However, It also puts a restriction on AsmMachine: while you
can do the following in Rust VM:
```
DefaultMachine<Foo<DefaultCoreMachine<...>>
```
as long as Foo implements SupportMachine via a newtype pattern, this is
not possible on AsmMachine. However there are certain cases we need
wrappers on `Box<AsmCoreMachine>` to customize behaviors. This commit
introduces a a new trait `AsmCoreMachineRevealer` between AsmMachine and
AsmCoreMachine, it provides a mean for users of AsmMachine to customize
its behavior, while also requires the presence of AsmCoreMachine, so
assembly VM can still function.
If only Rust has generic specialization, we won't need to go through all
those troubles...1 parent 610fb29 commit 65fef7b
2 files changed
+161
-122
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
0 commit comments