-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rust: Procedural macro for automatic VM declaration
- Loading branch information
Showing
11 changed files
with
505 additions
and
57 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
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
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,10 @@ | ||
[package] | ||
name = "evmc-declare-tests" | ||
version = "6.3.0-dev" | ||
authors = ["Jake Lang <jak3lang@gmail.com>"] | ||
edition = "2018" | ||
|
||
[dependencies] | ||
evmc-declare = { path = "../evmc-declare" } | ||
evmc-sys = { path = "../evmc-sys" } | ||
evmc-vm = { path = "../evmc-vm" } |
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,20 @@ | ||
use evmc_vm::EvmcVm; | ||
use evmc_vm::ExecutionContext; | ||
use evmc_vm::ExecutionResult; | ||
#[macro_use] | ||
use evmc_declare::evmc_declare_vm; | ||
|
||
#[evmc_declare_vm("Foo VM", "ewasm")] | ||
pub struct FooVM { | ||
a: i32, | ||
} | ||
|
||
impl EvmcVm for FooVM { | ||
fn init() -> Self { | ||
FooVM { a: 105023 } | ||
} | ||
|
||
fn execute(&self, code: &[u8], context: &ExecutionContext) -> ExecutionResult { | ||
ExecutionResult::new(evmc_sys::evmc_status_code::EVMC_SUCCESS, 235117, None) | ||
} | ||
} |
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,20 @@ | ||
[package] | ||
name = "evmc-declare" | ||
version = "6.3.0-dev" | ||
authors = ["Jake Lang <jak3lang@gmail.com>"] | ||
edition = "2018" | ||
|
||
[dependencies] | ||
quote = "0.6.12" | ||
heck = "0.3.1" | ||
proc-macro2 = "0.4.29" | ||
|
||
# For documentation examples | ||
evmc-vm = { path = "../evmc-vm" } | ||
|
||
[dependencies.syn] | ||
version = "0.15.33" | ||
features = ["full"] | ||
|
||
[lib] | ||
proc-macro = true |
Oops, something went wrong.